deslop 0.2.0

A static analyzer that spots low-context and AI-assisted code patterns across naming, concurrency, security, performance, and test quality.
Documentation
use super::{RuleConfigurability, RuleDefaultSeverity, RuleDefinition, RuleLanguage, RuleStatus};

pub(crate) const RULE_DEFINITIONS: &[RuleDefinition] = &[
    RuleDefinition {
        id: "dict_items_or_keys_materialized_in_loop",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "dict.items(), keys(), or values() are repeatedly materialized inside loops.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "enumerate_on_range_len",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "enumerate(range(len(...))) style loops that add indexing ceremony without extra value.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "in_check_on_list_literal",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "Membership tests against list literals where a tuple or set would be clearer or cheaper.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "json_loads_same_payload_multiple_times",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "The same JSON payload is decoded multiple times inside one function instead of caching the parsed value.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "list_comprehension_only_for_length",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "A list comprehension is built only so len(...) can be called on it.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "read_then_splitlines",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "File contents are fully read and then splitlines() is called instead of streaming lines.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "readlines_then_iterate",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "readlines() materializes the whole file before line-by-line iteration.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "regex_compile_in_hot_path",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "re.compile(...) or similar regex compilation repeated inside hot code paths.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "repeated_json_dumps_same_object",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "json.dumps(...) is repeated for the same object instead of caching the serialized value.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "repeated_open_same_file_in_function",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "The same file appears to be opened multiple times within one function.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "sorted_only_for_first_element",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "A sequence is fully sorted even though only the first or smallest element is used.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "string_startswith_endswith_chain",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "Repeated startswith(...) or endswith(...) checks that can often be combined into tuple-based calls.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
    RuleDefinition {
        id: "write_without_buffering_in_loop",
        language: RuleLanguage::Python,
        family: "hot_path",
        default_severity: RuleDefaultSeverity::Info,
        status: RuleStatus::Stable,
        configurability: &[
            RuleConfigurability::Disable,
            RuleConfigurability::Ignore,
            RuleConfigurability::SeverityOverride,
        ],
        description: "Repeated writes inside loops with no visible buffering or batching.",
        binding_location: super::bindings::PYTHON_HOTPATH,
    },
];