chore: Add clippy lints (#529)

Lints are added (deny) at crate level.

In each offending file, the failing lints are explicitly allowed.
Each file will be fixed in subsequent PRs.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2025-12-23 15:59:34 -06:00
committed by GitHub
parent 604591a0f7
commit 249dcd0b43
121 changed files with 703 additions and 23 deletions

View File

@@ -1,3 +1,4 @@
#![allow(clippy::missing_const_for_fn)]
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

View File

@@ -1,3 +1,4 @@
#![allow(clippy::missing_const_for_fn, clippy::pattern_type_mismatch)]
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

View File

@@ -1,5 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::unused_trait_names)]
#![allow(missing_debug_implementations)] // parser structs are internal; Debug not required
use alloc::boxed::Box;
use alloc::format;

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::pattern_type_mismatch)]
use alloc::string::String;

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::arithmetic_side_effects, clippy::unused_trait_names)]
use alloc::format;
use alloc::string::{String, ToString};

View File

@@ -5,6 +5,7 @@
#[cfg(test)]
mod condition_tests {
#![allow(clippy::panic, clippy::unwrap_used, clippy::expect_used)] // tests unwrap/expect to assert parse results
use crate::languages::azure_rbac::parser::*;
use alloc::string::String;
use alloc::vec;

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::as_conversions)]
use super::{CompilationContext, Compiler, ComprehensionType, ContextType, Register, Result};
use crate::ast::{ExprRef, Query};

View File

@@ -1,5 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::arithmetic_side_effects,
clippy::expect_used,
clippy::as_conversions,
clippy::unused_trait_names
)]
use super::{CompilationContext, Compiler, CompilerError, Register, Result, Scope};
use crate::ast::ExprRef;

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::pattern_type_mismatch)]
use super::Compiler;
use super::Register;
use crate::compiler::destructuring_planner::plans::{

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::pattern_type_mismatch)]
use alloc::format;
use alloc::string::String;

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::unused_trait_names, clippy::pattern_type_mismatch)]
mod collection_literals;
mod operations;

View File

@@ -1,5 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::indexing_slicing,
clippy::as_conversions,
clippy::pattern_type_mismatch
)]
use super::{Compiler, Register, Result};
use crate::ast::ExprRef;

View File

@@ -1,5 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(clippy::pattern_type_mismatch)]
use super::{Compiler, CompilerError, Register, Result};
use crate::ast::{ArithOp, BinOp, BoolOp, ExprRef};

View File

@@ -1,5 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::arithmetic_side_effects,
clippy::indexing_slicing,
clippy::unseparated_literal_suffix,
clippy::as_conversions,
clippy::unused_trait_names,
clippy::pattern_type_mismatch
)]
use super::{Compiler, CompilerError, Register, Result};
use crate::ast::ExprRef;

View File

@@ -1,5 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::indexing_slicing,
clippy::arithmetic_side_effects,
clippy::as_conversions,
clippy::unused_trait_names,
clippy::pattern_type_mismatch
)]
use super::{CompilationContext, Compiler, CompilerError, ContextType, Register, Result};
use crate::ast::{self, ExprRef, LiteralStmt, Query};

View File

@@ -1,3 +1,11 @@
#![allow(
missing_debug_implementations,
clippy::missing_const_for_fn,
clippy::option_if_let_else,
clippy::if_then_some_else_none,
clippy::unused_self
)] // compiler internals do not require Debug
mod comprehensions;
mod core;
mod destructuring;

View File

@@ -1,5 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::indexing_slicing,
clippy::as_conversions,
clippy::unused_trait_names,
clippy::pattern_type_mismatch
)]
use super::{Compiler, CompilerError, Result};
use crate::interpreter::Interpreter;

View File

@@ -1,5 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::indexing_slicing,
clippy::as_conversions,
clippy::pattern_type_mismatch
)]
use super::{Compiler, CompilerError, ComprehensionType, ContextType, Result};
use crate::ast::{self, LiteralStmt, Query};

View File

@@ -1,5 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::indexing_slicing,
clippy::expect_used,
clippy::as_conversions,
clippy::unused_trait_names,
clippy::pattern_type_mismatch
)]
use super::{Compiler, CompilerError, Register, Result, WorklistEntry};
use crate::lexer::Span;

View File

@@ -1,5 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#![allow(
clippy::indexing_slicing,
clippy::arithmetic_side_effects,
clippy::unwrap_used,
clippy::shadow_unrelated,
clippy::as_conversions,
clippy::unused_trait_names,
clippy::pattern_type_mismatch
)]
use super::{CompilationContext, Compiler, CompilerError, ContextType, Result, WorklistEntry};
use crate::ast::{Expr, Rule, RuleHead};
@@ -105,12 +114,11 @@ impl<'a> Compiler<'a> {
}
fn find_module_index_for_rule(&self, rule_ref: &crate::ast::NodeRef<Rule>) -> Result<u32> {
let rule_ptr = rule_ref.as_ref() as *const Rule;
let rule = rule_ref.as_ref();
for (module_idx, module) in self.policy.get_modules().iter().enumerate() {
for policy_rule in &module.policy {
let policy_rule_ptr = policy_rule.as_ref() as *const Rule;
if policy_rule_ptr == rule_ptr {
if core::ptr::eq(policy_rule.as_ref(), rule) {
return Ok(module_idx as u32);
}
}
@@ -126,12 +134,11 @@ impl<'a> Compiler<'a> {
) -> Result<(String, u32)> {
if let Some(rule_definitions) = rules.get(rule_path) {
if let Some(first_rule_ref) = rule_definitions.first() {
let rule_ptr = first_rule_ref.as_ref() as *const Rule;
let rule = first_rule_ref.as_ref();
for (module_index, module) in self.policy.get_modules().iter().enumerate() {
for policy_rule in &module.policy {
let policy_rule_ptr = policy_rule.as_ref() as *const Rule;
if policy_rule_ptr == rule_ptr {
if core::ptr::eq(policy_rule.as_ref(), rule) {
let package_path =
match get_path_string(&module.package.refr, Some("data")) {
Ok(path) => path,