use super::{RuleConfigurability, RuleDefaultSeverity, RuleDefinition, RuleLanguage, RuleStatus};
pub(crate) const RULE_DEFINITIONS: &[RuleDefinition] = &[
RuleDefinition {
id: "concatenation_in_comprehension_body",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "String or collection concatenation happens inside a comprehension body, creating avoidable churn.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "dict_copy_in_loop_same_source",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "A dict-like source is copied on each loop iteration instead of being reused or hoisted.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "gzip_open_per_chunk",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "gzip open/create calls are repeated per chunk instead of per stream.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "list_copy_in_loop_same_source",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "A list is copied on each loop iteration even though the source appears unchanged.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "nested_list_search_map_candidate",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "Nested linear list searches that look like they want a temporary map or set index.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "path_resolve_or_expanduser_in_loop",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "Path resolution helpers such as resolve() or expanduser() run inside loops on invariant inputs.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "pickle_dumps_in_loop_same_structure",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "pickle.dumps(...) is called repeatedly for the same structural shape in a loop.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "repeated_datetime_strptime_same_format",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "datetime.strptime(...) is repeated with the same format string instead of reusing a parsed shape or preprocessing once.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "repeated_dict_get_same_key_no_cache",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "The same dictionary key is fetched repeatedly instead of storing the value in a local binding.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "repeated_hashlib_new_same_algorithm",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "The same hashing algorithm is repeatedly constructed in a loop or tight path.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "repeated_isinstance_chain_same_object",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "The same object goes through repeated isinstance(...) checks that could be consolidated.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "repeated_list_index_lookup",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "The same list index lookup is performed repeatedly instead of caching the accessed value.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "repeated_locale_or_codec_lookup_in_loop",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "Locale or codec lookups repeat inside loops instead of being cached once.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "repeated_string_format_invariant_template",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "An invariant string template is formatted repeatedly in a loop instead of being partially precomputed.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "set_created_per_iteration_same_elements",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "A set with the same elements is rebuilt on each iteration instead of being hoisted.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "sort_then_first_or_membership_only",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "A collection is sorted even though only the first element or a membership-style check is needed.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "string_join_without_generator",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "String joins that materialize an unnecessary list comprehension instead of using a generator or direct iterable.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "tuple_unpacking_in_tight_loop",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "Tuple unpacking is repeated in tight loops where reducing per-iteration overhead may help.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "urlparse_in_loop_on_invariant_base",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "urlparse() or urlsplit() is repeated inside loops for invariant base values.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "xml_parse_same_payload_multiple_times",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "The same XML payload is parsed repeatedly within one function.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
RuleDefinition {
id: "yaml_load_same_payload_multiple_times",
language: RuleLanguage::Python,
family: "hot_path_ext",
default_severity: RuleDefaultSeverity::Info,
status: RuleStatus::Stable,
configurability: &[
RuleConfigurability::Disable,
RuleConfigurability::Ignore,
RuleConfigurability::SeverityOverride,
],
description: "The same YAML payload is parsed repeatedly within one function.",
binding_location: super::bindings::PYTHON_HOTPATH_EXT,
},
];