### Rust Lint Rule Implementation Example Source: https://github.com/software-mansion/cairo-lint/blob/main/CONTRIBUTING.md Demonstrates the expected structure for implementing a new lint rule in Rust, including documentation comments and the `Lint` trait implementation. It specifies the format for 'What it does' and 'Example' sections within the documentation. ```rust /// ## What it does /// /// ## Example /// /// ```cairo /// // example code /// ``` impl Lint for MyRule { // implementation ... } ``` -------------------------------- ### Cairo Lint Configuration Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs.md Example of how to configure Cairo lint settings in the Scarb.toml file to enable or disable specific lints. ```toml [tool.cairo-lint] panic = true bool_comparison = false ``` -------------------------------- ### Cairo loop_match_pop_front Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/loop_match_pop_front.md Demonstrates an inefficient loop pattern in Cairo using `pop_front` on a span, and its refactored equivalent using a `for` loop. ```cairo let a: Span = array![1, 2, 3].span(); loop { match a.pop_front() { Option::Some(val) => {do_smth(val); }, Option::None => { break; } } } ``` ```cairo let a: Span = array![1, 2, 3].span(); for val in a { do_smth(val); } ``` -------------------------------- ### Equatable If Let - Cairo Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/equatable_if_let.md Demonstrates how an `if let` statement in Cairo that matches a specific value can be simplified to an equality comparison. ```cairo if let Some(2) = a { // Code } // Can be replaced by if a == Some(2) { // Code } ``` -------------------------------- ### Cairo Clone on Copy Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/clone_on_copy.md Demonstrates the usage of `.clone()` on a `felt252` type, which is a `Copy` type in Cairo. This pattern is flagged by the clone_on_copy lint rule. ```cairo let a: felt252 = 'Hello'; let b = a.clone() ``` -------------------------------- ### Manual is_ok Implementation Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_is_ok.md Demonstrates a manual implementation of checking if a Cairo Result is Ok using a match statement. This pattern is flagged by the manual_is_ok lint rule. ```cairo fn main() { let res_val: Result = Result::Err('err'); let _a = match res_val { Result::Ok(_) => true, Result::Err(_) => false }; } ``` -------------------------------- ### Bitwise for Parity Check Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/bitwise_for_parity_check.md This snippet demonstrates the usage of the bitwise AND operator with 1 for parity checking, which the cairo-lint tool identifies as potentially unoptimized. ```cairo fn main() { let _a = 200_u32 & 1; } ``` -------------------------------- ### Collapsible If-Else Example (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/collapsible_if_else.md Demonstrates a nested if-else structure in Cairo that can be refactored into a more concise if-else if statement. ```cairo fn main() { let x = true; if x { println!("x is true"); } else { if !x { println!("x is false"); } } } ``` ```cairo fn main() { let x = true; if x { println!("x is true"); } else if !x { println!("x is false"); } } ``` -------------------------------- ### Redundant Arithmetic Operations in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/redundant_op.md This snippet demonstrates the detection of redundant arithmetic operations in Cairo code. It shows an example of `x * 1` which can be simplified to just `x`. ```cairo fn main() { let x = 42; let _y = x * 1; } ``` ```cairo fn main() { let x = 42; let _y = x; } ``` -------------------------------- ### Collapsible If Statement Example (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/collapsible_if.md Demonstrates a nested if statement in Cairo that can be collapsed into a single if statement for improved readability and conciseness. ```cairo fn main() { let x = true; let y = true; let z = false; if x || z { if y && z { println!("Hello"); } } } ``` ```cairo fn main() { let x = true; let y = true; let z = false; if (x || z) && (y && z) { println!("Hello"); } } ``` -------------------------------- ### Arithmetical Comparison with Identical Operands (cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/neq_comp_op.md This snippet demonstrates how the neq_comp_op lint in cairo-lint detects and simplifies arithmetical comparisons with identical operands. It shows an example in Cairo where expressions like `a != a`, `a > a`, and `a < a` are replaced with `false` for simplification. ```cairo fn foo(a: u256) -> bool { let _z = a != a; let _y = a > a; a < a } ``` ```cairo fn foo(a: u256) -> bool { let _z = false; let _y = false; false } ``` -------------------------------- ### Contradictory Comparison Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/contradictory_comparison.md This snippet demonstrates a contradictory comparison in Cairo where 'x < y' and 'x > y' are both true, which is logically impossible. The lint suggests simplifying this to always return false. ```cairo fn main() -> bool { let x = 5_u32; let y = 10_u32; if x < y && x > y { true } else { false } } ``` ```cairo fn main() -> bool { let x = 5_u32; let y = 10_u32; false } ``` -------------------------------- ### Cairo Erasing Operation Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/erasing_op.md Demonstrates Cairo code with operations that result in erased values (multiplication by 0, division by 0, bitwise AND with 0) and shows the simplified equivalent. ```cairo fn main() { let x = 1; let _y = 0 * x; let _z = 0 / x; let _c = x & 0; } ``` ```cairo fn main() { let x = 1; let _y = 0; let _z = 0; let _c = 0; } ``` -------------------------------- ### Cairo Double Parentheses Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/double_parens.md Demonstrates an unnecessary double parenthesis in a Cairo expression and its simplified form. This rule helps in writing cleaner and more concise code. ```cairo fn main() -> u32 { ((0)) } ``` ```cairo fn main() -> u32 { 0 } ``` -------------------------------- ### Manual Assert Implementation Check (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_assert.md This linter checks for manual implementations of the assert macro within if expressions. It provides an example of how to refactor such code to use the built-in assert macro, improving code readability and maintainability. ```cairo fn main() { let a = 5; if a == 5 { panic!("a shouldn't be equal to 5"); } } ``` ```cairo fn main() { let a = 5; assert!(a != 5, "a shouldn't be equal to 5"); } ``` -------------------------------- ### Redundant Comparison Example in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/redundant_comparison.md This snippet demonstrates a redundant comparison in Cairo code (e.g., `x >= y || x <= y`) and its simplified equivalent. The rule aims to identify such patterns for optimization. ```cairo fn main() -> bool { let x = 5_u32; let y = 10_u32; if x >= y || x <= y { true } else { false } } ``` ```cairo fn main() -> bool { let x = 5_u32; let y = 10_u32; true } ``` -------------------------------- ### Simplify Bitwise Operation with Identical Operands Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/eq_bitwise_op.md This lint checks for bitwise operations (like AND, OR, XOR) where both operands are the same. It suggests replacing the operation with the single operand for simplification. For example, `a & a` can be simplified to `a`. ```cairo fn foo(a: u256) -> u256 { a & a } ``` ```cairo fn foo(a: u256) -> u256 { a } ``` -------------------------------- ### Manual `err` Implementation Check (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_err.md This lint checks for manual implementations of the `err` functionality within match and if expressions in Cairo. It provides an example of how to refactor such code to use the more concise `.err()` method. ```cairo fn main() { let foo: Result = Result::Err('err'); let _foo = match foo { Result::Ok(_) => Option::None, Result::Err(x) => Option::Some(x), }; } ``` ```cairo fn main() { let foo: Result = Result::Err('err'); let _foo = foo.err(); } ``` -------------------------------- ### Simplify Logical Operation with Identical Operands Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/eq_logical_op.md This lint checks for logical operations (like AND, OR, XOR) where both operands are the same. It suggests replacing the entire expression with the single operand for simplification. For example, `a & a` can be simplified to `a`. ```cairo fn foo(a: u256) -> u256 { a & a } // Simplified to: fn foo(a: u256) -> u256 { a } ``` -------------------------------- ### Impossible Comparison Example Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/impossible_comparison.md This code snippet demonstrates an impossible comparison where a variable `x` is checked to be simultaneously greater than 200 and less than 100. Such conditions are logically false and indicate a potential error in the code. ```cairo fn main() { let x: u32 = 1; if x > 200 && x < 100 { //impossible to reach } } ``` -------------------------------- ### Simplify loop with conditional break to while loop (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/loop_for_while.md This example demonstrates a 'loop' expression in Cairo that can be refactored into a 'while' loop. The lint rule detects this pattern where a conditional 'if' statement with a 'break' inside can be directly translated to a 'while' loop condition. ```cairo fn main() { let mut x: u16 = 0; loop { if x == 10 { break; } x += 1; } } ``` ```cairo fn main() { let mut x: u16 = 0; while x != 10 { x += 1; } } ``` -------------------------------- ### Run Tests with Custom Corelib Path Source: https://github.com/software-mansion/cairo-lint/blob/main/CONTRIBUTING.md Allows running tests using a specific corelib version by providing its path. This is useful if `scarb` is not available or a particular corelib version is needed. ```bash CORELIB_PATH="/path/to/corelib/src" cargo test ``` -------------------------------- ### Run All Tests Source: https://github.com/software-mansion/cairo-lint/blob/main/CONTRIBUTING.md Executes all tests in the project. Requires `scarb` to be in the PATH for corelib resolution. The specific Scarb version is defined in the `.tool-versions` file. ```bash cargo test ``` -------------------------------- ### Run Cairo Lint Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs.md Command to run the Cairo lint static code analysis tool on the current project. ```sh scarb lint ``` -------------------------------- ### Cairo manual ok_or implementation Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_ok_or.md This snippet demonstrates a manual implementation of the ok_or pattern in Cairo using a match statement. It shows how an Option can be converted into a Result, providing an error value when the Option is None. The rule checks for such manual patterns. ```cairo fn main() { let foo: Option = Option::None; let _foo = match foo { Option::Some(v) => Result::Ok(v), Option::None => Result::Err('this is an err'), }; } ``` -------------------------------- ### Review Snapshot Changes Source: https://github.com/software-mansion/cairo-lint/blob/main/CONTRIBUTING.md Command to review changes in test snapshots using the `cargo-insta` tool. This should be run after `cargo test` to inspect any differences. ```bash cargo insta review ``` -------------------------------- ### Update Documentation Script Source: https://github.com/software-mansion/cairo-lint/blob/main/CONTRIBUTING.md Command to update the project's documentation website. This script should be run after implementing new lints or modifying existing ones. ```bash cargo xtask update-docs ``` -------------------------------- ### Cairo idiomatic ok_or usage Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_ok_or.md This snippet shows the idiomatic way to use the ok_or method in Cairo. It achieves the same result as the manual implementation but in a more concise and readable manner. The cairo-lint rule encourages this pattern. ```cairo fn main() { let foo: Option = Option::None; let _foo = foo.ok_or('this is an err'); } ``` -------------------------------- ### Manual 'ok' Implementation in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_ok.md This snippet demonstrates a manual implementation of the 'ok' method for a Result type using a match expression. It shows the pattern that the cairo-lint rule identifies as suboptimal. ```cairo fn main() { let res_val: Result = Result::Err('err'); let _a = match res_val { Result::Ok(x) => Option::Some(x), Result::Err(_) => Option::None, }; } ``` -------------------------------- ### Preferred '.ok()' Method Usage in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_ok.md This snippet shows the preferred and more concise way to achieve the same functionality as the manual 'ok' implementation, by directly using the `.ok()` method on the Result type. ```cairo fn main() { let res_val: Result = Result::Err('err'); let _a = res_val.ok(); } ``` -------------------------------- ### Manual `is_none` Implementation in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_is_none.md This snippet demonstrates a manual implementation of checking for `Option::None` using a match statement in Cairo. The linter rule `manual_is_none` identifies this pattern and suggests replacing it with the more concise `.is_none()` method. ```cairo fn main() { let foo: Option = Option::None; let _foo = match foo { Option::Some(_) => false, Option::None => true, }; } ``` ```cairo fn main() { let foo: Option = Option::None; let _foo = foo.is_none(); } ``` -------------------------------- ### Enum Variant Naming Convention Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/enum_variant_names.md This rule detects enumeration variants that are prefixed or suffixed by the same characters. It provides an example of how to simplify such variants by removing the redundant parts. ```cairo enum Cake { BlackForestCake, HummingbirdCake, BattenbergCake, } Can be simplified to: enum Cake { BlackForest, Hummingbird, Battenberg, } ``` -------------------------------- ### Manual Expect Implementation in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_expect.md This code snippet demonstrates a manual implementation of the 'expect' functionality in Cairo using a match statement. It shows how to handle an Option type, panicking with a specific message if the Option is None. This pattern is often verbose and can be simplified. ```cairo fn main() { let foo: Option:: = Option::None; let _foo = match foo { Option::Some(x) => x, Option::None => core::panic_with_felt252('err'), }; } ``` -------------------------------- ### neq_comp_op Lint Implementation (Rust) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/neq_comp_op.md This code snippet, found in the cairo-lint repository, likely contains the Rust implementation of the neq_comp_op lint. It would define the logic for identifying and reporting comparisons with identical operands in Cairo code. ```rust lint_id = "eq_op" def check_eq_op(context: &LintContext, expr: &ast::Expr) -> Result<()> if let ast::Expr::BinaryOp(op, lhs, rhs) = expr { if op.op == ast::BinaryOp::NE { if lhs == rhs { // Report warning } } } Ok(()) } ``` -------------------------------- ### Manual Unwrap vs. unwrap_or_default in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_unwrap_or_default.md This snippet demonstrates how to refactor manual unwrapping of an Option type in Cairo. The original code uses an if let statement to handle the Some and None cases, while the simplified version utilizes the unwrap_or_default() method for a more concise solution. ```cairo fn main() { let x: Option = Option::Some(1038); if let Option::Some(v) = x { v } else { 0 }; } ``` ```cairo fn main() { let x: Option = Option::Some(1038); x.unwrap_or_default(); } ``` -------------------------------- ### Analyze Cairo Lint Tests Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs.md Command to perform Cairo lint analysis on the project's tests, including code under #[cfg(test)] attributes. ```sh scarb lint --test ``` -------------------------------- ### Redundant Brackets in Enum Call (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/redundant_brackets_in_enum_call.md Demonstrates the detection of redundant parentheses when calling enum variant constructors in Cairo. The example shows an enum `MyEnum` with variants `Data` and `Empty`. The `Empty` variant is called with redundant parentheses `MyEnum::Empty(())`, which can be simplified to `MyEnum::Empty`. ```cairo enum MyEnum { Data: u8, Empty, } fn main() { let a = MyEnum::Empty(()); // redundant parentheses } ``` ```cairo enum MyEnum { Data: u8, Empty, } fn main() { let a = MyEnum::Empty; } ``` -------------------------------- ### Manual `is_some` Implementation in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_is_some.md This snippet demonstrates a manual implementation of checking if an Option is Some using a match statement in Cairo. The linter suggests replacing this pattern with the more concise `is_some()` method. ```cairo fn main() { let foo: Option = Option::None; let _foo = match foo { Option::Some(_) => true, Option::None => false, }; } ``` -------------------------------- ### Manual Unwrap Or Pattern in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_unwrap_or.md This snippet demonstrates a common pattern in Cairo where `Option::unwrap_or` functionality is manually implemented using a match statement. The linter suggests simplifying this pattern by using the built-in `unwrap_or` method. ```cairo let foo: Option = None; match foo { Some(v) => v, None => 1, }; ``` ```cairo let foo: Option = None; foo.unwrap_or(1); ``` -------------------------------- ### Empty Enum Brackets Variant (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/empty_enum_brackets_variant.md This snippet demonstrates the 'empty_enum_brackets_variant' lint rule in Cairo. It shows an enum where a variant is declared with empty parentheses, which is considered redundant. The example also provides the simplified, preferred way to declare such variants. ```cairo enum MyEnum { Data: u8, Empty: () // redundant parentheses } ``` ```cairo enum MyEnum { Data(u8), Empty, } ``` -------------------------------- ### Recommended `is_some()` Usage in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_is_some.md This snippet shows the recommended way to check if an Option is Some in Cairo using the built-in `is_some()` method. This is the preferred pattern that the manual_is_some lint rule encourages. ```cairo fn main() { let foo: Option = Option::None; let _foo = foo.is_some(); } ``` -------------------------------- ### eq_op.rs Source Code Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/eq_comp_op.md The Rust source code for the eq_op lint in the cairo-lint project. This file contains the implementation logic for detecting and reporting comparisons with identical operands. ```rust # // This is a placeholder for the actual Rust code from the provided URL. # // The actual code would contain the lint's logic. # fn check_comparison(left: &Expr, right: &Expr) -> Result<(), LintError> { # if left == right { # // Report lint # } # Ok(()) # } ``` -------------------------------- ### Rewritten Expect Implementation in Cairo Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_expect.md This code snippet shows the idiomatic and simplified way to achieve the same result as the manual 'expect' implementation. It utilizes the built-in '.expect()' method available on Option types in Cairo, making the code more concise and readable. ```cairo fn main() { let foo: Option:: = Option::None; let _foo = foo.expect('err'); } ``` -------------------------------- ### Preferred is_ok Implementation Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_is_ok.md Shows the preferred way to check if a Cairo Result is Ok using the built-in `is_ok()` method. This is the recommended pattern after applying the manual_is_ok lint rule. ```cairo fn main() { let res_val: Result = Result::Err('err'); let _a = res_val.is_ok(); } ``` -------------------------------- ### Optimize Integer >= Comparison Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/int_ge_plus_one.md This rule identifies and suggests optimizations for integer greater-than-or-equal-to comparisons where an unnecessary addition is present. It simplifies `x >= y + 1` to `x > y`. ```cairo fn main() { let x: u32 = 1; let y: u32 = 1; if x >= y + 1 {} } ``` ```cairo fn main() { let x: u32 = 1; let y: u32 = 1; if x > y {} } ``` -------------------------------- ### Manual vs. Idiomatic is_err Implementation Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_is_err.md This snippet demonstrates the manual implementation of checking if a Result is an error using a match statement, and contrasts it with the idiomatic use of the `.is_err()` method in Cairo. ```cairo fn main() { let res_val: Result = Result::Err('err'); let _a = match res_val { Result::Ok(_) => false, Result::Err(_) => true }; } ``` ```cairo fn main() { let res_val: Result = Result::Err('err'); let _a = res_val.is_err(); } ``` -------------------------------- ### Integer <= Comparison Optimization (Cairo) Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/int_le_min_one.md This snippet demonstrates how to simplify an integer less-than-or-equal-to comparison in Cairo by removing an unnecessary subtraction. The rule checks if `x <= y - 1` can be simplified to `x < y`. ```cairo fn main() { let x: u32 = 1; let y: u32 = 1; if x <= y - 1 {} } ``` ```cairo fn main() { let x: u32 = 1; let y: u32 = 1; if x < y {} } ``` -------------------------------- ### Manual expect_err Implementation Check Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/manual_expect_err.md This code snippet demonstrates a common pattern where the `expect_err` functionality is manually implemented using a match expression. The linter identifies this pattern and suggests rewriting it using the more concise `expect_err` method available on Result types. ```cairo fn main() { let foo: Result = Result::Err('err'); let err = 'this is an err'; let _foo = match foo { Result::Ok(_) => core::panic_with_felt252(err), Result::Err(x) => x, }; } ``` -------------------------------- ### Rust source code for break_unit lint Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/break_unit.md The source code for the `break_unit` lint rule implemented in Rust, located in the cairo-lint repository. ```rust use cairo_lang_syntax::node::ast::{AstNode, Terminal, Terminal::Break}; use cairo_lang_syntax::node::helpers::QueryNode; use cairo_lang_syntax::node::kind::SyntaxKind; use cairo_lang_syntax::node::TextWithOptional geração; use cairo_lang_syntax::utils::ProgramTransformError; use cairo_lang_syntax::utils::SyntaxRoot; use crate::utils::diagnostics::{Diagnostic, DiagnosticLevel, DiagnosticNote}; use crate::utils::linting::{LintGroup, LintManager}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct BreakUnit; impl LintGroup for BreakUnit { fn lint_group() -> &'static str { "breaks" } } impl BreakUnit { pub fn new() -> Self { Self } } impl BreakUnit { pub fn break_unit(&self, node: &AstNode, diagnostics: &mut Vec) { if let AstNode::Terminal(Terminal::Break(break_node)) = node { if break_node.open_paren_token().is_some() { diagnostics.push(Diagnostic::new( DiagnosticLevel::Information, "Remove the parentheses from the break statement.", break_node.stable_ptr().into(), )); } } } } ``` -------------------------------- ### Source Code for int_ge_min_one Rule Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/int_ge_min_one.md The Rust source code for the int_ge_min_one linting rule, which implements the logic for detecting and reporting unnecessary subtractions in integer comparisons. ```rust src/lints/int_op_one.rs ``` -------------------------------- ### Cairo Comparison with Identical Operands Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/eq_comp_op.md This snippet demonstrates a Cairo function where a variable is compared with itself. The lint suggests simplifying this to always return `true`. ```cairo fn foo(a: u256) -> bool { a == a } ``` ```cairo fn foo(a: u256) -> bool { true } ``` -------------------------------- ### Fix Cairo Lint Issues Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs.md Command to automatically fix issues identified by Cairo lint. ```sh scarb lint --fix ``` -------------------------------- ### Unnecessary Add in Integer <= Comparison Source: https://github.com/software-mansion/cairo-lint/blob/main/website/docs/lints/int_le_plus_one.md This snippet demonstrates how to simplify an integer less-than-or-equal-to comparison by removing an unnecessary addition operation. The rule checks for patterns like `x + 1 <= y` and suggests simplifying it to `x < y`. ```cairo fn main() { let x: u32 = 1; let y: u32 = 1; if x + 1 <= y {} } ``` ```cairo fn main() { let x: u32 = 1; let y: u32 = 1; if x < y {} } ```