Public report of astral-sh/ruff, published 14 November 2026. It has the same score, grades and number of findings as the full report. The details of security findings (where they are in the code, which known vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive report Measured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.11.4). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey → Signed and filed in the standard's public register, 14 November 2026, 06:21 UTC · Survey ID cd_ec66386e570d45098e342b9200c0cfa8

astral-sh/ruff

Measured 14 November 2026, 06:01 UTC, at code version b140af2

CAI score 61out of 100 At risk Up 2 since the last survey

The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.

A very large codebase: 728,120 lines of product code in 88 projects, tests not counted · Estimated rebuild effort: about 6.6 person-years · Weakest lens: Code Health, 51

Findings by how serious they are

79 critical 3815 serious 221 minor

17 dimensions are left out of the score. For each one, we either couldn't measure it in this code, or found no evidence of the safeguard we look for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.

This survey was produced by

Assert small markCanine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
14 November 2026, 06:01 UTC

A measurement, not a certificate. The Code Assurance Index records a number together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee the code. The standard was written by Canine Development, which also builds the Canine Code Analyzer. It is open to any tool that implements it, and today the Canine Code Analyzer is the only one that does.

A critical security finding is open, such as a library with a known critical vulnerability or a password or key found in the code. The score itself is unchanged, but its band shows At risk until the finding is fixed. See the Security and Compliance lens.

The score is deterministic, which means the same code always gets the same score. We work it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸

58of 58 dimensions measured by tools.
4060of 4115 findings point to an exact file and line, so you can open each one in the code. The other 55 concern the repository as a whole, such as missing documentation.
58dimensions across 8 lenses, read from 728,120 lines of product code in 88 projects.
Chapters

Executive summary

astral-sh/ruff is rated At risk because critical security findings are open, most of them in the build pipeline. It scores 61 out of 100, which the At risk rating leaves unchanged. We judged it as a preview release, against a lower bar.

Code Health, at 51, is the weakest lens and counts most in the score. The best first step is writing log messages as searchable templates, worth about 6 points. Making the controls keyboard-usable comes next, worth about 5 points. Raising Code Health to 67 would lift the score to about 67.

Fifty-three pipeline tools are referenced by a changeable name, so the build pipeline can be tampered with. Thirteen secrets can leak from the build pipeline, and three weaknesses in the code could be used by an attacker. Pinning each tool to an exact version, limiting each secret to its own step and fixing the weaknesses the scanner points to would close these risks. Updating the vulnerable packages would fix the package with a known security hole, and the two unsafe settings in infrastructure or container files need changing to safe values. The two buttons or links with no name need a name, even when they only show an icon.

The product code is 728,120 lines, about €960,000 to rebuild.

A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.

How the score is built: what each lens counts for The lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Code Health 51 · counts for 45%Accessibility 59 · counts for 25%Security and Compliance 74 · counts for 14%Maturity 78 · counts for 8%Production Readiness 80 · counts for 4%Performance 94 · counts for 2%Architecture 97 · counts for 1%Event Sourcing 100 · counts for 1%

If Code Health rose from 51 to 67, the lowest score rated Strong, the score would rise from 61 to about 67.

Code composition: what the lines of code are
Product code 84%Tests 16%
New since the last survey: 907 findings

These 907 critical or serious findings weren't in the previous survey, on 26 October 2026. The first 100 are listed here, and the findings file in the download package lists them all.

  • Cyclomatic Complexity · ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name (cyclomatic 81) crates/ruff_linter/src/checkers/ast/analyze/expression.rs
  • Cyclomatic Complexity · StaticClassLiteral::own_generated_member (cyclomatic 70) crates/ty_python_semantic/src/types/class/static_literal.rs
  • Cyclomatic Complexity · ComparableExpr::eq (cyclomatic 64) crates/ruff_python_ast/src/comparable.rs
  • Cyclomatic Complexity · ComparableStmt::eq (cyclomatic 47) crates/ruff_python_ast/src/comparable.rs
  • Cyclomatic Complexity · Type::map_type (cyclomatic 44) crates/ty_python_semantic/src/types.rs
  • Cyclomatic Complexity · Mro::ancestors_of_static_class (cyclomatic 31) crates/ty_python_semantic/src/types/mro.rs
  • Cyclomatic Complexity · TypeInferenceBuilder::infer_enum_call_expression (cyclomatic 30) crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
  • Cyclomatic Complexity · TypeRelationChecker::check_target_union (cyclomatic 25) crates/ty_python_semantic/src/types/relation.rs
  • Cyclomatic Complexity · CallInference::select_return_type (cyclomatic 24) crates/ty_python_semantic/src/types/call/bind.rs
  • Cyclomatic Complexity · ty_python_semantic::types::diagnostic::report_incompatible_method_override (cyclomatic 24) crates/ty_python_semantic/src/types/diagnostic.rs
  • Cyclomatic Complexity · ty_python_semantic::types::overrides::attributes::attribute_violation (cyclomatic 24) crates/ty_python_semantic/src/types/overrides/attributes.rs
  • Cyclomatic Complexity · PlaceLoadResolutionProcedure::resolve_enclosing_scopes (cyclomatic 23) crates/ty_python_semantic/src/place_load.rs
  • Cyclomatic Complexity · PlaceLoadResolutionProcedure::next (cyclomatic 21) crates/ty_python_semantic/src/place_load.rs
  • Cyclomatic Complexity · ruff_linter::fix::codemods::remove_imports (cyclomatic 19) crates/ruff_linter/src/fix/codemods.rs
  • Cyclomatic Complexity · SolutionWalker::binary_lower_bound_visits (cyclomatic 19) crates/ty_python_semantic/src/types/constraints/solutions.rs
  • Cyclomatic Complexity · Binding::argument_type_context (cyclomatic 18) crates/ty_python_semantic/src/types/call/bind.rs
  • Cyclomatic Complexity · Signature::bind_self_with_receiver (cyclomatic 18) crates/ty_python_semantic/src/types/signatures.rs
  • Cyclomatic Complexity · ty_python_semantic::types::infer::builder::post_inference::static_class::check_inferred_classvars (cyclomatic 18) crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs
  • Cyclomatic Complexity · Generator::unparse_pattern (cyclomatic 17) crates/ruff_python_codegen/src/generator.rs
  • Cyclomatic Complexity · ArgumentTypeChecker::evaluate_paramspec_sub_call (cyclomatic 17) crates/ty_python_semantic/src/types/call/bind.rs
  • Cyclomatic Complexity · CallInference::infer_legacy (cyclomatic 17) crates/ty_python_semantic/src/types/call/bind.rs
  • Cyclomatic Complexity · ty_python_semantic::types::overrides::check_inherited_conflicts (cyclomatic 17) crates/ty_python_semantic/src/types/overrides.rs
  • Cyclomatic Complexity · ComparablePattern::eq (cyclomatic 16) crates/ruff_python_ast/src/comparable.rs
  • Cyclomatic Complexity · ty_module_resolver::resolve::is_pkgutil_extend_path (cyclomatic 16) crates/ty_module_resolver/src/resolve.rs
  • Cyclomatic Complexity · SemanticIndexBuilder::visit_bool_expression (cyclomatic 16) crates/ty_python_core/src/builder.rs
  • Cyclomatic Complexity · CandidateSolutions::promote_for_argument_context (cyclomatic 16) crates/ty_python_semantic/src/types/constraints.rs
  • Cyclomatic Complexity · FieldMetadata::collect_from_annotation (cyclomatic 16) crates/ty_python_semantic/src/types/dedicated/pydantic.rs
  • Cyclomatic Complexity · TypeInferenceBuilder::parse_enum_members_from_sequence (cyclomatic 16) crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
  • Cyclomatic Complexity · TypeInferenceBuilder::infer_subscript_expression_types (cyclomatic 16) crates/ty_python_semantic/src/types/infer/builder/subscript.rs
  • Cyclomatic Complexity · IntersectionBuilder::add_negative_impl (cyclomatic 16) crates/ty_python_semantic/src/types/set_theoretic/builder.rs
  • Cyclomatic Complexity · ty_python_semantic::types::overrides::attributes::bind_attribute (cyclomatic 16) crates/ty_python_semantic/src/types/overrides/attributes.rs
  • Cognitive Complexity · StaticClassLiteral::own_generated_member (cognitive 94) crates/ty_python_semantic/src/types/class/static_literal.rs
  • Cognitive Complexity · ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name (cognitive 81) crates/ruff_linter/src/checkers/ast/analyze/expression.rs
  • Cognitive Complexity · Mro::ancestors_of_static_class (cognitive 64) crates/ty_python_semantic/src/types/mro.rs
  • Cognitive Complexity · ComparableExpr::eq (cognitive 63) crates/ruff_python_ast/src/comparable.rs
  • Cognitive Complexity · ComparableStmt::eq (cognitive 45) crates/ruff_python_ast/src/comparable.rs
  • Cognitive Complexity · PlaceLoadResolutionProcedure::resolve_enclosing_scopes (cognitive 42) crates/ty_python_semantic/src/place_load.rs
  • Cognitive Complexity · TypeInferenceBuilder::infer_enum_call_expression (cognitive 35) crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
  • Cognitive Complexity · ty_python_semantic::types::diagnostic::report_incompatible_method_override (cognitive 32) crates/ty_python_semantic/src/types/diagnostic.rs
  • Cognitive Complexity · TypeRelationChecker::check_target_union (cognitive 31) crates/ty_python_semantic/src/types/relation.rs
  • Cognitive Complexity · ty_python_semantic::types::infer::builder::post_inference::static_class::check_inferred_classvars (cognitive 31) crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs
  • Cognitive Complexity · CallInference::select_return_type (cognitive 29) crates/ty_python_semantic/src/types/call/bind.rs
  • Cognitive Complexity · CallInference::infer_legacy (cognitive 29) crates/ty_python_semantic/src/types/call/bind.rs
  • Cognitive Complexity · Suppressions::check_rule_codes (cognitive 28) crates/ruff_linter/src/suppression.rs
  • Cognitive Complexity · TypeInferenceBuilder::report_import_not_found (cognitive 28) crates/ty_python_semantic/src/types/infer/builder/imports.rs
  • Cognitive Complexity · PlaceLoadResolutionProcedure::next (cognitive 27) crates/ty_python_semantic/src/place_load.rs
  • Cognitive Complexity · CandidateSolutions::promote_for_argument_context (cognitive 24) crates/ty_python_semantic/src/types/constraints.rs
  • Cognitive Complexity · TypeInferenceBuilder::parse_enum_members_from_sequence (cognitive 24) crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
  • Cognitive Complexity · ty_python_semantic::types::overrides::attributes::bind_attribute (cognitive 24) crates/ty_python_semantic/src/types/overrides/attributes.rs
  • Cognitive Complexity · CallInference::intersect_specialized_returns (cognitive 22) crates/ty_python_semantic/src/types/call/bind.rs
  • Cognitive Complexity · MroLookup::class_body_declaration (cognitive 22) crates/ty_python_semantic/src/types/class.rs
  • Cognitive Complexity · SolutionWalker::binary_lower_bound_visits (cognitive 22) crates/ty_python_semantic/src/types/constraints/solutions.rs
  • Cognitive Complexity · TypeInferenceBuilder::check_union_operator (cognitive 22) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs
  • Cognitive Complexity · Type::map_type (cognitive 20) crates/ty_python_semantic/src/types.rs
  • Cognitive Complexity · ty_module_resolver::resolve::is_pkgutil_extend_path (cognitive 19) crates/ty_module_resolver/src/resolve.rs
  • Cognitive Complexity · FieldMetadata::collect_from_annotation (cognitive 19) crates/ty_python_semantic/src/types/dedicated/pydantic.rs
  • Cognitive Complexity · OverrideOptions::lint (cognitive 18) crates/ty_project/src/metadata/options.rs
  • Cognitive Complexity · TypeInferenceBuilder::infer_enum_spec (cognitive 18) crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
  • Cognitive Complexity · UnionTypeInstance::value_expression_types (cognitive 18) crates/ty_python_semantic/src/types/union_type_instance.rs
  • Cognitive Complexity · UnionTypeInstance::recursive_type_normalized_impl (cognitive 18) crates/ty_python_semantic/src/types/union_type_instance.rs
  • Cognitive Complexity · ruff_linter::toml::rule_selectors::check_selectors (cognitive 17) crates/ruff_linter/src/toml/rule_selectors.rs
  • Cognitive Complexity · ComparablePattern::eq (cognitive 17) crates/ruff_python_ast/src/comparable.rs
  • Cognitive Complexity · PlaceLoadResolutionProcedure::decide_resolution_path (cognitive 17) crates/ty_python_semantic/src/place_load.rs
  • Cognitive Complexity · Type::class_member_with_policy_inner (cognitive 17) crates/ty_python_semantic/src/types.rs
  • Cognitive Complexity · ty_python_semantic::types::equality::compare_literal_to_other (cognitive 17) crates/ty_python_semantic/src/types/equality.rs
  • Cognitive Complexity · TypeInferenceBuilder::infer_subscript_expression_types (cognitive 16) crates/ty_python_semantic/src/types/infer/builder/subscript.rs
  • Cognitive Complexity · PatternSuccessAnalyzer::analyze_pattern_subject_arms (cognitive 16) crates/ty_python_semantic/src/types/narrow.rs
  • Cognitive Complexity · ty_python_semantic::types::attribute_write::instance_attribute_write_requirement (cognitive 16) crates/ty_python_semantic/src/types/attribute_write.rs
  • God Classes · MethodTooLong: StaticClassLiteral.own_generated_member crates/ty_python_semantic/src/types/class/static_literal.rs
  • God Classes · FunctionTooLong: ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name crates/ruff_linter/src/checkers/ast/analyze/expression.rs
  • God Classes · MethodTooLong: Type.map_type crates/ty_python_semantic/src/types.rs
  • God Classes · MethodTooLong: Mro.ancestors_of_static_class crates/ty_python_semantic/src/types/mro.rs
  • God Classes · FunctionTooLong: ty_python_semantic::types::diagnostic::report_incompatible_method_override crates/ty_python_semantic/src/types/diagnostic.rs
  • God Classes · MethodTooLong: CallInference.infer_legacy crates/ty_python_semantic/src/types/call/bind.rs
  • God Classes · MethodTooLong: UnionBuilder.push_type crates/ty_python_semantic/src/types/set_theoretic/builder.rs
  • God Classes · MethodTooLong: TypeInferenceBuilder.infer_enum_call_expression crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
  • God Classes · FileTooLong: builder/enum_call.rs crates/ty_python_semantic/src/types/infer/builder/enum_call.rs
  • God Classes · ClassTooLong: UnionType crates/ty_python_semantic/src/types/set_theoretic.rs
  • God Classes · MethodTooLong: TypeRelationChecker.check_target_union crates/ty_python_semantic/src/types/relation.rs
  • God Classes · MethodTooLong: StaticClassLiteral.own_class_member crates/ty_python_semantic/src/types/class/static_literal.rs
  • God Classes · MethodTooLong: TypeInferenceBuilder.infer_subscript_expression_types crates/ty_python_semantic/src/types/infer/builder/subscript.rs
  • God Classes · MethodTooLong: SolutionWalker.pending_candidate_solution crates/ty_python_semantic/src/types/constraints/solutions.rs
  • God Classes · FileTooLong: types/recursive.rs crates/ty_python_semantic/src/types/recursive.rs
  • God Classes · MethodTooLong: Binding.argument_type_context crates/ty_python_semantic/src/types/call/bind.rs
  • God Classes · FileTooLong: types/mro.rs crates/ty_python_semantic/src/types/mro.rs
  • God Classes · FileTooLong: src/suppression.rs crates/ty_python_semantic/src/suppression.rs
  • God Classes · FileTooLong: src/will_rename.rs crates/ty_ide/src/will_rename.rs
  • God Classes · MethodTooLong: TypeInferenceBuilder.infer_paramspec_explicit_specialization_value crates/ty_python_semantic/src/types/infer/builder/subscript.rs
  • God Classes · FunctionTooLong: ty::run_check crates/ty/src/lib.rs
  • God Classes · ClassTooLong: CandidateSolutions crates/ty_python_semantic/src/types/constraints.rs
  • God Classes · MethodTooLong: ConstructorBinding.instance_return_specialization crates/ty_python_semantic/src/types/call/bind/constructor.rs
  • God Classes · ClassTooLong: ContextCursor crates/ty_ide/src/completion.rs
  • God Classes · FileTooLong: src/inlay_hints.rs crates/ty_ide/src/inlay_hints.rs
  • Code Duplication · Near-duplicate member pair (68 shared lines) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs
  • Code Duplication · Near-duplicate member pair (58 shared lines) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs
  • Code Duplication · Near-duplicate member pair (58 shared lines) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs
  • Code Duplication · Near-duplicate member pair (57 shared lines) crates/ruff_server/src/server/schedule/thread/pool.rs
  • Code Duplication · Edited copy of a member (21 corresponding lines) crates/ty_python_semantic/src/types/constraints/paths.rs
  • Code Duplication · Members sharing a duplicated core (13 members, 50+ identical tokens) crates/ty_server/src/server/api/requests/completion.rs
  • Code Duplication · Members sharing a duplicated core (9 members, 50+ identical tokens) crates/ty_python_semantic/src/types.rs

We compare every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.

Fixed since the last survey: 341 findings

These 341 critical or serious findings were in the previous survey, on 26 October 2026, and are gone from this one. The first 100 are listed here.

  • Cyclomatic Complexity · StaticClassLiteral::own_synthesized_member (cyclomatic 69) crates/ty_python_semantic/src/types/class/static_literal.rs
  • Cyclomatic Complexity · Mro::of_static_class (cyclomatic 27) crates/ty_python_semantic/src/types/mro.rs
  • Cyclomatic Complexity · ty_python_semantic::types::diagnostic::report_invalid_method_override (cyclomatic 23) crates/ty_python_semantic/src/types/diagnostic.rs
  • Cyclomatic Complexity · PlaceLoadResolution::next (cyclomatic 21) crates/ty_python_semantic/src/place_load.rs
  • Cyclomatic Complexity · CallInference::infer (cyclomatic 21) crates/ty_python_semantic/src/types/call/bind.rs
  • Cyclomatic Complexity · PlaceLoadResolution::resolve_enclosing_scopes (cyclomatic 18) crates/ty_python_semantic/src/place_load.rs
  • Cyclomatic Complexity · ruff_linter::rules::ruff::rules::unnecessary_literal_within_deque_call::unnecessary_literal_within_deque_call (cyclomatic 17) crates/ruff_linter/src/rules/ruff/rules/unnecessary_literal_within_deque_call.rs
  • Cyclomatic Complexity · InlayHintVisitor::visit_expr (cyclomatic 17) crates/ty_ide/src/inlay_hints.rs
  • Cyclomatic Complexity · CallInference::refined_return_type (cyclomatic 17) crates/ty_python_semantic/src/types/call/bind.rs
  • Cyclomatic Complexity · ty_python_semantic::reachability::analyze_single (cyclomatic 17) crates/ty_python_semantic/src/reachability.rs
  • Cyclomatic Complexity · ruff_linter::rules::pep8_naming::helpers::is_django_model_import (cyclomatic 16) crates/ruff_linter/src/rules/pep8_naming/helpers.rs
  • Cyclomatic Complexity · RangedValue::to_override (cyclomatic 16) crates/ty_project/src/metadata/options.rs
  • Cyclomatic Complexity · LegacyNamespacePackageVisitor::check_pkgutil_extend_path (cyclomatic 16) crates/ty_module_resolver/src/resolve.rs
  • Cyclomatic Complexity · TypeInferenceBuilder::infer_typed_dict_constructor (cyclomatic 16) crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs
  • Cognitive Complexity · StaticClassLiteral::own_synthesized_member (cognitive 92) crates/ty_python_semantic/src/types/class/static_literal.rs
  • Cognitive Complexity · Mro::of_static_class (cognitive 57) crates/ty_python_semantic/src/types/mro.rs
  • Cognitive Complexity · PlaceLoadResolution::resolve_enclosing_scopes (cognitive 36) crates/ty_python_semantic/src/place_load.rs
  • Cognitive Complexity · CallInference::infer (cognitive 33) crates/ty_python_semantic/src/types/call/bind.rs
  • Cognitive Complexity · ty_python_semantic::types::diagnostic::report_invalid_method_override (cognitive 31) crates/ty_python_semantic/src/types/diagnostic.rs
  • Cognitive Complexity · TypeInferenceBuilder::report_unresolved_import (cognitive 28) crates/ty_python_semantic/src/types/infer/builder/imports.rs
  • Cognitive Complexity · PlaceLoadResolution::next (cognitive 27) crates/ty_python_semantic/src/place_load.rs
  • Cognitive Complexity · RangedValue::to_override (cognitive 25) crates/ty_project/src/metadata/options.rs
  • Cognitive Complexity · TypeInferenceBuilder::infer_place_load (cognitive 25) crates/ty_python_semantic/src/types/infer/builder.rs
  • Cognitive Complexity · CallInference::refined_return_type (cognitive 24) crates/ty_python_semantic/src/types/call/bind.rs
  • Cognitive Complexity · SemanticModel::reaching_definitions_at (cognitive 21) crates/ty_python_semantic/src/semantic_model.rs
  • Cognitive Complexity · SuppressionsBuilder::add_comment (cognitive 21) crates/ty_python_semantic/src/suppression.rs
  • Cognitive Complexity · LegacyNamespacePackageVisitor::check_pkgutil_extend_path (cognitive 19) crates/ty_module_resolver/src/resolve.rs
  • Cognitive Complexity · SemanticIndexBuilder::update_lazy_snapshots (cognitive 19) crates/ty_python_core/src/builder.rs
  • Cognitive Complexity · ruff_linter::rules::pyflakes::rules::repeated_keys::repeated_keys (cognitive 18) crates/ruff_linter/src/rules/pyflakes/rules/repeated_keys.rs
  • Cognitive Complexity · ruff_dev::generate_ty_rules::generate_markdown (cognitive 17) crates/ruff_dev/src/generate_ty_rules.rs
  • Cognitive Complexity · ruff_linter::rules::ruff::rules::rule_codes_in_selectors::check_selectors (cognitive 17) crates/ruff_linter/src/rules/ruff/rules/rule_codes_in_selectors.rs
  • Cognitive Complexity · PlaceLoadResolution::decide_resolution_path (cognitive 17) crates/ty_python_semantic/src/place_load.rs
  • Cognitive Complexity · CallInference::specialized_return_type (cognitive 17) crates/ty_python_semantic/src/types/call/bind.rs
  • Cognitive Complexity · Parameters::expand_paramspec_variadics (cognitive 17) crates/ty_python_semantic/src/types/signatures.rs
  • Cognitive Complexity · CallInference::solve (cognitive 16) crates/ty_python_semantic/src/types/call/bind.rs
  • Cognitive Complexity · TypeInferenceBuilder::infer_place_load_source (cognitive 16) crates/ty_python_semantic/src/types/infer/builder.rs
  • Cognitive Complexity · TypeRelationChecker::try_unary_overload_aggregate_relation (cognitive 16) crates/ty_python_semantic/src/types/signatures.rs
  • Cognitive Complexity · LspFileWatcher::reconcile (cognitive 16) crates/ty_server/src/session/file_watcher.rs
  • God Classes · MethodTooLong: StaticClassLiteral.own_synthesized_member crates/ty_python_semantic/src/types/class/static_literal.rs
  • God Classes · MethodTooLong: ComparableExpr.from crates/ruff_python_ast/src/comparable.rs
  • God Classes · MethodTooLong: ComparableStmt.from crates/ruff_python_ast/src/comparable.rs
  • God Classes · MethodTooLong: Mro.of_static_class crates/ty_python_semantic/src/types/mro.rs
  • God Classes · MethodTooLong: CallInference.infer crates/ty_python_semantic/src/types/call/bind.rs
  • God Classes · FunctionTooLong: ty_python_semantic::types::diagnostic::report_invalid_method_override crates/ty_python_semantic/src/types/diagnostic.rs
  • God Classes · MethodTooLong: RangedValue.to_override crates/ty_project/src/metadata/options.rs
  • God Classes · MethodTooLong: CandidateSolutions.compute_simple_bound_conjunction crates/ty_python_semantic/src/types/constraints.rs
  • God Classes · ClassTooLong: ConstraintSetStorage crates/ty_python_semantic/src/types/constraints.rs
  • God Classes · MethodTooLong: BoundTypeVarInstance.apply_type_mapping_impl crates/ty_python_semantic/src/types/typevar.rs
  • God Classes · MethodTooLong: PlaceLoadResolution.next crates/ty_python_semantic/src/place_load.rs
  • God Classes · FileTooLong: suspicious_conditions/exemptions.rs crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/exemptions.rs
  • Code Duplication · Near-duplicate member family (4 members, 49 shared lines) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Near-duplicate member pair (57 shared lines) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs
  • Code Duplication · Near-duplicate member pair (52 shared lines) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs
  • Code Duplication · Near-duplicate member pair (38 shared lines) crates/ty_python_semantic/src/types/infer/builder.rs
  • Code Duplication · Edited copy of a member (21 corresponding lines) crates/ty_python_semantic/src/types/constraints/paths.rs
  • Code Duplication · Members sharing a duplicated core (13 members, 50+ identical tokens) crates/ty_server/src/server/api/requests/completion.rs
  • Code Duplication · Members sharing a duplicated core (8 members, 50+ identical tokens) crates/ty_python_semantic/src/types.rs
  • Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) crates/ty_python_semantic/src/types/infer/builder.rs
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ruff_linter/src/linter.rs
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ruff_python_ast/src/nodes.rs
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_core/src/narrowing_constraints.rs
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_core/src/use_def.rs
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_semantic/src/types/call/bind.rs
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_semantic/src/types/infer/builder.rs
  • Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_semantic/src/types/typevar.rs
  • Code Duplication · Duplicated block (55 lines × 3) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Duplicated block (42 lines × 2) crates/ty_python_semantic/src/types/infer/builder/subscript.rs
  • Code Duplication · Duplicated block (33–34 lines × 3) crates/ty_python_semantic/src/types/signatures.rs
  • Code Duplication · Duplicated block (33 lines × 4) crates/ty_python_semantic/src/types/set_theoretic/builder.rs
  • Code Duplication · Duplicated block (26–31 lines × 2) crates/ruff_linter/src/rules/isort/order.rs
  • Code Duplication · Duplicated block (30 lines × 2) crates/ruff_python_formatter/src/other/f_string.rs
  • Code Duplication · Duplicated block (29 lines × 2) crates/ty_python_semantic/src/types/signatures.rs
  • Code Duplication · Duplicated block (27 lines × 2) crates/ty_python_semantic/src/types/signatures.rs
  • Code Duplication · Duplicated block (26 lines × 2) crates/ruff_linter/src/rules/isort/normalize.rs
  • Code Duplication · Duplicated block (25 lines × 4) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Duplicated block (25 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/useless_class_metaclass_type.rs
  • Code Duplication · Duplicated block (25 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs
  • Code Duplication · Duplicated block (24 lines × 4) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Duplicated block (24 lines × 4) crates/ty_python_semantic/src/types/signatures.rs
  • Code Duplication · Duplicated block (24 lines × 2) crates/ruff_dev/src/generate_options.rs
  • Code Duplication · Duplicated block (22 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/expression.rs
  • Code Duplication · Duplicated block (22 lines × 2) crates/ruff_python_semantic/src/model.rs
  • Code Duplication · Duplicated block (22 lines × 2) crates/ruff_server/src/server/schedule/thread/pool.rs
  • Code Duplication · Duplicated block (22 lines × 2) crates/ty_python_semantic/src/types/infer.rs
  • Code Duplication · Duplicated block (22 lines × 2) crates/ty_python_semantic/src/types/infer/builder/function.rs
  • Code Duplication · Duplicated block (21 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs
  • Code Duplication · Duplicated block (21 lines × 2) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Duplicated block (20 lines × 3) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Duplicated block (18–20 lines × 2) crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs
  • Code Duplication · Duplicated block (19 lines × 2) crates/ty_python_semantic/src/types/constraints/paths.rs
  • Code Duplication · Duplicated block (18 lines × 3) crates/ty_python_semantic/src/types/constraints/sequents.rs
  • Code Duplication · Duplicated block (18 lines × 3) crates/ty_python_semantic/src/types/constraints/sequents.rs
  • Code Duplication · Duplicated block (18 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs
  • Code Duplication · Duplicated block (18 lines × 2) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Duplicated block (15–18 lines × 2) crates/ty_python_semantic/src/types/class/static_literal.rs
  • Code Duplication · Duplicated block (18 lines × 2) crates/ty_python_semantic/src/types/iteration.rs
  • Code Duplication · Duplicated block (17 lines × 2) crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs
  • Code Duplication · Duplicated block (17 lines × 2) crates/ty_python_semantic/src/types/class/known.rs
  • Code Duplication · Duplicated block (15–16 lines × 3) crates/ty_python_semantic/src/types/infer/builder.rs
  • Code Duplication · Duplicated block (16 lines × 2) crates/ruff_annotate_snippets/src/renderer/mod.rs
Rebuild cost: about €960,000 · Estimate
Cost to rebuild€320,000 to €1,600,000, for 5,296 to 16,800 hours of work, about 6.6 person-years for 3 to 13 engineers
Difficulty of the problemStandard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.8 at a score of 61. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
SizeVery large: 728,120 lines of product code
What it is notNot a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.

How the estimate is made: We price the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.

Top priorities

The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.

1
Interpolated log message defeats structured logging
Raises the score by about 6 points · Medium effort · Structured logging
2
Make custom controls keyboard-operable (role + tabindex + key handler), drop positive tabindex, and give anchors a real href.
Raises the score by about 5 points · Medium effort · Keyboard semantics
3
Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
Raises the score by about 4 points · Medium effort · Cancellation propagation

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Files that change often carry extra risk · Combined risk
5 files are changed often and are hard to read, which makes them the likeliest places for a mistake. They also have under half their code tested, or were written almost entirely by one person, so a mistake there is less likely to be caught, or only one person knows the code well enough to avoid it. A change to these files therefore carries more risk than the overall score suggests.
Based on: Churn × Complexity Hotspots (79 files) · Code Coverage (88 files under half tested) · Bus Factor (0 files written almost entirely by one person) · The files: mod.rs, lib.rs and pydantic.rs
What to do: Add tests to these files and have a second person review every change to them, starting with mod.rs, lib.rs and pydantic.rs.
Where the investment is most exposed · Value at risk
This code would cost about €960,000 to build again, about 6.6 person-years of work. Its weakest lens is Code Health, at 51 (Adequate). Code Health is about how easy the code is to read and change safely, and code that is hard to read is slow and risky to change, so every future change costs more than it should. Because the weakest lens counts most in the score, work on Code Health also moves the score most.
Based on: the rebuild estimate · the Code Health grade · how much each lens counts
What to do: Start with the Code Health actions in Top priorities.
If you do one thing first · First action
Interpolated log message defeats structured logging. Of all the actions in this report, it raises the score most for the work it takes: about 6 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.1 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 5% to 11% on every change. The history of the code shows how much it changes: about 432,338 lines over the last 90 days, which is about 1,753,371 lines a year. At that pace, the extra work comes to an estimated 206.2 to 1237.5 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of our own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.

Architecture — module dependency graph

Project dependencies, layered top-to-bottom; arrows show direction. Any dashed red edge points upward or sideways, which only happens where the projects form a dependency cycle. A graph without cycles has none.

arch ruff ruff ruff_db ruff_db ruff->ruff_db ruff_diagnostics ruff_diagnostics ruff->ruff_diagnostics ruff_linter ruff_linter ruff->ruff_linter ruff_macros ruff_macros ruff->ruff_macros ruff_python_ast ruff_python_ast ruff->ruff_python_ast ruff_python_formatter ruff_python_formatter ruff->ruff_python_formatter ruff_python_parser ruff_python_parser ruff->ruff_python_parser ruff_ranged_value ruff_ranged_value ruff->ruff_ranged_value ruff_server ruff_server ruff->ruff_server ruff_source_file ruff_source_file ruff->ruff_source_file ruff_text_size ruff_text_size ruff->ruff_text_size ruff_workspace ruff_workspace ruff->ruff_workspace ruff_db->ruff_diagnostics ruff_db->ruff_python_ast ruff_db->ruff_python_parser ruff_python_trivia ruff_python_trivia ruff_db->ruff_python_trivia ruff_db->ruff_source_file ruff_db->ruff_text_size ruff_dev ruff_dev ruff_dev->ruff ruff_dev->ruff_db ruff_dev->ruff_linter ruff_dev->ruff_python_ast ruff_dev->ruff_python_formatter ruff_dev->ruff_python_parser ruff_dev->ruff_python_trivia ruff_dev->ruff_workspace ty_project ty_project ruff_dev->ty_project ty_python_semantic ty_python_semantic ruff_dev->ty_python_semantic ruff_diagnostics->ruff_text_size ruff_linter->ruff_db ruff_linter->ruff_diagnostics ruff_linter->ruff_macros ruff_linter->ruff_python_ast ruff_linter->ruff_python_parser ruff_linter->ruff_python_trivia ruff_linter->ruff_ranged_value ruff_linter->ruff_source_file ruff_linter->ruff_text_size ruff_macros->ruff_python_trivia ruff_python_ast->ruff_macros ruff_python_ast->ruff_python_trivia ruff_python_ast->ruff_source_file ruff_python_ast->ruff_text_size ruff_python_formatter->ruff_db ruff_python_formatter->ruff_macros ruff_python_formatter->ruff_python_ast ruff_python_formatter->ruff_python_parser ruff_python_formatter->ruff_python_trivia ruff_python_formatter->ruff_source_file ruff_python_formatter->ruff_text_size ruff_python_parser->ruff_python_ast ruff_python_parser->ruff_python_trivia ruff_python_parser->ruff_text_size ruff_python_trivia->ruff_source_file ruff_python_trivia->ruff_text_size ruff_ranged_value->ruff_db ruff_ranged_value->ruff_python_ast ruff_ranged_value->ruff_text_size ruff_server->ruff_db ruff_server->ruff_diagnostics ruff_server->ruff_linter ruff_server->ruff_python_ast ruff_server->ruff_python_formatter ruff_server->ruff_python_parser ruff_server->ruff_ranged_value ruff_server->ruff_source_file ruff_server->ruff_text_size ruff_server->ruff_workspace ruff_source_file->ruff_text_size ruff_workspace->ruff_db ruff_workspace->ruff_linter ruff_workspace->ruff_macros ruff_workspace->ruff_python_ast ruff_workspace->ruff_python_formatter ruff_workspace->ruff_ranged_value ruff_workspace->ruff_source_file ty_ide ty_ide ty_ide->ruff_db ty_ide->ruff_diagnostics ty_ide->ruff_python_ast ty_ide->ruff_python_trivia ty_ide->ruff_source_file ty_ide->ruff_text_size ty_ide->ty_project ty_python_core ty_python_core ty_ide->ty_python_core ty_ide->ty_python_semantic ty_project->ruff_db ty_project->ruff_macros ty_project->ruff_python_ast ty_project->ruff_python_formatter ty_project->ruff_ranged_value ty_project->ruff_source_file ty_project->ruff_text_size ty_project->ty_python_core ty_project->ty_python_semantic ty_python_core->ruff_db ty_python_core->ruff_macros ty_python_core->ruff_python_ast ty_python_core->ruff_python_parser ty_python_core->ruff_text_size ty_python_semantic->ruff_db ty_python_semantic->ruff_diagnostics ty_python_semantic->ruff_macros ty_python_semantic->ruff_python_ast ty_python_semantic->ruff_python_parser ty_python_semantic->ruff_python_trivia ty_python_semantic->ruff_source_file ty_python_semantic->ruff_text_size ty_python_semantic->ty_python_core ty_server ty_server ty_server->ruff_db ty_server->ruff_diagnostics ty_server->ruff_macros ty_server->ruff_python_ast ty_server->ruff_ranged_value ty_server->ruff_source_file ty_server->ruff_text_size ty_server->ty_ide ty_server->ty_project ty_server->ty_python_core ty_server->ty_python_semantic __more__ +68 more projects

Architecture: which parts of the code depend on which

The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.

1743 modules, with 7379 dependencies between them. 22 loops run through 255 of the modules, marked above the diagonal.

The table shows the 40 modules with the most connections; 1703 more are left out to keep it readable.

Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
uses →1 ruff_db.system.path2 ruff_formatter.formatter3 ruff_python_ast.name4 ruff_python_semantic.scope5 ruff_text_size.size6 ty_server.session.client7 ruff_diagnostics.fix8 ruff_text_size.traits9 ruff_linter.settings.types10 ruff_text_size.range11 ruff_db.files12 ruff_formatter13 ruff_linter.locator14 ruff_python_ast.token.tokens15 ruff_db.diagnostic16 ruff_python_codegen.stylist17 ty_python_core.program18 ruff_linter.violation19 ty_python_core.program_file20 ty_project.db21 ty_python_core.scope22 ty_python_core23 ty_server.session24 ty_python_core.definition25 ty_server.server.api.traits26 ruff_python_ast.nodes27 ty_python_semantic.types.context28 ruff_python_ast.generated29 ty_python_semantic.types.typevar30 ruff_python_ast.visitor31 ruff_python_formatter32 ruff_python_semantic.model33 ty_python_semantic.types.generics34 ruff_python_semantic.binding35 ty_python_semantic.types.infer.builder36 ruff_linter.checkers.ast37 ty_python_semantic.types.function38 ty_python_semantic.types.class.static_literal39 ty_python_semantic.types.class40 ty_python_semantic.types
1 ruff_db.system.path
2 ruff_formatter.formatter2
3 ruff_python_ast.name2
4 ruff_python_semantic.scope1
5 ruff_text_size.size1
6 ty_server.session.client2
7 ruff_diagnostics.fix1
8 ruff_text_size.traits21
9 ruff_linter.settings.types1
10 ruff_text_size.range111
11 ruff_db.files4111
12 ruff_formatter913
13 ruff_linter.locator11
14 ruff_python_ast.token.tokens11
15 ruff_db.diagnostic2422
16 ruff_python_codegen.stylist1
17 ty_python_core.program211
18 ruff_linter.violation11
19 ty_python_core.program_file11
20 ty_project.db223122
21 ty_python_core.scope11211
22 ty_python_core111123
23 ty_server.session4434
24 ty_python_core.definition14211311356
25 ty_server.server.api.traits516
26 ruff_python_ast.nodes122729240
27 ty_python_semantic.types.context2191221
28 ruff_python_ast.generated118787693
29 ty_python_semantic.types.typevar31134321
30 ruff_python_ast.visitor4412
31 ruff_python_formatter111
32 ruff_python_semantic.model15112168
33 ty_python_semantic.types.generics113231411518
34 ruff_python_semantic.binding511132
35 ty_python_semantic.types.infer.builder11111213410158633211313
36 ruff_linter.checkers.ast12312213279123
37 ty_python_semantic.types.function3322145413126
38 ty_python_semantic.types.class.static_literal11111123412268
39 ty_python_semantic.types.class22121147362415
40 ty_python_semantic.types21334244193103619
Uses a module listed above itPart of a loopThe module itself
1 ruff_db.system.path2 ruff_formatter.formatter3 ruff_python_ast.name4 ruff_python_semantic.scope5 ruff_text_size.size6 ty_server.session.client7 ruff_diagnostics.fix8 ruff_text_size.traits9 ruff_linter.settings.types10 ruff_text_size.range11 ruff_db.files12 ruff_formatter13 ruff_linter.locator14 ruff_python_ast.token.tokens15 ruff_db.diagnostic16 ruff_python_codegen.stylist17 ty_python_core.program18 ruff_linter.violation19 ty_python_core.program_file20 ty_project.db21 ty_python_core.scope22 ty_python_core23 ty_server.session24 ty_python_core.definition25 ty_server.server.api.traits26 ruff_python_ast.nodes27 ty_python_semantic.types.context28 ruff_python_ast.generated29 ty_python_semantic.types.typevar30 ruff_python_ast.visitor31 ruff_python_formatter32 ruff_python_semantic.model33 ty_python_semantic.types.generics34 ruff_python_semantic.binding35 ty_python_semantic.types.infer.builder36 ruff_linter.checkers.ast37 ty_python_semantic.types.function38 ty_python_semantic.types.class.static_literal39 ty_python_semantic.types.class40 ty_python_semantic.typesruff_db.system.path1ruff_formatter.formatter2ruff_python_ast.name3ruff_python_semantic.scope4ruff_text_size.size5ty_server.session.client6ruff_diagnostics.fix7ruff_text_size.traits8ruff_linter.settings.types9ruff_text_size.range10ruff_db.files11ruff_formatter12ruff_linter.locator13ruff_python_ast.token.tokens14ruff_db.diagnostic15ruff_python_codegen.stylist16ty_python_core.program17ruff_linter.violation18ty_python_core.program_file19ty_project.db20ty_python_core.scope21ty_python_core22ty_server.session23ty_python_core.definition24ty_server.server.api.traits25ruff_python_ast.nodes26ty_python_semantic.types.context27ruff_python_ast.generated28ty_python_semantic.types.typevar29ruff_python_ast.visitor30ruff_python_formatter31ruff_python_semantic.model32ty_python_semantic.types.generics33ruff_python_semantic.binding34ty_python_semantic.types.infer.builder35ruff_linter.checkers.ast36ty_python_semantic.types.function37ty_python_semantic.types.class.static_literal38ty_python_semantic.types.class39ty_python_semantic.types40221121211111411191311112422121111112231221121111112344341421131135651612272924021912211187876933113432144121111511216811323141151851113211111213410158633211313123122132791233322145413126111111234122682212114736241521334244193103619+1703 more modules (most-connected shown)

At a glance — Code Health · 51% · Adequate · gated by D2, X4 ·

At a glance — Architecture · 97% · Exemplary ·

At a glance — Maturity · 78% · Strong ·

At a glance — Readiness · 80% · Strong ·

At a glance — Security · 74% · Adequate · gated by D29 ·

At a glance — Event Sourcing · 100% · Exemplary ·

At a glance — Accessibility · 59% · Adequate · gated by AC4 ·

At a glance — Performance · 94% · Exemplary ·

Security & Compliance — OWASP Top-10 mapping

Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).

OWASP categoryFindingsSeverity
A05:2025 — Injection71High / Critical
A03:2025 — Software Supply Chain Failures13High / Critical
A02:2025 — Security Misconfiguration4High / Critical

Roadmap

Top priorities: Interpolated log message defeats structured logging; Make custom controls keyboard-operable (role + tabindex + key handler), drop positive tabindex, and give anchors a real href; Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Interpolated log message defeats structured logging+5.6 ptsMediumStructured logging
Make custom controls keyboard-operable (role + tabindex + key handler), drop positive tabindex, and give anchors a real href.+4.6 ptsMediumKeyboard semantics
Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.+4.1 ptsMediumCancellation propagation
Give every control a programmatic label (a <label for> / wrapping <label> / aria-label) and every button text — a placeholder is not a label.+2.8 ptsMediumForms & labels
Resolve the 1 No ADRs found finding(s) in ADR Quality — start with REDACTED.+0.9 ptsLowADR Quality
The findings name the configuration each number was taken from and, for the assertions, the files that hold them. Turn null checking on where it is off — `"strict": true` in the base tsconfig that the others extend switches `strictNullChecks` on with the rest of the family — and then resolve the assertions rather than adding to them. A `!` on a value the checker could show to be null is a promise the author cannot check from where they are standing, and each one is a `TypeError: Cannot read properties of null` waiting for the path that makes it true; where the value genuinely cannot be null, say something the checker can see instead (narrow it with a test, make the property required, drop the `?`).+1.6 ptsMediumNullable reference types
Bring the 7 bodies over 240 down to 240 or less in Cognitive Complexity — start with Bindings::evaluate_known_cases (cognitive 741), ruff_linter::checkers::ast::analyze::statement::statement (cognitive 710), ruff_linter::checkers::ast::analyze::expression::expression (cognitive 653).+1.1 ptsHighCognitive Complexity
Resolve the 13 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (12), REDACTED.+0.9 ptsMediumStatic Analysis (SAST)

File quality

Per-file score 0–10 — a quality signature. Of 864 files carrying findings, judged against the Preview bar: 0% slop · 21% mixed · 79% near-clean.

FileScoreBandWorst signal
REDACTED2.3SlopStatic Analysis (SAST): High: REDACTED
REDACTED2.7SlopIaC & Container Security: High IaC: REDACTED
REDACTED3.7MixedStatic Analysis (SAST): High: REDACTED
REDACTED4.4MixedStatic Analysis (SAST): High: REDACTED
crates/ruff_graph/src/db.rs4.7MixedChange Coupling: Boundary-crossing change coupling: db.rs ↔ ty_check_invalid_syntax.rs
crates/ty_python_semantic/src/types/set_theoretic.rs4.8MixedGod Classes: FileTooLong: types/set_theoretic.rs
REDACTED4.8MixedStatic Analysis (SAST): High: REDACTED
REDACTED5.1MixedStatic Analysis (SAST): High: REDACTED
crates/ruff_linter/src/checkers/ast/analyze/expression.rs5.5MixedCyclomatic Complexity: ruff_linter::checkers::ast::analyze::expression::expression (cyclomatic 431)
crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs5.5MixedCyclomatic Complexity: ruff_linter::rules::airflow::rules::removal_in_3::check_name (cyclomatic 73)
crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs5.5MixedCyclomatic Complexity: ruff_linter::rules::airflow::rules::moved_to_provider_in_3::check_names_moved_to_provider (cyclomatic 112)
crates/ty_python_semantic/src/types/dedicated/pydantic.rs5.5MixedCyclomatic Complexity: ty_python_semantic::types::dedicated::pydantic::lax_input_type_impl (cyclomatic 43)
crates/ty_python_semantic/src/types/class/dynamic_literal.rs5.6MixedCognitive Complexity: DynamicClassLiteral::try_metaclass (cognitive 16)
crates/ruff_server/src/session/client.rs5.6MixedCode Duplication: Edited copy of a member (22 corresponding lines)
crates/ty_python_semantic/src/dunder_all.rs5.7MixedCyclomatic Complexity: DunderAllNamesCollector::visit_stmt (cyclomatic 38)
crates/ty_python_core/src/re_exports.rs5.7MixedCyclomatic Complexity: ExportFinder::visit_stmt (cyclomatic 18)
crates/mdtest/src/lib.rs5.7MixedCognitive Complexity: mdtest::run (cognitive 31)
crates/ruff_dev/src/generate_options.rs5.7MixedCode Duplication: Edited copy of a member (51 corresponding lines)
REDACTED5.8MixedStatic Analysis (SAST): High: REDACTED
crates/ruff_dev/src/generate_rules_table.rs5.9MixedCyclomatic Complexity: ruff_dev::generate_rules_table::generate_table (cyclomatic 16)

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 79

A definite problem that already costs you something and drags the score down: a missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here tends to cause failures elsewhere.

Serious — 3815

Likely wrong, but not failing yet. It degrades the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to carry for two years either.

Minor — 221

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 17

Something this survey could not settle from the outside, and which could be critical or serious. Either a control was required and no positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean result. These are excluded from the score rather than awarded a pass, so the number on the cover neither rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each one is named under Limitations.

Methodology & how to trust this report

This survey is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. All 58 evaluated dimensions are computed by tools and static analysis; no language model sets or judges any of them. Overall confidence is 0.9, the weighted average across measured dimensions.

Every figure here is one of two kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10.

What we checked — 58 dimensions across the health lenses
D1D2D3D4D5D6D8D12D13D14D15D16D17D19D20D24D26D28D29D30D31D34D35D36D43D44AC2AC3AC4AC5AC6AX10AX3AX4AX8AX9ES1ES2M1M2M3P1P10P2P3P4P6PF1PF3S1X1X2X21X27X29X30X4X5

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 4060 of 4115 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Canine Code Analyzer duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivySecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3✓ deterministic

Every finding is locatable in findings.md. Run 01a1d8a5-8089-770e-82c3-1456acfe3ce2.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D11 Test Reliability — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Test source is present (.py, .rs) and this repository declares a Cargo test suite (repository root, 466 test files), but it was not re-run: its build outgrew the 12 GB scratch ceiling (12.25 GB measured) and was stopped; its suite was not run. Not scored — this is a gap in the analyzer's language coverage, not a finding about this repository.
  • D14 License Compliance — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This repository declares a Python REDACTED/requirements.txt (pip/uv/Poetry), but the licence verdict published here was taken over its crate dependencies. Nothing was read about its Python dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
  • D14 License Compliance — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. This repository declares package.json, but the licence verdict published here was taken over its crate dependencies. Nothing was read about its npm dependencies' licensing in either direction, and a clean score on this card must not be read as covering them.
  • D15 Churn × Complexity Hotspots — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. A hotspot's complexity is meant to be the worst body its churn actually touched. For crates/ruff_python_ast/src/comparable.rs that could not be established — the complexity reader for the file reports no body extents, or the history carries no per-line attribution — so the row quotes the file's worst body, which the counted changes may never have touched. The churn count is unaffected.
  • D19 Documentation Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
  • D21 Naming Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's naming rules read C# through Roslyn and every other language through its sidecar model; these languages are left out (PHP's reading is its own change, a Roslyn-loaded VB or F# project has no population builder yet). Their declarations carry no naming verdict this run — this says nothing about whether their names are consistent.
  • D21 Naming Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
  • D21 Naming Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these names are consistent.
  • D22 Internal API Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
  • D24 Comment Value — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each source language's comment syntax, and the code a comment annotates in it, needs its own proof before D24 judges it. Until then those comments are left unread, not counted as clean.
  • D27 Navigability — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Navigability is taken over call sites whose callee resolved. For C# that population includes calls into referenced assemblies; for this language only calls declared inside the repository count, so the abstention threshold reads the repository's use of its standard library as a resolution failure. That is a limit of this analyzer, not a build problem in this repository.
  • D31 IaC & Container Security — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Checkov ran but its report could not be read (checkov produced no output — not a clean result). Every misconfiguration only checkov reports — most of its Terraform, CloudFormation, Bicep and Ansible policies — is absent from this card, so its absence here is not evidence those resources are configured correctly.
  • D32 Data Compliance (PII/GDPR) — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `crates/ruff_benchmark/resources/typeis_narrowing.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_invalid_annotation.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_invalid_target.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_invalid_value.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_missing_rhs.py`, … (+359 more) produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
  • AX6 Interface segregation — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • AXB2 Runtime readiness — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. (rule: no-root-manifest). The renderer reported: the dev server (`npm run start`) exited before it served a page. Likely cause (our sandbox): `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. Last output: "npm error code ENOENT / npm error syscall open / npm error path <repo>/package.json / npm error errno -2 / npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '<repo>/package.json' / npm error enoent This is related to npm not being able to find a file. / npm error enoent / npm error A complete log of this run can be found in: <path>" No runtime evidence was gathered.
  • AXR1 Runtime accessibility — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via DevServer (start). the dev server (`npm run start`) exited before it served a page. Likely cause (our sandbox): `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. Last output: "npm error code ENOENT / npm error syscall open / npm error path <repo>/package.json / npm error errno -2 / npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '<repo>/package.json' / npm error enoent This is related to npm not being able to find a file. / npm error enoent / npm error A complete log of this run can be found in: <path>" No runtime evidence was gathered.
  • GD1 Unfinished & placeholder code — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and this repository's Python, Rust is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • IC1 Incompleteness & stubs — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and this repository's Python, Rust is most of its product and is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • P5 DR & Backup — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. No backup/snapshot/replication config, RTO/RPO or restore-procedure documentation was found — and no production persistence was detected either (no data-access packages, no data-store services, no database resources), so there is nothing in this repository whose loss a DR control would recover. If this system's data lives in a platform or ops repo we can't see, that's where the DR evidence belongs.
  • X10 Duplicated predicate — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. 2 further occurrence(s) are not listed individually; the score already reflects all 42.
  • X12 Unreachable branch — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X13 Undrained process stream — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X16 Unfloored truncation loop — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X17 Uncapped recursion over a caller-supplied document — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Uncapped recursion over a caller-supplied document could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository. Engine failure: IndexOutOfRangeException: Index was outside the bounds of the array.
  • X18 Disposal-pattern correctness — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X23 Unguarded diagnostic materialisation — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X24 Document value interpolated into markup unescaped — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check's reader does not cover most of the languages this repository's product is written in. What it read is kept, but it is too small a share to grade the product by. That is a gap in this analyzer's language reach — not a finding about this repository.
  • X3 Exception handling — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Exception handling could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository. Engine failure: ArgumentOutOfRangeException: length ('-25') must be a non-negative value. (Parameter 'length') Actual value was -25.
  • X4 Structured logging — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 332 further occurrence(s) are not listed individually; the score already reflects all 372.

Repo exclusion declarations: 25 pattern(s) declared (.gitattributes linguist-generated/vendored, .editorconfig generated_code) excluded 0 source file(s) from code-quality scoring. Declarations are the repo's own visible statement that a tree is machine-written or vendored — auditable in any diff, honored by GitHub the same way.

Limitations & what we did not check

We assess the repository exactly as committed, and only the repository. By design we do not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
  • D5 Coupling: Coupling is measured between projects/assemblies — runtime coupling through DI, reflection, messaging or shared databases is invisible to a static reference graph.
  • D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
  • D8 Code Coverage: Coverage is measured by building and running the test suite inside our isolated image — the target repo is never modified, and nothing on your systems runs. So coverage exists only when the suite builds and runs within the inline time budget; one that needs external services, can't build, or exceeds the budget yields no coverage (D8 then degrades to not-measured, not a low score). Line coverage also says nothing about assertion quality.
  • D12 Dependency Hygiene: Dependency health reads manifests and lockfiles — a vulnerability in a vendored/copied dependency, or risk from how a dependency is actually used, is outside this view.
  • D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
  • D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
  • D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
  • D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
  • D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
  • D20 ADR Quality: ADR quality checks the structure of the decision records present: it cannot know about decisions made and never recorded, and it does not judge how well a record argues its case. Records in a language the section lexicon does not cover are not evaluated.
  • D24 Comment Value: Comment value is measured as redundancy only: a comment that repeats its code's words is found, but a paraphrase in other words, a vague comment, or one the code contradicts is not, and whether a comment is valuable is not claimed. Comments in other scripts or languages, and outside C#, are not judged.
  • D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
  • D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
  • D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a REDACTED (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
  • AC2 Forms & labels: Label association is read from static markup — a label wired up at runtime (JS-set aria-labelledby, framework-injected ids) reads as missing, a present label says nothing about whether its text is correct. A known UI-library field component (e.g. a JSX <TextField>) is now checked conservatively — flagged only when it carries NO label/aria-label/aria-labelledby/id/name — but wrapper/context-labelled libraries (Chakra/Radix FormControl+FormLabel) aren't statically visible (possible false positive) and non-JSX lowercased components are still skipped. A click handler on a plain element is now asked for a name too (it is a control the author declared), but the subtree test that answers it is deliberately generous: any DYNAMIC text expression in the subtree counts as a name, so an icon chosen by a ternary ({cond ? <IconA/> : <IconB/>}) reads as named, and a glyph component from a library the icon-import list does not know still names its parent. A clean result is "no unlabelled control found", not a labelling proof.
  • AC3 Page structure: Page structure is read from the static markup tree — landmarks, headings and lang injected at runtime aren't seen, heading ORDER is checked structurally (not against the rendered visual hierarchy), and lang/title/main fire only on full documents, never partials, and the data-table check sees header-cell presence (a <th> exists), not whether each header correctly associates with its cells. Static readiness, not conformance.
  • AC4 Keyboard semantics: Keyboard semantics are inferred from markup attributes — interactivity wired purely in script, focus managed at runtime, and component-level handlers are invisible. A clean result means "no static keyboard-trap shape", not a keyboard-operability proof.
  • AC5 ARIA correctness: ARIA correctness is checked against the static role/attribute shape — roles/attributes set dynamically aren't seen, a valid role says nothing about whether it matches the element's real behaviour, and required-state checks are suppressed when a JSX spread could supply them. The two-branch toggle check (a control whose state is conveyed only by which of two mutually exclusive branches renders) reads CONDITIONALS THAT ARE ATTRIBUTES — Vue v-if/v-else/v-show and Alpine x-if/x-show — so the same toggle written as a Svelte {#if} block or a JSX ternary is control flow the markup model never projects as a branch and is not seen at all.
  • AC6 Visual & motion safety: Contrast and motion safety are PARTIAL by construction — literal colours (hex/rgb/hsl/named) in inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS top-level declarations are read (same-rule/same-element colour+background pairs only); computed/runtime/theme colour, external-CDN stylesheets, CSS-in-JS dynamic (${…}) and nested-selector colours, cross-element pairs and image contrast stay out of reach, so a clean result is bounded by what the static CSS itself shows.
  • AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
  • AX9 CQS / query purity: Handlers are found by interface/name convention — a query handler using neither is not seen. Mutation is a resolved write/publish invocation (SaveChanges/repository/bus), so a write hidden behind a hand-rolled wrapper, reflection, or a string-keyed service locator resolves to a non-persistence type and isn't flagged; it detects that a query writes state, not whether the write is a legitimate read-side cache update. Clean means "no resolved write/publish in a query body", not a proof of CQS purity.
  • P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
  • P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.

Dimensions

D1 · Cyclomatic Complexity4.5 / 10Weak✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

Maturity: Documented → Verified → Prevented · effective 4.5 / 10 · rule-coverage 100% · ceiling Prevented

469 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was ruff_linter::checkers::ast::analyze::expression::expression at 431. A further 89 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being ruff_linter::codes::code_to_rule at 992 — they are counted neither in the figure above nor in this dimension's score. 34 files carry no cyclomatic complexity row at all for this reason — every one of their over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: crates/ruff_linter/src/codes.rs (ruff_linter::codes::code_to_rule at 992), crates/ruff_python_ast/src/token.rs (TokenKind::fmt at 107), crates/ty_module_resolver/src/module.rs (KnownModule::as_str at 47), crates/ruff_python_parser/src/error.rs (ParseErrorType::fmt at 42), crates/ruff_linter/src/docstrings/sections.rs (SectionKind::from_str at 38), and 29 more not listed here. They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.

ruff_linter::checkers::ast::analyze::expression::expression (cyclomatic 431) · ×102crates/ruff_linter/src/checkers/ast/analyze/expression.rs:25
TypeInferenceBuilder::infer_parameterized_special_form_type_expression (cyclomatic 109) · ×49crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2564
ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions (cyclomatic 168) · ×46crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:144
Type::member_lookup_with_policy_and_receiver::member_lookup_with_policy_impl (cyclomatic 118) · ×18crates/ty_python_semantic/src/types.rs:6090
TypeRelationChecker::check_signature_pair_inner (cyclomatic 236) · ×9crates/ty_python_semantic/src/types/signatures.rs:3100

+ 160 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 3 bodies over 240 down to 240 or less in Cyclomatic Complexity — start with ruff_linter::checkers::ast::analyze::expression::expression (cyclomatic 431), ruff_linter::checkers::ast::analyze::statement::statement (cyclomatic 416), Bindings::evaluate_known_cases (cyclomatic 254). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 3 together lifts Cyclomatic Complexity from 4.5 to about 5.1/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.

Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.

D2 · Cognitive Complexity2.0 / 10Critical✓ Tool-verified

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

Maturity: Documented → Verified → Prevented · effective 2.0 / 10 · rule-coverage 100% · ceiling Prevented

836 method(s) exceeded the cognitive complexity threshold of 15; the worst was Bindings::evaluate_known_cases at 741.

ruff_linter::checkers::ast::analyze::statement::statement (cognitive 710) · ×229crates/ruff_linter/src/checkers/ast/analyze/statement.rs:19
ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions (cognitive 366) · ×79crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:144
TypeInferenceBuilder::infer_parameterized_special_form_type_expression (cognitive 225) · ×79crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2564
Type::member_lookup_with_policy_and_receiver::member_lookup_with_policy_impl (cognitive 67) · ×21crates/ty_python_semantic/src/types.rs:6090
Parser::parse_impl (cognitive 84) · ×16crates/mdtest/src/parser.rs:591

+ 234 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 7 bodies over 240 down to 240 or less in Cognitive Complexity — start with Bindings::evaluate_known_cases (cognitive 741), ruff_linter::checkers::ast::analyze::statement::statement (cognitive 710), ruff_linter::checkers::ast::analyze::expression::expression (cognitive 653). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 7 together lifts Cognitive Complexity from 2.0 to about 3.0/10, projected with the scoring formula itself and assuming each lands exactly at 240; a cleaner split scores higher.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes8.5 / 10Strong✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.5 / 10 · rule-coverage 100% · ceiling Prevented

531 god class(es) detected.

MethodTooLong: TypeRelationChecker.check_signature_pair_inner · ×194crates/ty_python_semantic/src/types/signatures.rs:3100
FileTooLong: infer/builder.rs · ×144crates/ty_python_semantic/src/types/infer/builder.rs
FunctionTooLong: ruff_linter::checkers::ast::analyze::statement::statement · ×95crates/ruff_linter/src/checkers/ast/analyze/statement.rs:19
ClassTooLong: TypeInferenceBuilder · ×54crates/ty_python_semantic/src/types/infer/builder.rs:306
TooManyMethods: TypeInferenceBuilder · ×35crates/ty_python_semantic/src/types/infer/builder.rs:306

+ 2 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 194 MethodTooLong finding(s) in God Classes — start with builder.rs (23), types.rs (16), known.rs (12). — One of this dimension's main actionable groups (194 warning-level).
  2. Resolve the 144 FileTooLong finding(s) in God Classes — start with mod.rs (7), lib.rs (5), builder.rs (3). — One of this dimension's main actionable groups (144 warning-level).
  3. Resolve the 95 FunctionTooLong finding(s) in God Classes — start with lib.rs (4), visitor.rs (4), diagnostic.rs (4). — One of this dimension's main actionable groups (95 warning-level).

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication8.2 / 10Strong✓ Tool-verified

What it measures: How much of the production code is copy-pasted: the share of production lines inside a reported copy (every copy of a duplicated block or of an edited member, each line once), 10 at none and 0 at a quarter of the lines.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), scored on the share of production lines inside a reported copy (each line once; 10 at none, 0 at a quarter). Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.2 / 10 · rule-coverage 100% · ceiling Verified

733 duplicated block group(s) detected. 4.4 % of the production lines (32,290 of 728,120) are in a reported copy. A further 414 rows report members as variants of one another; the share counts each copied line once, however many rows cite it. 1 of the 1147 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.

Duplicated block (10 lines × 2) · ×46crates/ruff_annotate_snippets/src/renderer/render.rs:1416
Duplicated block (9 lines × 2) · ×45crates/ruff_linter/src/rules/airflow/helpers.rs:315
Duplicated block (8 lines × 2) · ×36crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:78
Duplicated block (11 lines × 2) · ×34crates/ruff/src/args.rs:1031
Duplicated block (6 lines × 2) · ×34crates/ruff_dev/src/generate_options.rs:28

+ 267 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 46 Duplicated block (10 lines × 2) finding(s) in Code Duplication — start with visitor.rs (3), server.rs (3), render.rs (2). — One of this dimension's main actionable groups (46 warning-level).
  2. Resolve the 45 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with builder.rs (3), helpers.rs (2), sequents.rs (2). — One of this dimension's main actionable groups (45 warning-level).
  3. Resolve the 36 Duplicated block (8 lines × 2) finding(s) in Code Duplication — start with sequents.rs (3), use_def.rs (2), typed_dict.rs (2). — One of this dimension's main actionable groups (36 warning-level).

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D5 · Coupling8.6 / 10Strong✓ Tool-verified

What it measures: Whether volatile projects sit underneath others that depend on them (so their churn ripples upward), and whether project dependencies form cycles. A widely-depended-on but stable shared/kernel project is healthy, not penalised.

Method: Dependency cycles via elementary-DFS over real .csproj references, plus Martin instability (afferent/efferent) per project. Exhaustive over the reference graph, deterministic.

Coverage: Exhaustive · type-level: afferent/efferent coupling + cycles computed over every production type — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 8.6 / 10 · rule-coverage 100% · ceiling Prevented

88 production modules (Cargo+npm+Python), 0 dependency cycle(s), 4 unstable depended-on module(s). Read from the build's own module declarations; 11 module(s) off the main sequence, with abstractness counted on 47 of the 88 (the rest declare no modelled class or interface, export only macros, declare types in source no model reads, or have no source directory of their own).

Off the main sequence: ruff_memory_usage · ×10
Unstable project mdtest
Unstable project ruff
Unstable project ruff_server
Unstable project ty_server

+ 1 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 10 Off the main sequence finding(s) in Coupling. — One of this dimension's main actionable groups (10 warning-level).
  2. Resolve the 1 Unstable project mdtest finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).
  3. Resolve the 1 Unstable project ruff finding(s) in Coupling. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d5_recommendation.md · top locations in Appendix A, every location in findings.md.

D6 · Cohesion (LCOM4)9.8 / 10Stronggated by 21 serious findings✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Verified

21 of 1124 classes have LCOM4 above 3.

Low cohesion: UnionType (LCOM4 11) · ×21crates/ty_python_semantic/src/types/set_theoretic.rs:26

What to do

  1. Resolve the 21 Low cohesion finding(s) in Cohesion (LCOM4) — start with set_theoretic.rs (2), lib.rs (2), protocol_class.rs (2). — One of this dimension's main actionable groups (21 warning-level).

Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.

D8 · Code Coverage10.0 / 10Stronggated by 107 serious findings✓ Tool-verified

What it measures: How much of the code is actually exercised by tests.

Method: Coverage from the analyzer's own run of the suite, computed per-file with structured exclusions for generated, trivial, and glue code. A coverage report found in the repository is never read. When the suite can't be built/run in-image, coverage is reported NOT-MEASURED (excluded from the score) with the precondition to make it measurable — never a LoC-ratio proxy folded in as if measured. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

Line coverage 90.4% — 107 file(s) below 50%. Measured from the Rust suite (repository root: `cargo test --workspace` instrumented over 1699 production file(s), 84 test binaries and 1 doc-test binaries).

Low coverage: crates/mdtest/src/lib.rs · ×107crates/mdtest/src/lib.rs:1

What to do

  1. Resolve the 107 Low coverage finding(s) in Code Coverage — start with lib.rs (9), main.rs (6), settings.rs (4). — One of this dimension's main actionable groups (107 warning-level).

Detailed fixes: d8_recommendation.md · top locations in Appendix A, every location in findings.md.

D12 · Dependency Hygiene8.9 8.8 / 10Strong✓ Tool-verified

What it measures: Whether dependencies are current, not deprecated, and not bloated. Known vulnerabilities are D30's.

Method: Manifest scan via dotnet list package across all projects; worst-signal-per-package deduction (capped-linear for deprecation, prerelease and outdated) per KLoC. Known-vulnerable packages are D30's and are not charged here (rubric-2026.11.2). Exhaustive.

Maturity: Documented → Verified → Prevented · effective 8.8 / 10 · rule-coverage 98% · ceiling Verified

21 outdated, 0 yanked direct Cargo dependencies. 120 of 122 direct crates were graded against crates.io (0 not published there, 2 not resolved by a committed REDACTED). Only DIRECT edges are graded: a transitive crate cannot be moved past what its parent's requirement admits, so reporting one would be advice its owner cannot take. A newer release is reported only where this repository's OWN requirement already admits it, so the remedy is `cargo update` and never a manifest edit — which means a release outside the declared range is deliberately NOT charged, because a written-down constraint is a decision rather than a defect. Note that a bare requirement is a CARET, and for a 0.x crate its ceiling is the minor. Whether any crate is UNMAINTAINED is not graded — crates.io publishes no maintenance status, and release age does not stand in for one. Known CVEs in this dependency graph are D30's question, read from REDACTED there.

Outdated: arc-swap · ×21

Detailed fixes: d12_recommendation.md · top locations in Appendix A, every location in findings.md.

D13 · Secret Scanning10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

Secret scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

D14 · License Compliance10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the licenses of third-party packages are compatible with your policy.

Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 of 462 shipped crate(s) use a banned license. Licences were resolved from crates.io over the crates a consumer compiles — this repository's REDACTED closed over its manifests' `[dependencies]` and `[build-dependencies]`. Crates it asks for ONLY under `[dev-dependencies]` are excluded: they are not compiled by anything that depends on this repository. This repository publishes itself under MIT, which is its own choice and is not judged here. ★ COVERAGE OF THIS VERDICT: it grades this repository's crate dependencies and nothing else. The repository also declares a Python REDACTED/requirements.txt (pip/uv/Poetry) and package.json, and the licences of those dependency graphs were NOT read by this pass — a gap in this engine's coverage, not a statement about them. So this result says the graded closure carries no banned licence; it does NOT say this repository's licensing is clear.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots8.4 / 10Strong✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

Maturity: Documented → Verified → Prevented · effective 8.4 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: crates/ty_python_semantic/src/types/call/bind.rs (90×254=22860); crates/ty_python_semantic/src/types.rs (120×131=15720); crates/ty_python_semantic/src/types/infer/builder.rs (137×109=14933) Repeated repair below the complexity floor: crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs (3 of 5 changes were fixes)

Hotspot: crates/ty_python_semantic/src/types/call/bind.rs · ×90crates/ty_python_semantic/src/types/call/bind.rs:1715
Repeated repair: crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rscrates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs:129

What to do

  1. Resolve the 90 Hotspot finding(s) in Churn × Complexity Hotspots — start with builder.rs (3), mod.rs (3), lib.rs (3). — One of this dimension's main actionable groups (90 warning-level).
  2. Resolve the 1 Repeated repair finding(s) in Churn × Complexity Hotspots — start with non_pep695_type_alias.rs. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D16 · Bus Factor9.6 / 10Exemplary✓ Tool-verified

What it measures: Whether knowledge is concentrated in too few people (the "bus factor").

Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.

Maturity: Documented → Verified → Prevented · effective 9.6 / 10 · rule-coverage 100% · ceiling Documented

61 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is crates/ty_ide/src/docstring/document/google.rs. Counted over 1433 of the 2875 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Off-boarding risk: anonymized user #1 · ×5
Further sole-owners (lower concentration)

✓ On the Gold path — maintain.

Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt9.8 / 10Stronggated by 564 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Prevented

564 deducted task-comment markers across 728120 LoC (0.1/KLoC) → score 9.8. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×523scripts/ty_benchmark/src/benchmark/lsp_client.py:65
FixmeComment · ×32crates/ty_site_packages/src/lib.rs:2113
HackComment · ×7crates/ty_python_semantic/src/types/infer/builder/subscript.rs:253
XxxComment · ×2crates/ty_python_core/src/symbol.rs:107

What to do

  1. Resolve the 523 TodoComment finding(s) in Explicit Debt — start with bind.rs (35), builder.rs (35), types.rs (26). — One of this dimension's main actionable groups (523 warning-level).
  2. Resolve the 32 FixmeComment finding(s) in Explicit Debt — start with completion.rs (11), symbols.rs (6), importer.rs (3). — One of this dimension's main actionable groups (32 warning-level).
  3. Resolve the 7 HackComment finding(s) in Explicit Debt — start with range.rs (2), todos.rs (2), subscript.rs. — One of this dimension's main actionable groups (7 warning-level).

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D19 · Documentation Quality8.3 / 10Strong✓ Tool-verified

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 8.3 / 10 · rule-coverage 100% · ceiling Documented

1 of 2 documentation facets pass in full; short on: F2 example. 54 document(s) read across 8 unit(s).

Documentation: no build, run or usage exampleplayground/api/README.md:1

What to do

  1. Resolve the 1 Documentation finding(s) in Documentation Quality — start with README.md. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d19_recommendation.md · top locations in Appendix A, every location in findings.md.

D20 · ADR Quality0.0 / 10Critical✓ Tool-verified

What it measures: Whether architecture decisions are recorded well (context, decision, consequences).

Method: Every ADR read by its section structure: nine located rules (a missing Decision, Context or Consequences section, a stale status, two records deciding the same question, a dangling supersede link, a number-only title, a single option, no named cost, no status where the log uses one, no enforcement field where the log adopted one), each a fixed deduction from 10; the score is the mean over evaluated records. Deterministic, no model. Advisory.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

No architecture decision records were found.

No ADRs foundREDACTED:11

What to do

  1. Resolve the 1 No ADRs found finding(s) in ADR Quality — start with REDACTED. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d20_recommendation.md · top locations in Appendix A, every location in findings.md.

D24 · Comment Value8.4 8.0 / 10Strong✓ Tool-verified

What it measures: Whether comments are worth it — explaining WHY (valuable) rather than WHAT (redundant).

Method: Every inline C# comment compared word by word with the identifiers, literals and constructs of the code it annotates (taken from the syntax); a comment whose words that code already contains is redundant, as are closing-brace labels and generator template text. Comments giving a reason or a reference are kept; other scripts and languages are not judged. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 8.0 / 10 · rule-coverage 95% · ceiling Documented

1 of 62 judged comments only repeat the code they sit on (1.6 %). 5 comment(s) in another language or script were not judged.

redundant commentdocs/js/extra.js:24
doc comments repeat the namesplayground/ty/src/Editor/markdown.ts:20

What to do

  1. Resolve the 1 redundant comment finding(s) in Comment Value — start with extra.js. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d24_recommendation.md · top locations in Appendix A, every location in findings.md.

D26 · Project Cohesion7.9 / 10Strong✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic.

Maturity: Documented → Verified → Prevented · effective 7.9 / 10 · rule-coverage 100% · ceiling Documented

6 of 58 build units (Cargo, Python, npm) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

What to do

  1. Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.

D28 · Secrets (history)10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

gitleaks scanned the full history AND the current working tree and found no secrets.

✓ On the Gold path — maintain.

Detailed fixes: d28_recommendation.md.

D29 · Static Analysis (SAST)0.4 / 10Critical✓ Tool-verified

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

Maturity: Documented → Verified → Prevented · effective 0.4 / 10 · rule-coverage 100% · ceiling Documented

71 finding(s): 0 critical, 71 high, 0 medium, 0 low. 53 unpinned-GitHub-Actions row(s) are reported here but scored by D36 (supply-chain provenance), which measures that posture as `pinned_actions` — one pinning decision is charged once, not once per lens. semgrep hit a parse error in 390 file(s) — `crates/ruff_benchmark/resources/typeis_narrowing.py`, `crates/ruff_db/src/system/path.rs` (line 29), `crates/ruff_db/src/vendored/path.rs` (line 13), `crates/ruff_linter/src/rule_selector.rs` (line 246, line 270), `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_invalid_annotation.py` (line 1, line 2, line 3), … (+385 more) — so no absence of findings in the named regions is evidence of anything; rows reported elsewhere in those files are real. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 5 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 1 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 13 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (12), REDACTED. — One of this dimension's main actionable groups (13 issue-level).
  2. No action in Static Analysis (SAST) — all 47 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (47 issue-level, 0 of them charged here).
  3. No action in Static Analysis (SAST) — all 6 REDACTED finding(s) are reported here at file:line but scored by D36 (supply-chain provenance), so none is charged to this dimension. — One of this dimension's main actionable groups (6 issue-level, 0 of them charged here).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D30 · Dependency Vulnerabilities8.0 / 10Adequategated by 1 critical finding✓ Tool-verified

What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.

Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05. Advisory since rubric-2026.11.2 (CAI decision 0006): every row is a match against a vulnerability database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 8.0 / 10 · rule-coverage 100% · ceiling Documented

5 finding(s): 1 critical, 0 high, 4 medium, 0 low.

REDACTED
REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 2 Medium advisory (unmaintained) finding(s) in Dependency Vulnerabilities — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).
  3. Resolve the 1 Medium vulnerability finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.

D31 · IaC & Container Security9.1 / 10Adequategated by 2 critical findings✓ Tool-verified

What it measures: Whether Dockerfiles / Terraform / Kubernetes config follow security best practices.

Method: IaC/container misconfiguration scan via trivy config (REDACTED/Terraform/K8s/Helm/CloudFormation); severity rules to 0-10 moderate normalizer. NotApplicable without manifests. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 9.1 / 10 · rule-coverage 100% · ceiling Documented

4 finding(s): 0 critical, 2 high, 2 medium, 0 low.

REDACTED
REDACTED

What to do

  1. Resolve the 2 High IaC finding(s) in IaC & Container Security — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
  2. Resolve the 2 Medium IaC finding(s) in IaC & Container Security — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).

Detailed fixes: d31_recommendation.md · top locations in Appendix A, every location in findings.md.

D34 · Knowledge Freshness9.3 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

Maturity: Documented → Verified → Prevented · effective 9.3 / 10 · rule-coverage 100% · ceiling Documented

95 of 1433 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is crates/ty_python_core/src/builder/loop_bindings_visitor.rs. Counted over 1433 of the 2875 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Orphaned file · ×95crates/ty_python_core/src/builder/loop_bindings_visitor.rs:1
Orphaned files with no living knowledge

✓ On the Gold path — maintain.

Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.

D35 · Change Coupling9.8 / 10Adequategated by 1 critical finding✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

Maturity: Documented → Verified → Prevented · effective 9.8 / 10 · rule-coverage 100% · ceiling Documented

Strongest change-coupling: fix.rs↔lint.rs 70%; re_exports.rs↔dunder_all.rs 69%; dunder_all.rs↔class.rs 67%

Boundary-crossing change coupling: db.rs ↔ ty_check_invalid_syntax.rscrates/ruff_graph/src/db.rs:1
Change coupling: fix.rs ↔ lint.rs · ×16crates/ruff_server/src/fix.rs:1
Change-coupling hub: re_exports.rs → dunder_all.rs, class.rs, infer.rs · ×2crates/ty_python_core/src/re_exports.rs

What to do

  1. Resolve the 1 Boundary-crossing change coupling finding(s) in Change Coupling — start with db.rs. — One of this dimension's main actionable groups (1 issue-level).
  2. Resolve the 16 Change coupling finding(s) in Change Coupling — start with preview.rs (2), builder.rs (2), testing.rs (2). — One of this dimension's main actionable groups (16 warning-level).
  3. Resolve the 2 Change-coupling hub finding(s) in Change Coupling — start with re_exports.rs, requests.rs. — One of this dimension's main actionable groups (2 warning-level).

Detailed fixes: d35_recommendation.md · top locations in Appendix A, every location in findings.md.

D36 · Supply-chain Provenance & Signing5.0 / 10Adequate✓ Tool-verified

What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.

Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.

Maturity: Documented → Verified → Prevented · effective 5.0 / 10 · rule-coverage 100% · ceiling Documented

2/4 supply-chain integrity signals present (provenance, signing, SBOM, pinned actions).

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

+ 3 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
  2. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 warning-level).
  3. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Reported apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.

Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. Advisory since rubric-2026.11.2 (CAI decision 0006): the malicious-package feed is a database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

D44 · Platform End-of-Life10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.

Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 3 platform declaration(s) and 19 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.

✓ On the Gold path — maintain.

Detailed fixes: d44_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AC2 · Forms & labels5.4 / 10Adequate✓ Tool-verified

Other · Accessibility — Whether form controls have a programmatic label (an associated label, aria-label or aria-labelledby), buttons have text, links have an accessible name, a click handler on a plain element names the control it declares, fieldsets have a non-empty legend, known UI-library field components carry a label prop, and a placeholder isn't used as the only label. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: inputs/selects/textareas checked for an associated label[for]/wrapping label/aria-label/aria-labelledby (per document), buttons for accessible text, fieldsets for a legend; placeholder-only labelling flagged. Deterministic, hard fact per control.

Coverage: Population: form controls, buttons, links, fieldsets and known UI-library field components in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx); components, hidden subtrees and spread/dynamic-attribute elements are skipped, so a control whose label arrives through a spread or a runtime expression is deliberately not judged. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

  • A link with no text, aria-label or labelled child (e.g. an icon-only link) has no accessible name, so assistive tech can't say where it goes. Add visible text or an aria-label. (×2) — playground/shared/src/Header.tsx:97, playground/shared/src/RepoButton.tsx:3
  • This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it. — playground/ty/src/Editor/Files.tsx:184

What to do

  • Give every control a programmatic label (a <label for> / wrapping <label> / aria-label) and every button text — a placeholder is not a label.
AC3 · Page structure10.0 / 10Exemplary○ Nothing flagged

Other · Accessibility — Whether pages declare a language (well-formed BCP-47) and a non-empty title, expose exactly one main landmark and a sane heading order with non-empty headings, keep zoom enabled, title their iframes, give data tables header cells, and avoid meta-refresh. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: html lang, document <title>, a main landmark and heading order on full documents only, plus zoom-disabling viewports, untitled iframes and meta-refresh anywhere. Deterministic, per structural checkpoint.

Coverage: Population: the PARSED MARKUP documents (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx). The page-level checks — lang, title, single main landmark — fire ONCE PER FULL DOCUMENT (an <html> root) and never on a partial or component fragment, so a repo of fragments is assessed only on the per-element checks (heading order, table headers, iframe titles, meta-refresh, zoom). Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

AC4 · Keyboard semantics1.0 / 10Critical✓ Tool-verified

Other · Accessibility — Whether interactive behaviour is keyboard-reachable — no click handler on a non-interactive element lacking a role, tabindex and key handler, no element the repo's own CSS styles `cursor: pointer` without giving it any of the three, no unfocusable element whose only binding is a mouse enter/leave pair or a double-click, no positive tabindex, no href-less anchor, no placeholder-href (#/javascript) link acting as a button. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: click handlers on non-interactive elements lacking role+tabindex+key handler, positive tabindex values, and href-less anchors. Components skipped, spreads suppressed. Deterministic, hard fact per element.

Coverage: Population: elements that pose a keyboard-semantics question, in the PARSED MARKUP files only (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) — a non-natively-interactive element carrying a click handler, a double-click or hover enter/leave binding, a pointer-only gesture on a tabindex="0" element, or `cursor: pointer` from the repo's own CSS; an href-less or placeholder-href (#, javascript:) anchor; and any element with a positive tabindex. Natively interactive elements used correctly (<button>, <a href>, form controls) are NOT in the population — there is nothing to judge — so a page of nothing but correct controls gives AC4 nothing to measure. Keyboard reachability is judged from the markup, never from a rendered page. ★ An interactive element declared in a tagged-template (html`…`) or hyperscript frontend is NOT in this population — no producer reads either — so an empty population is reported as an analyzer gap, never as "this repository has no interactive elements".

  • This <li> announces itself as a role="button" and binds a click, but nothing can put focus on it: no tabIndex={0} in any spelling, no key handler, and nothing in this file moves focus or sets aria-activedescendant. The role tells assistive tech what the control IS; it does not make the control reachable, so a keyboard user cannot operate it at all (WCAG 2.1.1). Give it tabIndex={0}="0" and an Enter/Space key handler, or make it a native <button>. If a parent widget owns the keyboard model, that parent must move focus onto the active role="button" or point aria-activedescendant at it. — playground/shared/src/SideBar.tsx:39

What to do

  • Make custom controls keyboard-operable (role + tabindex + key handler), drop positive tabindex, and give anchors a real href.
AC5 · ARIA correctness10.0 / 10Exemplary○ Nothing flagged

Other · Accessibility — Whether ARIA is used correctly — valid non-abstract roles, the ARIA state a role requires, valid (non-misspelled) aria-* attribute names, in-enum values for token-typed aria-* attributes, and no aria-hidden on (or wrapping) a focusable element. Static markup readiness, not a WCAG conformance claim.

Method: Static markup-model scan: role values checked against the WAI-ARIA role set (abstract/invalid flagged), required ARIA state for a role, and aria-hidden on a focusable element. Deterministic, role/attribute level.

Coverage: Population: elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx) that carry a role or an aria-* attribute; roles and token values are checked against the ARIA enums exhaustively within that set. An expression-valued (dynamic) role or aria-* value is skipped rather than guessed, and markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

AC6 · Visual & motion safety10.0 / 10Exemplary○ Nothing flagged

Other · Accessibility — Whether focus outlines aren't removed without a replacement, motion respects prefers-reduced-motion, and literal CSS colour pairs meet contrast — PARTIAL: inline styles, in-repo <style> blocks, in-repo .css files, var() tokens, Tailwind neutral utilities and CSS-in-JS literals are read (hex/rgb/hsl/named), never computed/runtime/external-CDN colour. Static markup readiness, not a WCAG conformance claim.

Method: Static markup/CSS scan: inline outline:none/0, literal inline colour/background contrast against the 4.5:1 AA floor, and <style>-block animation without a prefers-reduced-motion guard. Deterministic but PARTIAL — only inline styles and in-repo CSS literals are visible.

Coverage: Population: styled elements in the PARSED MARKUP files (.html/.htm/.cshtml/.razor/.vue/.svelte/.jsx/.tsx), plus in-repo <style> blocks, in-repo .css files and CSS-in-JS literals. Colour contrast is computed from LITERAL colour pairs only (hex/rgb/hsl/named, including var() tokens and Tailwind neutral utilities) — computed, runtime-themed and external-CDN colour is never resolved, so this is a partial read of contrast by construction. Markup built in script — tagged-template (html`…`) UIs and hyperscript DOM factories — is not read at all.

AX10 · Code composition9.9 / 10Exemplary✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

AX8 · Test isolation10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether production projects stay free of references to test projects — tests may depend on production, never the reverse.

Method: Csproj graph: each production project checked for references to test projects (identified by test-framework presence, not name). Zero violations is clean. Deterministic.

AX9 · CQS / query purity10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether read (query) handlers stay side-effect-free — a query that writes persistent state or raises events breaks CQS and makes reads unsafe to retry, cache, or route to a read replica.

Method: Roslyn scan: CQRS handlers classified query-vs-command by interface (IQueryHandler/ICommandHandler/IRequestHandler<TQuery,TResult>) and name convention (*Query/Get*/Find* vs *Command); each query handler's body checked for persistent-state writes (SaveChanges/repository Add-Update) or event publishes by resolved invocation. Deterministic, type-level, exhaustive over the detected handlers.

Coverage: Population: CQRS handlers identified by IQueryHandler/ICommandHandler/IRequestHandler interface + *Query/Get*/Find*/*Command NAME convention; query purity then checked exhaustively within that set — a query handler using neither convention is invisible, and mutation is a resolved persistence/publish CALL, not full dataflow.

ES1 · Fold determinism10.0 / 10Exemplary✓ Tool-verified

Other · Event Sourcing — Whether the recovery-replay fold is deterministic — state derived purely from each event's own fields, no clock/random/IO on the replay path.

Method: Roslyn syntax scan (event-sourcing gated): Apply/When folds checked for forbidden tokens (DateTime.Now, Guid.NewGuid, Random, IO), stripped of comments/strings. Deterministic, hard fact per fold.

ES2 · Immutable events10.0 / 10Exemplary✓ Tool-verified

Other · Event Sourcing — Whether domain events stay immutable (private fields, set once) rather than carrying mutable state.

Method: Roslyn scan (event-sourcing gated): persisted events checked for public setters; immutability verified per property/field. Deterministic, hard fact.

M1 · Documentation (README)9.2 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repository and its projects have a README, and whether it is substantive.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

M2 · Architecture documentation5.0 / 10Adequate✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repository is organised deliberately: production code and tests are set apart in a way its ecosystem or the repository itself declares.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

P1 · CI/CD gates10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.

Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language's code model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.

P2 · Observability6.6 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

  • Only 25/29 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `crates/ty_completion_bench`, `crates/ty_completion_eval`, `python/py-fuzzer`.

What to do

  • Extend structured logging to the remaining runnable modules so everything you run is diagnosable in production.
  • Add a health-check endpoint (a /health route on your axum/actix router) so orchestrators and load balancers can probe liveness/readiness.
P3 · Security & performance tooling6.0 / 10Adequate✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

  • `playground/api/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`. — playground/api/package.json:7

What to do

  • Enable Dependabot/Renovate or a dependency-review gate.
  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P4 · Deployment & Rollback10.0 / 10Exemplary✓ Tool-verified

Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.

Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.

P6 · Release Hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

PF1 · Benchmark discipline9.0 / 10Exemplary✓ Tool-verified

Readiness · Performance — Whether the code protects its performance with benchmarks — a benchmark suite, allocation/memory measurement, and (ideally) a CI gate. Presence is credited as a bonus, never a deduction.

Method: Repo + source scan: BenchmarkDotNet referenced (csproj/source), [Benchmark]/[MemoryDiagnoser] attribute counts, and a benchmark step in CI; off .NET, the same ladder over Go testing.B, Rust criterion/#[bench]/divan, JMH/kotlinx-benchmark, pytest-benchmark/asv/pyperf, tinybench/mitata/vitest bench/benchmark.js and Swift package-benchmark — scored as a bonus ladder (absence is neutral, never a deduction). Deterministic, presence detection.

PF3 · Async & latency hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.

Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from each language's code model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

S1 · Web-Security Posture8.0 / 10Strong✓ Tool-verified

Other · Security — Read from this repository's Rust source: cryptographic hygiene (weak hash or cipher, key material fixed in the source) and outbound TLS (certificate validation, protocol version) — facts about code that hold whether or not it serves anything itself. Markup this repository SHIPS is scored for third-party script integrity whether or not the repository serves it itself, since a page handed to a consumer runs in that consumer’s origin. The server controls — HTTPS enforcement, HSTS, cookie flags, input validation — are read from a Rust server this repository starts itself, and its production Rust starts none. What serves its HTTP is outside the Rust source, and only what this card names about it was assessed.

Method: Roslyn plus filesystem scan: HSTS/security headers, secure cookies, input validation, middleware order, weak crypto (MD5/SHA1/DES); HTTPS-metadata context-aware. On a repository with no .NET source it reads JavaScript/TypeScript, Dart, Ruby, Scala, Rust or Elixir source itself (test, vendored, generated and minified paths not) for the arms that hold whether or not the code serves HTTP: a weak hash or cipher, key material fixed in the source, a TLS client that accepts any certificate, and (JavaScript/TypeScript, Ruby, Scala, Rust and Elixir) an obsolete TLS version; the server controls are not assessed there, and a Dart, Ruby, Scala, Rust or Elixir repository that serves no HTTP of its own is N/A on them. Deterministic.

  • `https://cdn.usefathom.com/script.js` is executed by this page with no Subresource Integrity. Whoever can answer that request — the CDN, anyone who compromises it, anyone on the network path — runs arbitrary script in this page's origin, with its session. The URL also names no version, so it resolves to whatever that origin serves at fetch time — the executed bytes can change with nobody touching this repository. 2 such include(s) across the repository's markup. — playground/ruff/index.html:29

What to do

  • Pin third-party scripts and verify them: name an exact version in the URL and add an `integrity="sha384-…"` hash alongside `crossorigin="anonymous"` (both are required — an integrity hash on a cross-origin script without `crossorigin` is not evaluated, it blocks the script). Where the vendor ships a continuously-updated loader and publishes no stable hash (tag managers, analytics, chat widgets), Subresource Integrity is not available: constrain it instead with a `Content-Security-Policy` that names the exact origins allowed to execute, and drop the script from the pages that do not need it. Where the page is shipped inside a package that others host, prefer vendoring the asset and serving it from the app’s own origin, so no consumer inherits a third-party dependency they did not choose.
X1 · Async correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.

Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.

X2 · Cancellation propagation4.0 / 10Weak✓ Tool-verified

Other · Code Health — Whether async functions that make a cancellable request accept or pass on an AbortSignal (adoption curve).

Method: Roslyn scan: every async method (excluding framework-fixed overrides/Blazor handlers) checked for CancellationToken parameter presence. Deterministic, adoption percentage. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same question: every named async function that itself makes a request an AbortSignal can cancel (global `fetch`, axios and its file-local instances, ky, ofetch) counts, and it is compliant when its parameters or body name a signal or it hands one of its own parameters to the request as options; signatures a framework fixes (JSX event handlers, route and lifecycle exports, request-first handlers, `override`, `'use server'` modules, TanStack `mutationFn`) are exempt unless they take a signal. Deterministic, adoption percentage.

  • Only 0/4 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
  • `fetchPlayground` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. (×2) — playground/ty/src/Editor/api.ts:14, playground/ruff/src/Editor/api.ts:13
  • `savePlayground` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`. (×2) — playground/ty/src/Editor/api.ts:27, playground/ruff/src/Editor/api.ts:24

What to do

  • Thread an AbortSignal through async functions that make requests, so the work stops when its caller gives up.
X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.

Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.

X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `for` loop leaves the `RefCell` it is walking alone — safe Rust rejects a body that changes the collection its loop borrows at compile time, except through interior mutability: a `RefCell` borrowed in the loop's header stays borrowed until the loop ends, so a `borrow_mut()` of it inside the body panics with `already borrowed: BorrowMutError` and the remaining elements are never seen. Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.

Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.

X29 · Per-element action decided by a fixed element10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a decision taken once per element is taken ABOUT that element — a test inside a counted loop that reads a fixed subscript of the very collection its guarded statement indexes by the loop variable applies element zero's answer to all of them, so the elements that differ from it are all handled wrongly, and in the same direction.

Method: Roslyn syntax only, no semantic model: every `for` statement declaring exactly ONE loop variable, and every `if` inside its body that is not under a nested loop or a lambda. A site enters the population when the `if`’s condition never mentions the loop variable while the statement it guards indexes some collection by that variable ALONE (`c[i]`; `c[i + 1]` and `c[i, j]` are outside it). A finding additionally needs the AGREEING TWIN at the same-collection grain: the condition must read THAT SAME collection at a subscript that does not move — written into the condition, or reached through a local declared BEFORE the loop, so an alias bound inside the body is not followed. Both collection expressions must be simple identifiers. On a repository with no .NET source the same rule reads JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `for (let|var|const x = …; …; …)` with one declarator and a braced body, an alias followed only when it is declared before the loop in a block that encloses it and never assigned inside the loop. Deterministic, provable per finding. Advisory.

X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.

Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.

X4 · Structured logging2.1 / 10Critical✓ Tool-verified

Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.

Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.

  • `trace!` at line 45 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `trace!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_test/src/db.rs:45
  • `debug!` at line 436 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_test/src/lib.rs:436
  • `debug!` at line 315 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:315
  • `debug!` at line 343 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:343
  • `trace!` at line 403 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `trace!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:403
  • `debug!` at line 759 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:759
  • `warn!` at line 805 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:805
  • `warn!` at line 831 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:831
  • `trace!` at line 874 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `trace!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:874
  • `warn!` at line 906 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:906
  • `warn!` at line 930 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:930
  • `warn!` at line 935 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:935
  • `debug!` at line 944 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:944
  • `debug!` at line 980 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:980
  • `debug!` at line 990 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:990
  • `debug!` at line 1224 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:1224
  • `debug!` at line 1241 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:1241
  • `debug!` at line 1674 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:1674
  • `debug!` at line 1823 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_site_packages/src/lib.rs:1823
  • `warn!` at line 108 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/document.rs:108
  • `warn!` at line 68 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/lib.rs:68
  • `error!` at line 84 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/server.rs:84
  • `debug!` at line 87 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/server.rs:87
  • `debug!` at line 88 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/server.rs:88
  • `debug!` at line 92 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/server.rs:92
  • `info!` at line 99 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `info!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/server.rs:99
  • `warn!` at line 144 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/server.rs:144
  • `error!` at line 225 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/server.rs:225
  • `debug!` at line 268 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:268
  • `debug!` at line 291 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:291
  • `debug!` at line 442 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:442
  • `debug!` at line 455 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:455
  • `debug!` at line 720 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:720
  • `debug!` at line 723 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:723
  • `debug!` at line 731 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:731
  • `debug!` at line 752 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:752
  • `debug!` at line 756 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:756
  • `error!` at line 825 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:825
  • `debug!` at line 960 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:960
  • `error!` at line 967 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`. — crates/ty_server/src/session.rs:967

What to do

  • Interpolated log message defeats structured logging
X5 · Nullable reference types7.1 / 10Strong✓ Tool-verified

Other · Code Health — Whether strict null checking is enabled and not undermined by heavy `!` assertion — TypeScript's `strictNullChecks` (which `strict` turns on) is what makes `string` exclude `null` and `undefined`, and the postfix `!` is the operator that silences it.

Method: Roslyn compiler-options scan: NullableContextOptions per project; null-forgiving (!) suppression density per 1k syntax nodes. Deterministic, adoption plus suppression penalty.

  • 2/3 of this repository's type-checking configuration(s) turn on strict null checking (`"strict": true`, or `"strictNullChecks": true`). A configuration that states neither is counted as OFF, because off is tsc's own default; a solution-style one whose `"files"` is empty and whose `"references"` point at other projects is in neither number, because it checks no source itself. Where it is off, `string` admits `null` and `undefined`: passing a value that is null compiles silently and throws on the first property access.
  • ~0.7 `!` null assertions per 1k TypeScript source lines — 5 assertion(s) across the 7291 source line(s) of the 43 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: playground/ruff/src/Editor/Editor.tsx (2), playground/ruff/src/Editor/SecondaryPanel.tsx (2), playground/ruff/src/Editor/settings.ts (1). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce. Many are correct: each is a claim the checker could not verify, and it is wrong only where the value can in fact be missing, so review the densest places first.

What to do

  • The findings name the configuration each number was taken from and, for the assertions, the files that hold them. Turn null checking on where it is off — `"strict": true` in the base tsconfig that the others extend switches `strictNullChecks` on with the rest of the family — and then resolve the assertions rather than adding to them. A `!` on a value the checker could show to be null is a promise the author cannot check from where they are standing, and each one is a `TypeError: Cannot read properties of null` waiting for the path that makes it true; where the value genuinely cannot be null, say something the checker can see instead (narrow it with a test, make the property required, drop the `?`).

WCAG coverage — what static analysis assessed

Statically assessed 12 of 55 WCAG 2.2 Level A/AA success criteria (22%; ≈24% of the 50 WCAG 2.1 AA criteria for EN 301 549). The other 43 require runtime or manual evaluation. Partial signal only (a clean result is necessary, not sufficient; static analysis fully verifies none). This is accessibility readiness, not a conformance claim — a WCAG conformance claim requires manual evaluation (WCAG-EM 1.0).

DimensionWCAG 2.2 A/AA criteriaCoverage
AC2 · Forms & labels1.3.1, 3.3.2, 4.1.2Partial signal
AC3 · Page structure1.4.4, 2.2.1, 2.4.1, 2.4.2, 3.1.1, 4.1.2Partial signal
AC4 · Keyboard semantics2.1.1, 2.4.3Partial signal
AC5 · ARIA correctness4.1.2Partial signal
AC6 · Visual & motion safety1.4.3, 2.4.7Partial — literal CSS only

Not statically assessed — these 43 Level A/AA criteria need runtime or manual evaluation (WCAG-EM): 1.1.1, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.4.1, 1.4.2, 1.4.5, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 2.1.2, 2.1.4, 2.2.2, 2.3.1, 2.4.4, 2.4.5, 2.4.6, 2.4.11, 2.5.1, 2.5.2, 2.5.3, 2.5.4, 2.5.7, 2.5.8, 3.1.2, 3.2.1, 3.2.2, 3.2.3, 3.2.4, 3.2.6, 3.3.1, 3.3.3, 3.3.4, 3.3.7, 3.3.8, 4.1.3.

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health51%Adequate — gated by D2, X4Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture97%ExemplarySolid.
Maturity78%StrongSolid.
Readiness80%StrongSolid.
Security74%Adequate — gated by D29Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Event Sourcing100%ExemplaryStrongest area.
Accessibility59%Adequate — gated by AC4Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Performance94%ExemplarySolid.
Unscored — 2 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • X10 Duplicated predicate — 40 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 4 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 control(s) we could not find positive evidence for

These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.

  • P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 58 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AC1 Text alternatives — No image/media element found in the parsed markup — AC1 not applicable here.
  • AX1 Captive dependencies — Not applicable: this repository's Python imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's; Rust with no dependency-injection crate has no container to hand one lifetime's instance to another — every value is owned by the code that builds it, and the borrow checker rejects a longer-lived value keeping a borrow of a shorter-lived one; this repository's TypeScript imports no dependency-injection container and defines no container of its own — nothing that both registers and resolves bindings, and nothing that names two lifetimes — so nothing holds one lifetime's instance while handing out another's.
  • AX2 Stateful singletons — Not applicable: Rust's compiler refuses unsynchronised shared mutation — a value shared across threads must be Sync — so the race this check looks for cannot be written. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
  • AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX6 Interface segregation — AX6 reached only 1% of this repository's production lines — rust (699,137 lines), python (20,865 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • AXR1 Runtime accessibility — the dev server (`npm run start`) exited before it served a page. Likely cause (our sandbox): `npm run` found no package.json in the folder where our sandbox ran it. This is a limit of our sandbox, not of your repository. Last output: "npm error code ENOENT / npm error syscall open / npm error path <repo>/package.json / npm error errno -2 / npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '<repo>/package.json' / npm error enoent This is related to npm not being able to find a file. / npm error enoent / npm error A complete log of this run can be found in: <path>" No runtime evidence was gathered. This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
  • C1 Data Protection — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no data at rest for these controls to protect.
  • C2 Access Controls — No access-control surface detected in the analyzed source — this repository starts no server another machine can reach (no actix-web HttpServer, axum::serve, Rocket launch, warp::serve, poem or salvo Server, tonic Server::builder, hyper or tiny_http server outside examples and tests, none bound beyond loopback). Access control is therefore N/A here — a crate is authorized by the application that serves it, not by itself. If this codebase grows request handlers, the dimension reactivates and a default-deny posture is expected then.
  • C3 Audit Trail — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no sensitive data whose changes an audit trail would record. If it does (through a store configured outside this repository, for instance), the trail belongs to wherever that data is stored.
  • C4 Data Retention — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no personal data whose lifetime a retention limit would bound.
  • C5 Data-Subject Rights — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Diesel schema, a SeaORM entity, a Diesel or sqlx row struct, or a SQL CREATE TABLE or ALTER TABLE — and no database or data-store crate (sqlx, Diesel, SeaORM, rusqlite, tokio-postgres, MongoDB, …) in the source either, so this repository keeps no personal data for a data subject to erase, export or consent over.
  • D10 Test Quality — ~140703 lines of test source are present (.py, .rs) but no test cases reached the test census for this repository — no test root we could resolve declared them, or the files we read declare no cases in a test framework we recognise — so skipped/assertion-free tests couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
  • D11 Test Reliability — Test reliability not included — the .rs suite was found but not re-run
  • D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
  • D21 Naming Consistency — Naming consistency does not read html yet; not measured.
  • D22 Internal API Consistency — API consistency is measured on C# only; the exposed Rust surface was not measured.
  • D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ sibling projects each declaring an entity of their own or taking another project's integration events. Aggregate roots were found in only one source directory (ty_project), which is a layered codebase, not two contexts. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
  • D25 ADR Conformance — no ADRs to check
  • D27 Navigability — D27 counts a call into the standard library or a dependency as unresolved for this repository's language (.rs), so too few call sites counted as resolved to assess navigability. Not scored: this is a gap in the analyzer, not a verdict about this repository.
  • D32 Data Compliance (PII/GDPR) — 364 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
  • D37 Vulnerability-disclosure Policy — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.
  • D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
  • D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
  • D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • DM1 Domain Modelling — applicable but not scored (3 signals for this style, 3 needed — the count is met but a required primary signal is absent): 1 aggregate root(s) (types guarding their own state behind command methods — this language has no AggregateRoot base to inherit); 632 value object(s); 1 domain event(s); its domain events are published by services or handlers — no domain entity raises one; no aggregate is declared and no domain structure surrounds the state-guarding types: not claimed as DDD
  • ED2 Event/command shape — not scored — deciding whether a command has more than one competing handler requires resolving the call graph, and a call made through an inferred or generic receiver has no resolvable owner in the source. Reported as guidance rather than measured
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
  • IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • M4 Documentation accuracy — Not applicable: the 54 current-state document(s) make no claim of a kind M4 checks. 112 claim(s) of kinds M4 does not check were not checked (path 83, command argument 13, environment variable 15, cd 1); M4 checks only links and versions and artefact counts.
  • P12 CI test-gate honesty — Reported, not scored — and nothing was matched here. The coverage check applies to any stack, and the automatic-re-run check to any GitHub-Actions workflow, but the checks for excluded tests, skipped tests and sleep-based synchronisation currently recognise only some ecosystems' test-runner idioms, so on a repository built with another stack the zeros below mean 'not checked', not 'clean'.
  • P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the JavaScript/TypeScript, Python, Rust source, so there is no service whose uptime a failing dependency could take down
  • P8 Schema migrations — no ORM, schema-migration tool or schema auto-create was found in this repository's dependency manifests or source, so there is no database schema for this check to judge
  • P9 Domain vs controller coverage — coverage data present for 1699 file(s), but no domain-layer files were identified: no covered file's path contains any of the markers this check keys on (/domain/, /aggregates/, /valueobjects/, /domainmodel/, .domain/, /entities/), which are matched case-insensitively anywhere in the path. With no domain partition there is nothing to compare the web/controller layer against — if this repository keeps its business rules under a folder named none of those, that naming is what the check cannot see, not the domain logic.
  • PF2 Allocation hygiene — Not scored: this check counted allocation-aware idioms (Span, pools, stackalloc) per line, which describes what kind of code a repository is rather than whether it has an allocation problem, so it was withdrawn. Nothing here is a finding about your code.
  • SC1 Supply-chain hygiene — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X12 Unreachable branch — X12 reached only 4% of this repository's production lines — rust (699,137 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X13 Undrained process stream — X13 reached only 4% of this repository's production lines — rust (699,137 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X14 Bypassable address classification — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X15 Unvalidated length from an untrusted reader — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X16 Unfloored truncation loop — X16 reached only 1% of this repository's production lines — rust (699,137 lines), python (20,865 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X17 Uncapped recursion over a caller-supplied document — Uncapped recursion over a caller-supplied document could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository.
  • X18 Disposal-pattern correctness — X18 reached only 1% of this repository's production lines — rust (699,137 lines), python (20,865 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X19 Unrestored process-global state — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X22 Contradicted release guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X23 Unguarded diagnostic materialisation — X23 reached only 4% of this repository's production lines — rust (699,137 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X24 Document value interpolated into markup unescaped — X24 reached only 4% of this repository's production lines — rust (699,137 lines) was left unread. Not scored: a score over a minority of the product would be published as the whole of it.
  • X25 Inert configuration knob — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X26 Unsynchronised callback handoff — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X28 Index access outside its own emptiness guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
  • X3 Exception handling — Exception handling could not be assessed in this run — the check did not complete, so it is not scored. This is a gap in the analyzer, not a finding about this repository.
  • X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 79 finding(s)
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • + 22 more in this group — see findings.md.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
AC2 · Forms & labels · Link with no accessible name · ×2
  • Link with no accessible name playground/shared/src/Header.tsx:97 — A link with no text, aria-label or labelled child (e.g. an icon-only link) has no accessible name, so assistive tech can't say where it goes. Add visible text or an aria-label.
  • Link with no accessible name playground/shared/src/RepoButton.tsx:3 — A link with no text, aria-label or labelled child (e.g. an icon-only link) has no accessible name, so assistive tech can't say where it goes. Add visible text or an aria-label.
D31 · IaC & Container Security · High IaC · ×2
  • REDACTED
  • REDACTED
AC2 · Forms & labels · <input> without a programmatic label · ×1
  • <input> without a programmatic label playground/ty/src/Editor/Files.tsx:184 — This control has no associated label. Add a <label htmlFor> / wrapping <label> / aria-label / aria-labelledby so assistive tech can name it.
AC4 · Keyboard semantics · Clickable role="button" that no keyboard user can reach · ×1
  • Clickable role="button" that no keyboard user can reach playground/shared/src/SideBar.tsx:39 — This <li> announces itself as a role="button" and binds a click, but nothing can put focus on it: no tabIndex={0} in any spelling, no key handler, and nothing in this file moves focus or sets aria-activedescendant. The role tells assistive tech what the control IS; it does not make the control reachable, so a keyboard user cannot operate it at all (WCAG 2.1.1). Give it tabIndex={0}="0" and an Enter/Space key handler, or make it a native <button>. If a parent widget owns the keyboard model, that parent must move focus onto the active role="button" or point aria-activedescendant at it.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · Critical CVE · ×1
  • REDACTED
D35 · Change Coupling · Boundary-crossing change coupling · ×1
  • Boundary-crossing change coupling: db.rs ↔ ty_check_invalid_syntax.rs crates/ruff_graph/src/db.rs:1 — `crates/ruff_graph/src/db.rs` (context crates) and `fuzz/fuzz_targets/ty_check_invalid_syntax.rs` (context fuzz) sit in DIFFERENT parts of the tree yet change together 56% of the time (10 of the 18 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) — the bounded-context boundary may be in the wrong place, or one context is leaking into the other. This is the behavioural boundary violation a static scan can't see. You can check this without leaving the row: of the 10 shared commits counted here, the most recent 3 are `d6a7c9b4` [ty] Add `respect-type-ignore-comments` configuration option (#22137); `9393279f` [ty] Limit shown import paths to at most 5 unless ty runs with `-v` (…; `99d0ac60` [ty] Track open files in the server (#19264) — run `git show` on any of them.
Serious — 3815 finding(s)
D17 · Explicit Debt · TodoComment · ×523
  • TodoComment scripts/ty_benchmark/src/benchmark/lsp_client.py:65 — # TODO: remove the suppression comment when https://github.com/openlawlibrary/pygls/pull/635 has been released
  • TodoComment scripts/ty_benchmark/src/benchmark/lsp_client.py:82 — # TODO: remove the suppression comment when https://github.com/openlawlibrary/pygls/pull/635 has been released
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/check.py:123 — # TODO: This is not a performant way to check the length but the whole — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/check.py:155 — # TODO(zanieb): We take the `max` here to avoid division by zero errors where — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/check.py:173 — # TODO: remove the need for the max() call here, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/check.py:477 — # TODO(zanieb): There has to be a cleaner way to express this logic — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/check.py:512 — # TODO(brent) Remove this workaround when human-readable rule names are stabilized. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/format.py:177 — # TODO(brent) Remove this workaround when human-readable rule names are stabilized. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/format.py:211 — # TODO(brent) Remove this workaround when human-readable rule names are stabilized. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/cli.py:120 — # TODO: Support non-default `--targets` — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/defaults.py:14 — # TODO(zanieb): Consider exporting this as JSON and loading from there instead — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/defaults.py:78 — # TODO: Re-enable Sphinx once https://github.com/sphinx-doc/sphinx/issues/14364 is fixed.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/markdown.py:25 — # TODO(zanieb): GitHub does not support coloring with <span> it seems like the only — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment python/ruff-ecosystem/ruff_ecosystem/projects.py:62 — # TODO(brent) Remove selector normalization when human-readable rule names are stabilized. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment playground/ty/src/Editor/Editor.tsx:371 — // TODO(micha): It's unclear why this field is required for monaco but not VS Code. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_wasm/src/lib.rs:585 — // TODO: Provide a way to configure this — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_test/src/lib.rs:502 — // TODO: For now list_modules does not partake in desperate module resolution so — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_site_packages/src/lib.rs:1081 — // TODO: replace this with better shim support, e.g. pyenv — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_server/tests/e2e/initialize.rs:526 — /// TODO: This test currently only verifies a single capability. It should be — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_server/tests/e2e/main.rs:256 — // TODO: This should probably be configurable to test concurrency issues — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ruff_server/tests/e2e/main.rs:207 — // TODO: This should probably be configurable to test concurrency issues — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_server/src/server/api.rs:450 — // TODO: Revisit this check before routing a notification that can target closed documents through — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_server/src/server/api/diagnostics.rs:68 — // TODO: Hash only the source snippets used by the rendered output. Hashing the entire — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_python_semantic/src/place.rs:975 — // TODO: Preserve `Final` when a later public assignment re-exports a private import, — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment crates/ty_python_semantic/src/place.rs:1360 — // TODO: We probably don't want to report `AlwaysDefined` here. This requires a bit of — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • + 498 more in this group — see findings.md.
D2 · Cognitive Complexity · ruff_linter · ×229
  • ruff_linter::checkers::ast::analyze::statement::statement (cognitive 710) crates/ruff_linter/src/checkers/ast/analyze/statement.rs:19 — ruff_linter::checkers::ast::analyze::statement::statement has cognitive complexity 710 (threshold 15). Drivers by points: if/else 382 (650 pts), loops 17 (57 pts), boolean chains 2, match/switch 1 (nesting depth added 308). Of this number, 702 points are the body's own statements and 8 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::checkers::ast::analyze::expression::expression (cognitive 653) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:25 — ruff_linter::checkers::ast::analyze::expression::expression has cognitive complexity 653 (threshold 15). Drivers by points: if/else 365 (587 pts), loops 9 (27 pts), boolean chains 26, match/switch 4 (13 pts) (nesting depth added 249). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::flake8_annotations::rules::definition::definition (cognitive 161) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:633 — ruff_linter::rules::flake8_annotations::rules::definition::definition has cognitive complexity 161 (threshold 15). Drivers by points: if/else 50 (134 pts), boolean chains 16, match/switch 2 (8 pts), loops 2 (3 pts) (nesting depth added 91). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::checkers::noqa::check_noqa (cognitive 129) crates/ruff_linter/src/checkers/noqa.rs:28 — ruff_linter::checkers::noqa::check_noqa has cognitive complexity 129 (threshold 15). Drivers by points: if/else 33 (99 pts), boolean chains 14, loops 4 (9 pts), match/switch 2 (7 pts) (nesting depth added 76). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::pylint::rules::non_slot_assignment::is_attributes_not_in_slots (cognitive 128) crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:105 — ruff_linter::rules::pylint::rules::non_slot_assignment::is_attributes_not_in_slots has cognitive complexity 128 (threshold 15). Drivers by points: if/else 28 (98 pts), loops 8 (20 pts), match/switch 2 (6 pts), boolean chains 4 (nesting depth added 86). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::pycodestyle::rules::logical_lines::extraneous_whitespace::extraneous_whitespace (cognitive 114) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:132 — ruff_linter::rules::pycodestyle::rules::logical_lines::extraneous_whitespace::extraneous_whitespace has cognitive complexity 114 (threshold 15). Drivers by points: if/else 21 (103 pts), boolean chains 5, match/switch 2 (5 pts), loops 1 (nesting depth added 85). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::pydocstyle::rules::sections::blanks_and_section_underline (cognitive 107) crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1476 — ruff_linter::rules::pydocstyle::rules::sections::blanks_and_section_underline has cognitive complexity 107 (threshold 15). Drivers by points: if/else 33 (99 pts), loops 2 (6 pts), boolean chains 2 (nesting depth added 70). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::isort::normalize::normalize_imports (cognitive 102) crates/ruff_linter/src/rules/isort/normalize.rs:5 — ruff_linter::rules::isort::normalize::normalize_imports has cognitive complexity 102 (threshold 15). Drivers by points: loops 15 (62 pts), if/else 12 (33 pts), boolean chains 5, match/switch 1 (2 pts) (nesting depth added 69). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • ruff_linter::checkers::ast::analyze::deferred_scopes::deferred_scopes (cognitive 101) crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs:12 — ruff_linter::checkers::ast::analyze::deferred_scopes::deferred_scopes has cognitive complexity 101 (threshold 15). Drivers by points: if/else 44 (90 pts), boolean chains 6, loops 2 (5 pts) (nesting depth added 49). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::pydoclint::rules::check_docstring::check_docstring (cognitive 98) crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:1231 — ruff_linter::rules::pydoclint::rules::check_docstring::check_docstring has cognitive complexity 98 (threshold 15). Drivers by points: if/else 29 (73 pts), loops 3 (10 pts), match/switch 3 (10 pts), boolean chains 5 (nesting depth added 58). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::pycodestyle::rules::literal_comparisons::literal_comparisons (cognitive 96) crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs:207 — ruff_linter::rules::pycodestyle::rules::literal_comparisons::literal_comparisons has cognitive complexity 96 (threshold 15). Drivers by points: if/else 24 (74 pts), match/switch 5 (17 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 63). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::pyflakes::rules::redefined_while_unused::redefined_while_unused (cognitive 87) crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs:96 — ruff_linter::rules::pyflakes::rules::redefined_while_unused::redefined_while_unused has cognitive complexity 87 (threshold 15). Drivers by points: if/else 25 (76 pts), loops 5 (7 pts), boolean chains 4 (nesting depth added 53). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name (cognitive 81) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1717 — ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name has cognitive complexity 81 (threshold 15). Drivers by points: if/else 80 (81 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • ruff_linter::rules::pycodestyle::rules::logical_lines::whitespace_around_named_parameter_equals::whitespace_around_named_parameter_equals (cognitive 80) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_named_parameter_equals.rs:91 — ruff_linter::rules::pycodestyle::rules::logical_lines::whitespace_around_named_parameter_equals::whitespace_around_named_parameter_equals has cognitive complexity 80 (threshold 15). Drivers by points: if/else 15 (63 pts), loops 3 (9 pts), boolean chains 6, match/switch 1 (2 pts) (nesting depth added 55). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::pylint::rules::no_method_decorator::get_undecorated_methods (cognitive 71) crates/ruff_linter/src/rules/pylint/rules/no_method_decorator.rs:103 — ruff_linter::rules::pylint::rules::no_method_decorator::get_undecorated_methods has cognitive complexity 71 (threshold 15). Drivers by points: if/else 15 (56 pts), match/switch 4 (11 pts), boolean chains 2, loops 2 (nesting depth added 48). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::pylint::rules::unnecessary_lambda::unnecessary_lambda (cognitive 64) crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs:74 — ruff_linter::rules::pylint::rules::unnecessary_lambda::unnecessary_lambda has cognitive complexity 64 (threshold 15). Drivers by points: if/else 24 (54 pts), match/switch 3 (5 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::checkers::ast::analyze::definitions::definitions (cognitive 62) crates/ruff_linter/src/checkers/ast/analyze/definitions.rs:19 — ruff_linter::checkers::ast::analyze::definitions::definitions has cognitive complexity 62 (threshold 15). Drivers by points: if/else 32 (56 pts), boolean chains 4, loops 1, match/switch 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::pycodestyle::rules::logical_lines::whitespace_before_comment::whitespace_before_comment (cognitive 58) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_before_comment.rs:172 — ruff_linter::rules::pycodestyle::rules::logical_lines::whitespace_before_comment::whitespace_before_comment has cognitive complexity 58 (threshold 15). Drivers by points: if/else 16 (54 pts), boolean chains 3, loops 1 (nesting depth added 38). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_linter::rules::flake8_bandit::rules::suspicious_imports::suspicious_imports (cognitive 54) crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs:375 — ruff_linter::rules::flake8_bandit::rules::suspicious_imports::suspicious_imports has cognitive complexity 54 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 7 (20 pts), match/switch 4 (10 pts) (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::flake8_type_checking::rules::runtime_import_in_type_checking_block::runtime_import_in_type_checking_block (cognitive 54) crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs:102 — ruff_linter::rules::flake8_type_checking::rules::runtime_import_in_type_checking_block::runtime_import_in_type_checking_block has cognitive complexity 54 (threshold 15). Drivers by points: if/else 14 (36 pts), loops 5 (11 pts), boolean chains 5, match/switch 1 (2 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::pyupgrade::rules::outdated_version_block::outdated_version_block (cognitive 54) crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:92 — ruff_linter::rules::pyupgrade::rules::outdated_version_block::outdated_version_block has cognitive complexity 54 (threshold 15). Drivers by points: if/else 11 (35 pts), match/switch 5 (15 pts), boolean chains 3, loops 1 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::pyupgrade::rules::use_pep604_annotation::non_pep604_annotation (cognitive 54) crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs:148 — ruff_linter::rules::pyupgrade::rules::use_pep604_annotation::non_pep604_annotation has cognitive complexity 54 (threshold 15). Drivers by points: if/else 18 (39 pts), match/switch 3 (7 pts), boolean chains 4, loops 1 (4 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::isort::format_import_block (cognitive 53) crates/ruff_linter/src/rules/isort/mod.rs:154 — ruff_linter::rules::isort::format_import_block has cognitive complexity 53 (threshold 15). Drivers by points: if/else 10 (27 pts), loops 5 (16 pts), match/switch 2 (7 pts), boolean chains 3 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::flake8_bandit::rules::suspicious_function_call::suspicious_function (cognitive 52) crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs:1018 — ruff_linter::rules::flake8_bandit::rules::suspicious_function_call::suspicious_function has cognitive complexity 52 (threshold 15). Drivers by points: if/else 17 (39 pts), boolean chains 6, match/switch 3 (6 pts), loops 1 (nesting depth added 25). Of this number, 39 points are the body's own statements and 13 belong to 4 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_linter::rules::pycodestyle::rules::logical_lines::missing_whitespace_around_operator::missing_whitespace_around_operator (cognitive 50) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/missing_whitespace_around_operator.rs:169 — ruff_linter::rules::pycodestyle::rules::logical_lines::missing_whitespace_around_operator::missing_whitespace_around_operator has cognitive complexity 50 (threshold 15). Drivers by points: if/else 17 (38 pts), boolean chains 6, match/switch 2 (5 pts), loops 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • + 204 more in this group — see findings.md.
D3 · God Classes · MethodTooLong · ×194
  • MethodTooLong: TypeRelationChecker.check_signature_pair_inner crates/ty_python_semantic/src/types/signatures.rs:3100 — MethodTooLong — check_signature_pair_inner runs 1160 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1060 over it, 11.60× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Bindings.evaluate_known_cases crates/ty_python_semantic/src/types/call/bind.rs:1715 — MethodTooLong — evaluate_known_cases runs 1117 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1017 over it, 11.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: SemanticIndexBuilder.visit_stmt_impl crates/ty_python_core/src/builder.rs:3896 — MethodTooLong — visit_stmt_impl runs 1017 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 917 over it, 10.17× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: TypeRelationChecker.check_type_pair crates/ty_python_semantic/src/types/relation.rs:2058 — MethodTooLong — check_type_pair runs 684 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 584 over it, 6.84× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: DisjointnessChecker.check_type_pair_impl crates/ty_python_semantic/src/types/relation.rs:3763 — MethodTooLong — check_type_pair_impl runs 587 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 487 over it, 5.87× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Type.member_lookup_with_policy_and_receiver crates/ty_python_semantic/src/types.rs:6051 — MethodTooLong — member_lookup_with_policy_and_receiver runs 576 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 476 over it, 5.76× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: TypeInferenceBuilder.report_redundant_condition crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:61 — MethodTooLong — report_redundant_condition runs 548 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 448 over it, 5.48× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: TypeInferenceBuilder.infer_type_expression_no_store crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:436 — MethodTooLong — infer_type_expression_no_store runs 536 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 436 over it, 5.36× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: DisplayRepresentation.fmt_detailed crates/ty_python_semantic/src/types/display.rs:1183 — MethodTooLong — fmt_detailed runs 522 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 422 over it, 5.22× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: SpecializationBuilder.infer_map_inner crates/ty_python_semantic/src/types/generics.rs:4147 — MethodTooLong — infer_map_inner runs 514 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 414 over it, 5.14× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: TypeInferenceBuilder.infer_binary_expression_type_impl crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:470 — MethodTooLong — infer_binary_expression_type_impl runs 498 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 398 over it, 4.98× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Checker.visit_stmt crates/ruff_linter/src/checkers/ast/mod.rs:1048 — MethodTooLong — visit_stmt runs 489 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 389 over it, 4.89× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: BindingError.report_diagnostic crates/ty_python_semantic/src/types/call/bind.rs:10621 — MethodTooLong — report_diagnostic runs 488 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 388 over it, 4.88× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: TypeInferenceBuilder.infer_explicit_callable_specialization_impl crates/ty_python_semantic/src/types/infer/builder/subscript.rs:627 — MethodTooLong — infer_explicit_callable_specialization_impl runs 479 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 379 over it, 4.79× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: TypeInferenceBuilder.infer_call_expression_impl crates/ty_python_semantic/src/types/infer/builder.rs:9652 — MethodTooLong — infer_call_expression_impl runs 447 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 347 over it, 4.47× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: TypeInferenceBuilder.infer_parameterized_special_form_type_expression crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2564 — MethodTooLong — infer_parameterized_special_form_type_expression runs 439 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 339 over it, 4.39× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Checker.visit_expr crates/ruff_linter/src/checkers/ast/mod.rs:1781 — MethodTooLong — visit_expr runs 420 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 320 over it, 4.20× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Generator.unparse_stmt crates/ruff_python_codegen/src/generator.rs:248 — MethodTooLong — unparse_stmt runs 382 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 282 over it, 3.82× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: KnownFunction.check_call crates/ty_python_semantic/src/types/infer/builder/function.rs:1627 — MethodTooLong — check_call runs 363 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 263 over it, 3.63× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: ErrorContext.render crates/ty_python_semantic/src/types/relation_error.rs:251 — MethodTooLong — render runs 362 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 262 over it, 3.62× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Generator.unparse_expr crates/ruff_python_codegen/src/generator.rs:942 — MethodTooLong — unparse_expr runs 356 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 256 over it, 3.56× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: Type.bindings_with_receiver crates/ty_python_semantic/src/types.rs:7162 — MethodTooLong — bindings_with_receiver runs 351 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 251 over it, 3.51× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: NarrowingConstraintsBuilder.evaluate_expr_compare crates/ty_python_semantic/src/types/narrow.rs:4047 — MethodTooLong — evaluate_expr_compare runs 348 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 248 over it, 3.48× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: StaticClassLiteral.own_generated_member crates/ty_python_semantic/src/types/class/static_literal.rs:1868 — MethodTooLong — own_generated_member runs 337 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 237 over it, 3.37× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • MethodTooLong: IterationError.report_diagnostic crates/ty_python_semantic/src/types/iteration.rs:774 — MethodTooLong — report_diagnostic runs 319 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 219 over it, 3.19× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • + 169 more in this group — see findings.md.
D3 · God Classes · FileTooLong · ×144
  • FileTooLong: infer/builder.rs crates/ty_python_semantic/src/types/infer/builder.rs — FileTooLong — 8904 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 91% of them inside a single declaration: TypeInferenceBuilder (2 blocks, 306-12904). The bar is 500 significant lines; this is 8404 over it, 17.81× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: src/types.rs crates/ty_python_semantic/src/types.rs — FileTooLong — 8149 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 70% of them inside a single declaration: Type (5 blocks, 2075-11585). The bar is 500 significant lines; this is 7649 over it, 16.30× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: call/bind.rs crates/ty_python_semantic/src/types/call/bind.rs — FileTooLong — 7151 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 6651 over it, 14.30× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/diagnostic.rs crates/ty_python_semantic/src/types/diagnostic.rs — FileTooLong — 4324 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 101 free functions. The bar is 500 significant lines; this is 3824 over it, 8.65× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/signatures.rs crates/ty_python_semantic/src/types/signatures.rs — FileTooLong — 4164 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 3664 over it, 8.33× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/narrow.rs crates/ty_python_semantic/src/types/narrow.rs — FileTooLong — 3747 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 3247 over it, 7.49× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/builder.rs crates/ty_python_core/src/builder.rs — FileTooLong — 3727 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 92% of them inside a single declaration: SemanticIndexBuilder (4 blocks, 237-6043). The bar is 500 significant lines; this is 3227 over it, 7.45× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: types/constraints.rs crates/ty_python_semantic/src/types/constraints.rs — FileTooLong — 3161 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2661 over it, 6.32× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/generics.rs crates/ty_python_semantic/src/types/generics.rs — FileTooLong — 3093 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2593 over it, 6.19× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/relation.rs crates/ty_python_semantic/src/types/relation.rs — FileTooLong — 2843 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2343 over it, 5.69× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/display.rs crates/ty_python_semantic/src/types/display.rs — FileTooLong — 2779 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 2279 over it, 5.56× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: builder/type_expression.rs crates/ty_python_semantic/src/types/infer/builder/type_expression.rs — FileTooLong — 2487 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 98% of them inside a single declaration: TypeInferenceBuilder (59-3711). The bar is 500 significant lines; this is 1987 over it, 4.97× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: types/protocol_class.rs crates/ty_python_semantic/src/types/protocol_class.rs — FileTooLong — 2459 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1959 over it, 4.92× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/options.rs crates/ruff_workspace/src/options.rs — FileTooLong — 2343 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1843 over it, 4.69× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: class/static_literal.rs crates/ty_python_semantic/src/types/class/static_literal.rs — FileTooLong — 2302 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 91% of them inside a single declaration: StaticClassLiteral (4 blocks, 83-3815). The bar is 500 significant lines; this is 1802 over it, 4.60× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: ast/mod.rs crates/ruff_linter/src/checkers/ast/mod.rs — FileTooLong — 2292 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 84% of them inside a single declaration: Checker (6 blocks, 196-3481). The bar is 500 significant lines; this is 1792 over it, 4.58× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: types/typed_dict.rs crates/ty_python_semantic/src/types/typed_dict.rs — FileTooLong — 2146 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), declaring 32 free functions. The bar is 500 significant lines; this is 1646 over it, 4.29× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/nodes.rs crates/ruff_python_ast/src/nodes.rs — FileTooLong — 2141 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1641 over it, 4.28× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: src/use_def.rs crates/ty_python_core/src/use_def.rs — FileTooLong — 2137 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1637 over it, 4.27× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/class.rs crates/ty_python_semantic/src/types/class.rs — FileTooLong — 2115 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1615 over it, 4.23× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: types/tuple.rs crates/ty_python_semantic/src/types/tuple.rs — FileTooLong — 2003 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1503 over it, 4.01× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: class/known.rs crates/ty_python_semantic/src/types/class/known.rs — FileTooLong — 1943 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 96% of them inside a single declaration: KnownClass (2 blocks, 34-2220). The bar is 500 significant lines; this is 1443 over it, 3.89× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: builder/subscript.rs crates/ty_python_semantic/src/types/infer/builder/subscript.rs — FileTooLong — 1825 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), about 92% of them inside a single declaration: TypeInferenceBuilder (67-2565). The bar is 500 significant lines; this is 1325 over it, 3.65× the bar. Moving the declarations that sit BESIDE it into sibling files will not shorten this file. Extract from INSIDE that declaration instead: lift each cohesive group of its body — the parts that share the same inputs and are named together — into its own unit in a sibling file, and have the original call them.
  • FileTooLong: src/completion.rs crates/ty_ide/src/completion.rs — FileTooLong — 1818 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1318 over it, 3.64× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: renderer/render.rs crates/ruff_annotate_snippets/src/renderer/render.rs — FileTooLong — 1774 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted). The bar is 500 significant lines; this is 1274 over it, 3.55× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • + 119 more in this group — see findings.md.
D8 · Code Coverage · Low coverage · ×107
  • Low coverage: crates/mdtest/src/lib.rs crates/mdtest/src/lib.rs:1 — 45.0% line coverage (204/453).
  • Low coverage: crates/ruff/src/commands/add_noqa.rs crates/ruff/src/commands/add_noqa.rs:1 — 0.0% line coverage (0/72).
  • Low coverage: crates/ruff/src/commands/analyze_graph.rs crates/ruff/src/commands/analyze_graph.rs:1 — 0.0% line coverage (0/176).
  • Low coverage: crates/ruff/src/commands/clean.rs crates/ruff/src/commands/clean.rs:1 — 0.0% line coverage (0/18).
  • Low coverage: crates/ruff/src/commands/completions/config.rs crates/ruff/src/commands/completions/config.rs:1 — 23.5% line coverage (20/85).
  • Low coverage: crates/ruff/src/commands/format.rs crates/ruff/src/commands/format.rs:1 — 37.3% line coverage (266/713).
  • Low coverage: crates/ruff/src/commands/format_stdin.rs crates/ruff/src/commands/format_stdin.rs:1 — 49.4% line coverage (41/83).
  • Low coverage: crates/ruff/src/commands/linter.rs crates/ruff/src/commands/linter.rs:1 — 0.0% line coverage (0/34).
  • Low coverage: crates/ruff/src/commands/server.rs crates/ruff/src/commands/server.rs:1 — 0.0% line coverage (0/7).
  • Low coverage: crates/ruff/src/commands/show_settings.rs crates/ruff/src/commands/show_settings.rs:1 — 0.0% line coverage (0/22).
  • Low coverage: crates/ruff/src/commands/version.rs crates/ruff/src/commands/version.rs:1 — 0.0% line coverage (0/8).
  • Low coverage: crates/ruff/src/main.rs crates/ruff/src/main.rs:1 — 0.0% line coverage (0/25).
  • Low coverage: crates/ruff/src/stdin.rs crates/ruff/src/stdin.rs:1 — 45.5% line coverage (5/11).
  • Low coverage: crates/ruff_annotate_snippets/src/lib.rs crates/ruff_annotate_snippets/src/lib.rs:1 — 0.0% line coverage (0/3).
  • Low coverage: crates/ruff_cache/src/globset.rs crates/ruff_cache/src/globset.rs:1 — 0.0% line coverage (0/6).
  • Low coverage: crates/ruff_command_line/src/lib.rs crates/ruff_command_line/src/lib.rs:1 — 12.0% line coverage (3/25).
  • Low coverage: crates/ruff_dev/src/format_dev.rs crates/ruff_dev/src/format_dev.rs:1 — 5.3% line coverage (26/488).
  • Low coverage: crates/ruff_dev/src/generate_default_rules.rs crates/ruff_dev/src/generate_default_rules.rs:1 — 0.0% line coverage (0/47).
  • Low coverage: crates/ruff_dev/src/generate_docs.rs crates/ruff_dev/src/generate_docs.rs:1 — 27.7% line coverage (43/155).
  • Low coverage: crates/ruff_dev/src/generate_options.rs crates/ruff_dev/src/generate_options.rs:1 — 0.0% line coverage (0/131).
  • Low coverage: crates/ruff_dev/src/generate_rules_table.rs crates/ruff_dev/src/generate_rules_table.rs:1 — 0.0% line coverage (0/141).
  • Low coverage: crates/ruff_dev/src/generate_ty_env_vars_reference.rs crates/ruff_dev/src/generate_ty_env_vars_reference.rs:1 — 0.0% line coverage (0/64).
  • Low coverage: crates/ruff_dev/src/main.rs crates/ruff_dev/src/main.rs:1 — 0.0% line coverage (0/32).
  • Low coverage: crates/ruff_dev/src/print_ast.rs crates/ruff_dev/src/print_ast.rs:1 — 0.0% line coverage (0/12).
  • Low coverage: crates/ruff_dev/src/print_cst.rs crates/ruff_dev/src/print_cst.rs:1 — 0.0% line coverage (0/8).
  • + 82 more in this group — see findings.md.
D1 · Cyclomatic Complexity · ruff_linter · ×102
  • ruff_linter::checkers::ast::analyze::expression::expression (cyclomatic 431) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:25 — ruff_linter::checkers::ast::analyze::expression::expression has cyclomatic complexity 431 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::checkers::ast::analyze::statement::statement (cyclomatic 416) crates/ruff_linter/src/checkers/ast/analyze/statement.rs:19 — ruff_linter::checkers::ast::analyze::statement::statement has cyclomatic complexity 416 (threshold 15). Of this number, 414 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::airflow::rules::moved_to_provider_in_3::check_names_moved_to_provider (cyclomatic 112) crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:112 — ruff_linter::rules::airflow::rules::moved_to_provider_in_3::check_names_moved_to_provider has cyclomatic complexity 112 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name (cyclomatic 81) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1717 — ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name has cyclomatic complexity 81 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • ruff_linter::rules::numpy::rules::numpy_2_0_deprecation::numpy_2_0_deprecation (cyclomatic 78) crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:162 — ruff_linter::rules::numpy::rules::numpy_2_0_deprecation::numpy_2_0_deprecation has cyclomatic complexity 78 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_linter::rules::airflow::rules::removal_in_3::check_name (cyclomatic 73) crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:655 — ruff_linter::rules::airflow::rules::removal_in_3::check_name has cyclomatic complexity 73 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_linter::rules::flake8_annotations::rules::definition::definition (cyclomatic 69) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:633 — ruff_linter::rules::flake8_annotations::rules::definition::definition has cyclomatic complexity 69 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::flake8_bandit::rules::suspicious_imports::suspicious_imports (cyclomatic 53) crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_imports.rs:375 — ruff_linter::rules::flake8_bandit::rules::suspicious_imports::suspicious_imports has cyclomatic complexity 53 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_linter::checkers::ast::analyze::deferred_scopes::deferred_scopes (cyclomatic 52) crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs:12 — ruff_linter::checkers::ast::analyze::deferred_scopes::deferred_scopes has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::flake8_bandit::rules::suspicious_function_call::suspicious_function (cyclomatic 51) crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs:1018 — ruff_linter::rules::flake8_bandit::rules::suspicious_function_call::suspicious_function has cyclomatic complexity 51 (threshold 15). Of this number, 41 points are the body's own statements and 10 belong to 4 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::checkers::noqa::check_noqa (cyclomatic 47) crates/ruff_linter/src/checkers/noqa.rs:28 — ruff_linter::checkers::noqa::check_noqa has cyclomatic complexity 47 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::pydoclint::rules::check_docstring::check_docstring (cyclomatic 44) crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:1231 — ruff_linter::rules::pydoclint::rules::check_docstring::check_docstring has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::pylint::rules::non_slot_assignment::is_attributes_not_in_slots (cyclomatic 44) crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:105 — ruff_linter::rules::pylint::rules::non_slot_assignment::is_attributes_not_in_slots has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::checkers::ast::analyze::definitions::definitions (cyclomatic 39) crates/ruff_linter/src/checkers/ast/analyze/definitions.rs:19 — ruff_linter::checkers::ast::analyze::definitions::definitions has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::airflow::rules::runtime_value_in_dag_or_task::find_runtime_varying_call (cyclomatic 39) crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs:99 — ruff_linter::rules::airflow::rules::runtime_value_in_dag_or_task::find_runtime_varying_call has cyclomatic complexity 39 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_linter::rules::flake8_bandit::rules::hardcoded_sql_expression::is_explicit_concatenation (cyclomatic 39) crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_sql_expression.rs:142 — ruff_linter::rules::flake8_bandit::rules::hardcoded_sql_expression::is_explicit_concatenation has cyclomatic complexity 39 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_linter::rules::perflint::rules::manual_list_comprehension::manual_list_comprehension (cyclomatic 35) crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:99 — ruff_linter::rules::perflint::rules::manual_list_comprehension::manual_list_comprehension has cyclomatic complexity 35 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • ruff_linter::rules::pycodestyle::rules::logical_lines::extraneous_whitespace::extraneous_whitespace (cyclomatic 35) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:132 — ruff_linter::rules::pycodestyle::rules::logical_lines::extraneous_whitespace::extraneous_whitespace has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::linter::check_path (cyclomatic 34) crates/ruff_linter/src/linter.rs:121 — ruff_linter::linter::check_path has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::pyflakes::rules::redefined_while_unused::redefined_while_unused (cyclomatic 34) crates/ruff_linter/src/rules/pyflakes/rules/redefined_while_unused.rs:96 — ruff_linter::rules::pyflakes::rules::redefined_while_unused::redefined_while_unused has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::pyupgrade::rules::outdated_version_block::outdated_version_block (cyclomatic 34) crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:92 — ruff_linter::rules::pyupgrade::rules::outdated_version_block::outdated_version_block has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::pyupgrade::rules::super_call_with_parameters::super_call_with_parameters (cyclomatic 34) crates/ruff_linter/src/rules/pyupgrade/rules/super_call_with_parameters.rs:73 — ruff_linter::rules::pyupgrade::rules::super_call_with_parameters::super_call_with_parameters has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_linter::rules::airflow::rules::removal_in_3::check_method (cyclomatic 32) crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:545 — ruff_linter::rules::airflow::rules::removal_in_3::check_method has cyclomatic complexity 32 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_linter::rules::isort::normalize::normalize_imports (cyclomatic 31) crates/ruff_linter/src/rules/isort/normalize.rs:5 — ruff_linter::rules::isort::normalize::normalize_imports has cyclomatic complexity 31 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • ruff_linter::rules::pycodestyle::rules::compound_statements::compound_statements (cyclomatic 31) crates/ruff_linter/src/rules/pycodestyle/rules/compound_statements.rs:105 — ruff_linter::rules::pycodestyle::rules::compound_statements::compound_statements has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • + 77 more in this group — see findings.md.
D3 · God Classes · FunctionTooLong · ×95
  • FunctionTooLong: ruff_linter::checkers::ast::analyze::statement::statement crates/ruff_linter/src/checkers/ast/analyze/statement.rs:19 — FunctionTooLong — ruff_linter::checkers::ast::analyze::statement::statement runs 1161 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1061 over it, 11.61× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::checkers::ast::analyze::expression::expression crates/ruff_linter/src/checkers/ast/analyze/expression.rs:25 — FunctionTooLong — ruff_linter::checkers::ast::analyze::expression::expression runs 1135 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 1035 over it, 11.35× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::codes::code_to_rule crates/ruff_linter/src/codes.rs:238 — FunctionTooLong — ruff_linter::codes::code_to_rule runs 1016 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 916 over it, 10.16× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::rules::airflow::rules::moved_to_provider_in_3::check_names_moved_to_provider crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:112 — FunctionTooLong — ruff_linter::rules::airflow::rules::moved_to_provider_in_3::check_names_moved_to_provider runs 851 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 751 over it, 8.51× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:144 — FunctionTooLong — ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions runs 642 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 542 over it, 6.42× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ty_python_semantic::types::overrides::check_class_declaration crates/ty_python_semantic/src/types/overrides.rs:729 — FunctionTooLong — ty_python_semantic::types::overrides::check_class_declaration runs 429 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 329 over it, 4.29× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::rules::numpy::rules::numpy_2_0_deprecation::numpy_2_0_deprecation crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:162 — FunctionTooLong — ruff_linter::rules::numpy::rules::numpy_2_0_deprecation::numpy_2_0_deprecation runs 401 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 301 over it, 4.01× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ty_python_semantic::types::infer::comparisons::infer_binary_type_comparison_inner crates/ty_python_semantic/src/types/infer/comparisons.rs:840 — FunctionTooLong — ty_python_semantic::types::infer::comparisons::infer_binary_type_comparison_inner runs 340 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 240 over it, 3.40× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::rules::airflow::rules::removal_in_3::check_name crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:655 — FunctionTooLong — ruff_linter::rules::airflow::rules::removal_in_3::check_name runs 289 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 189 over it, 2.89× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ty_test::run_test crates/ty_test/src/lib.rs:90 — FunctionTooLong — ty_test::run_test runs 267 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 167 over it, 2.67× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1717 — FunctionTooLong — ruff_linter::checkers::ast::analyze::expression::call_with_qualified_name runs 264 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 164 over it, 2.64× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::rules::flake8_annotations::rules::definition::definition crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:633 — FunctionTooLong — ruff_linter::rules::flake8_annotations::rules::definition::definition runs 229 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 129 over it, 2.29× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::checkers::ast::analyze::definitions::definitions crates/ruff_linter/src/checkers/ast/analyze/definitions.rs:19 — FunctionTooLong — ruff_linter::checkers::ast::analyze::definitions::definitions runs 228 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 128 over it, 2.28× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_python_ast::visitor::transformer::walk_expr crates/ruff_python_ast/src/visitor/transformer.rs:349 — FunctionTooLong — ruff_python_ast::visitor::transformer::walk_expr runs 225 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 125 over it, 2.25× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_python_ast::visitor::walk_expr crates/ruff_python_ast/src/visitor.rs:362 — FunctionTooLong — ruff_python_ast::visitor::walk_expr runs 218 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 118 over it, 2.18× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ty_python_semantic::types::enums::enum_metadata crates/ty_python_semantic/src/types/enums.rs:1005 — FunctionTooLong — ty_python_semantic::types::enums::enum_metadata runs 214 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 114 over it, 2.14× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_python_ast::helpers::any_over_stmt crates/ruff_python_ast/src/helpers.rs:533 — FunctionTooLong — ruff_python_ast::helpers::any_over_stmt runs 212 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 112 over it, 2.12× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: rule-filters.document$.subscribe() docs/js/rule-filters.js:4 — FunctionTooLong — document$.subscribe() runs 199 significant lines (blank, comment-only and punctuation-only lines excluded) in one body. The bar is 100 significant lines; this is 99 over it, 1.99× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff::check crates/ruff/src/lib.rs:237 — FunctionTooLong — ruff::check runs 190 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 90 over it, 1.90× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::checkers::noqa::check_noqa crates/ruff_linter/src/checkers/noqa.rs:28 — FunctionTooLong — ruff_linter::checkers::noqa::check_noqa runs 185 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 85 over it, 1.85× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::rules::isort::order::order_imports crates/ruff_linter/src/rules/isort/order.rs:10 — FunctionTooLong — ruff_linter::rules::isort::order::order_imports runs 185 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 85 over it, 1.85× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ty_python_semantic::types::diagnostic::register_lints crates/ty_python_semantic/src/types/diagnostic.rs:70 — FunctionTooLong — ty_python_semantic::types::diagnostic::register_lints runs 182 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 82 over it, 1.82× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::checkers::ast::analyze::deferred_scopes::deferred_scopes crates/ruff_linter/src/checkers/ast/analyze/deferred_scopes.rs:12 — FunctionTooLong — ruff_linter::checkers::ast::analyze::deferred_scopes::deferred_scopes runs 180 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 80 over it, 1.80× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_linter::rules::flake8_bandit::rules::suspicious_function_call::suspicious_function crates/ruff_linter/src/rules/flake8_bandit/rules/suspicious_function_call.rs:1018 — FunctionTooLong — ruff_linter::rules::flake8_bandit::rules::suspicious_function_call::suspicious_function runs 179 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 79 over it, 1.79× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • FunctionTooLong: ruff_python_ast::visitor::walk_stmt crates/ruff_python_ast/src/visitor.rs:135 — FunctionTooLong — ruff_python_ast::visitor::walk_stmt runs 178 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted) in one body. The bar is 100 significant lines; this is 78 over it, 1.78× the bar. This is length, not branching: a long straight-line body scores low on complexity and is still read whole to change any part of it, so the complexity numbers beside this row neither confirm nor excuse it. To reduce it, extract each cohesive step of the body — the runs of statements that work on the same values and would earn the same name — into its own named unit, and have this one call them in order.
  • + 70 more in this group — see findings.md.
D15 · Churn × Complexity Hotspots · Hotspot · ×90
  • Hotspot: crates/ty_python_semantic/src/types/call/bind.rs crates/ty_python_semantic/src/types/call/bind.rs:1715 — crates/ty_python_semantic/src/types/call/bind.rs changed 90 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 254 in Bindings::evaluate_known_cases at line 1715. 4 of those changes were fix/bug commits, and the other 86 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/call/bind.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types.rs crates/ty_python_semantic/src/types.rs:6051 — crates/ty_python_semantic/src/types.rs changed 120 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 131 in Type::member_lookup_with_policy_and_receiver at line 6051. 10 of those changes were fix/bug commits, and the other 110 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/builder.rs crates/ty_python_semantic/src/types/infer/builder.rs:9652 — crates/ty_python_semantic/src/types/infer/builder.rs changed 137 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 109 in TypeInferenceBuilder::infer_call_expression_impl at line 9652. 6 of those changes were fix/bug commits, and the other 131 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/builder.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/signatures.rs crates/ty_python_semantic/src/types/signatures.rs:3100 — crates/ty_python_semantic/src/types/signatures.rs changed 59 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 236 in TypeRelationChecker::check_signature_pair_inner at line 3100. 3 of those changes were fix/bug commits, and the other 56 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/signatures.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/relation.rs crates/ty_python_semantic/src/types/relation.rs:2058 — crates/ty_python_semantic/src/types/relation.rs changed 61 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 192 in TypeRelationChecker::check_type_pair at line 2058. 8 of those changes were fix/bug commits, and the other 53 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/relation.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/generics.rs crates/ty_python_semantic/src/types/generics.rs:4147 — crates/ty_python_semantic/src/types/generics.rs changed 72 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 122 in SpecializationBuilder::infer_map_inner at line 4147. 5 of those changes were fix/bug commits, and the other 67 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/generics.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_core/src/builder.rs crates/ty_python_core/src/builder.rs:3896 — crates/ty_python_core/src/builder.rs changed 33 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 172 in SemanticIndexBuilder::visit_stmt_impl at line 3896. 3 of those changes were fix/bug commits, and the other 30 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_core/src/builder.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ruff_linter/src/checkers/ast/analyze/expression.rs crates/ruff_linter/src/checkers/ast/analyze/expression.rs:25 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 431 in ruff_linter::checkers::ast::analyze::expression::expression at line 25. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ruff_linter/src/checkers/ast/analyze/expression.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/builder/type_expression.rs crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2564 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs changed 31 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 109 in TypeInferenceBuilder::infer_parameterized_special_form_type_expression at line 2564. 3 of those changes were fix/bug commits, and the other 28 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/builder/type_expression.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/narrow.rs crates/ty_python_semantic/src/types/narrow.rs:4047 — crates/ty_python_semantic/src/types/narrow.rs changed 43 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 78 in NarrowingConstraintsBuilder::evaluate_expr_compare at line 4047. 4 of those changes were fix/bug commits, and the other 39 changed it for other reasons — this file is under both repair and feature pressure. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/narrow.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/class/static_literal.rs crates/ty_python_semantic/src/types/class/static_literal.rs:1868 — crates/ty_python_semantic/src/types/class/static_literal.rs changed 47 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 70 in StaticClassLiteral::own_generated_member at line 1868. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/class/static_literal.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:61 — crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs changed 27 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 106 in TypeInferenceBuilder::report_redundant_condition at line 61. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:144 — crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 168 in ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions at line 144. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/overrides.rs crates/ty_python_semantic/src/types/overrides.rs:729 — crates/ty_python_semantic/src/types/overrides.rs changed 26 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 96 in ty_python_semantic::types::overrides::check_class_declaration at line 729. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/overrides.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/display.rs crates/ty_python_semantic/src/types/display.rs:1183 — crates/ty_python_semantic/src/types/display.rs changed 22 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 111 in DisplayRepresentation::fmt_detailed at line 1183. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/display.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/builder/function.rs crates/ty_python_semantic/src/types/infer/builder/function.rs:1627 — crates/ty_python_semantic/src/types/infer/builder/function.rs changed 28 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 80 in KnownFunction::check_call at line 1627. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/builder/function.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/builder/subscript.rs crates/ty_python_semantic/src/types/infer/builder/subscript.rs:627 — crates/ty_python_semantic/src/types/infer/builder/subscript.rs changed 23 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 80 in TypeInferenceBuilder::infer_explicit_callable_specialization_impl at line 627. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/builder/subscript.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/set_theoretic/builder.rs crates/ty_python_semantic/src/types/set_theoretic/builder.rs:812 — crates/ty_python_semantic/src/types/set_theoretic/builder.rs changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 74 in UnionBuilder::add_in_place_impl at line 812. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/set_theoretic/builder.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ruff_linter/src/checkers/ast/mod.rs crates/ruff_linter/src/checkers/ast/mod.rs:1781 — crates/ruff_linter/src/checkers/ast/mod.rs changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 124 in Checker::visit_expr at line 1781. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ruff_linter/src/checkers/ast/mod.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/diagnostic.rs crates/ty_python_semantic/src/types/diagnostic.rs:5277 — crates/ty_python_semantic/src/types/diagnostic.rs changed 54 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 24 in ty_python_semantic::types::diagnostic::report_incompatible_method_override at line 5277. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/diagnostic.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_ide/src/completion.rs crates/ty_ide/src/completion.rs:2698 — crates/ty_ide/src/completion.rs changed 16 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 78 in ImportStatement::detect at line 2698. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_ide/src/completion.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/constraints.rs crates/ty_python_semantic/src/types/constraints.rs:3887 — crates/ty_python_semantic/src/types/constraints.rs changed 51 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 23 in CandidateSolutions::compute_simple_bound_conjunction at line 3887. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/constraints.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:470 — crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 85 in TypeInferenceBuilder::infer_binary_expression_type_impl at line 470. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/callable.rs crates/ty_python_semantic/src/types/callable.rs:232 — crates/ty_python_semantic/src/types/callable.rs changed 23 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 42 in Type::try_upcast_to_callable_impl at line 232. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/callable.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: crates/ty_python_semantic/src/types/infer/comparisons.rs crates/ty_python_semantic/src/types/infer/comparisons.rs:840 — crates/ty_python_semantic/src/types/infer/comparisons.rs changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 66 in ty_python_semantic::types::infer::comparisons::infer_binary_type_comparison_inner at line 840. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ty_python_semantic/src/types/infer/comparisons.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • + 65 more in this group — see findings.md.
D2 · Cognitive Complexity · ty_python_semantic · ×79
  • ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions (cognitive 366) crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:144 — ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions has cognitive complexity 366 (threshold 15). Drivers by points: if/else 106 (272 pts), loops 17 (49 pts), boolean chains 27, match/switch 7 (18 pts) (nesting depth added 209). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ty_python_semantic::types::overrides::check_class_declaration (cognitive 200) crates/ty_python_semantic/src/types/overrides.rs:729 — ty_python_semantic::types::overrides::check_class_declaration has cognitive complexity 200 (threshold 15). Drivers by points: if/else 58 (159 pts), boolean chains 31, match/switch 3 (8 pts), loops 1 (2 pts) (nesting depth added 107). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ty_python_semantic::types::infer::builder::post_inference::overloaded_function::check_overloaded_function (cognitive 89) crates/ty_python_semantic/src/types/infer/builder/post_inference/overloaded_function.rs:35 — ty_python_semantic::types::infer::builder::post_inference::overloaded_function::check_overloaded_function has cognitive complexity 89 (threshold 15). Drivers by points: if/else 31 (69 pts), loops 6 (15 pts), boolean chains 5 (nesting depth added 47). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::suppression::unused::check_unused_suppressions (cognitive 59) crates/ty_python_semantic/src/suppression/unused.rs:20 — ty_python_semantic::suppression::unused::check_unused_suppressions has cognitive complexity 59 (threshold 15). Drivers by points: if/else 15 (39 pts), loops 4 (9 pts), boolean chains 7, match/switch 2 (4 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::ide_support::unused_bindings::unused_bindings (cognitive 55) crates/ty_python_semantic/src/types/ide_support/unused_bindings.rs:105 — ty_python_semantic::types::ide_support::unused_bindings::unused_bindings has cognitive complexity 55 (threshold 15). Drivers by points: if/else 12 (38 pts), boolean chains 10, loops 3 (7 pts) (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::enums::enum_metadata (cognitive 50) crates/ty_python_semantic/src/types/enums.rs:1005 — ty_python_semantic::types::enums::enum_metadata has cognitive complexity 50 (threshold 15). Drivers by points: if/else 17 (33 pts), match/switch 7 (12 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::diagnostic::report_inconsistent_generic_bases (cognitive 49) crates/ty_python_semantic/src/types/diagnostic.rs:5105 — ty_python_semantic::types::diagnostic::report_inconsistent_generic_bases has cognitive complexity 49 (threshold 15). Drivers by points: if/else 11 (41 pts), loops 3 (6 pts), match/switch 1 (2 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::fixes::fix_all (cognitive 45) crates/ty_python_semantic/src/fixes.rs:80 — ty_python_semantic::fixes::fix_all has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (34 pts), loops 6 (8 pts), match/switch 1 (3 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::typed_dict::validate_merged_dict_literal (cognitive 45) crates/ty_python_semantic/src/types/typed_dict.rs:2874 — ty_python_semantic::types::typed_dict::validate_merged_dict_literal has cognitive complexity 45 (threshold 15). Drivers by points: if/else 12 (44 pts), loops 1 (nesting depth added 32). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ty_python_semantic::types::infer::comparisons::infer_binary_type_comparison_inner (cognitive 42) crates/ty_python_semantic/src/types/infer/comparisons.rs:840 — ty_python_semantic::types::infer::comparisons::infer_binary_type_comparison_inner has cognitive complexity 42 (threshold 15). Drivers by points: match/switch 9 (17 pts), if/else 9 (12 pts), loops 4 (10 pts), boolean chains 3 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::typed_dict::extract_unpacked_typed_dict_from_value_type (cognitive 41) crates/ty_python_semantic/src/types/typed_dict.rs:1924 — ty_python_semantic::types::typed_dict::extract_unpacked_typed_dict_from_value_type has cognitive complexity 41 (threshold 15). Drivers by points: if/else 9 (25 pts), loops 6 (15 pts), match/switch 1 (nesting depth added 25). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ty_python_semantic::reachability::analyze_single_pattern_predicate_kind (cognitive 40) crates/ty_python_semantic/src/reachability.rs:1736 — ty_python_semantic::reachability::analyze_single_pattern_predicate_kind has cognitive complexity 40 (threshold 15). Drivers by points: if/else 21 (31 pts), match/switch 4 (7 pts), boolean chains 2 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ty_python_semantic::types::overrides::check_inherited_method_conflict (cognitive 40) crates/ty_python_semantic/src/types/overrides.rs:350 — ty_python_semantic::types::overrides::check_inherited_method_conflict has cognitive complexity 40 (threshold 15). Drivers by points: if/else 18 (36 pts), boolean chains 3, loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::generics::find_typevar_binding (cognitive 39) crates/ty_python_semantic/src/types/generics.rs:146 — ty_python_semantic::types::generics::find_typevar_binding has cognitive complexity 39 (threshold 15). Drivers by points: if/else 10 (24 pts), boolean chains 6, match/switch 2 (6 pts), loops 2 (3 pts) (nesting depth added 19). Of this number, 38 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::infer::builder::paramspec_validation::validate_paramspec_components (cognitive 39) crates/ty_python_semantic/src/types/infer/builder/paramspec_validation.rs:22 — ty_python_semantic::types::infer::builder::paramspec_validation::validate_paramspec_components has cognitive complexity 39 (threshold 15). Drivers by points: if/else 18 (34 pts), boolean chains 4, match/switch 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::set_theoretic::builder::normalize_enum_complement_unions (cognitive 39) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:316 — ty_python_semantic::types::set_theoretic::builder::normalize_enum_complement_unions has cognitive complexity 39 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 5 (12 pts), boolean chains 1 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::infer::builder::post_inference::static_class::check_class_namespace_against_metaclass_members (cognitive 38) crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:1346 — ty_python_semantic::types::infer::builder::post_inference::static_class::check_class_namespace_against_metaclass_members has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (34 pts), loops 2 (4 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::instance::protocol_materialization_is_noop_with_type_parameters (cognitive 37) crates/ty_python_semantic/src/types/instance.rs:608 — ty_python_semantic::types::instance::protocol_materialization_is_noop_with_type_parameters has cognitive complexity 37 (threshold 15). Drivers by points: if/else 19 (27 pts), boolean chains 7, match/switch 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::overrides::check_inherited_conflicts (cognitive 36) crates/ty_python_semantic/src/types/overrides.rs:172 — ty_python_semantic::types::overrides::check_inherited_conflicts has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (29 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::dedicated::pydantic::lax_input_type_impl (cognitive 35) crates/ty_python_semantic/src/types/dedicated/pydantic.rs:1144 — ty_python_semantic::types::dedicated::pydantic::lax_input_type_impl has cognitive complexity 35 (threshold 15). Drivers by points: if/else 24 (32 pts), match/switch 2, boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::overrides::attributes::check_inherited_conflict (cognitive 35) crates/ty_python_semantic/src/types/overrides/attributes.rs:998 — ty_python_semantic::types::overrides::attributes::check_inherited_conflict has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 2 (5 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::diagnostic::report_dynamic_function_decorator_return (cognitive 34) crates/ty_python_semantic/src/types/diagnostic.rs:2768 — ty_python_semantic::types::diagnostic::report_dynamic_function_decorator_return has cognitive complexity 34 (threshold 15). Drivers by points: if/else 17 (25 pts), match/switch 4 (5 pts), boolean chains 4 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::infer::builder::post_inference::typed_dict::validate_typed_dict_openness (cognitive 34) crates/ty_python_semantic/src/types/infer/builder/post_inference/typed_dict.rs:149 — ty_python_semantic::types::infer::builder::post_inference::typed_dict::validate_typed_dict_openness has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (23 pts), boolean chains 5, match/switch 2 (5 pts), loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::definition_resolution::definitions_for_attribute (cognitive 32) crates/ty_python_semantic/src/types/definition_resolution.rs:333 — ty_python_semantic::types::definition_resolution::definitions_for_attribute has cognitive complexity 32 (threshold 15). Drivers by points: if/else 6 (16 pts), match/switch 6 (10 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_python_semantic::types::diagnostic::report_incompatible_method_override (cognitive 32) crates/ty_python_semantic/src/types/diagnostic.rs:5277 — ty_python_semantic::types::diagnostic::report_incompatible_method_override has cognitive complexity 32 (threshold 15). Drivers by points: if/else 13 (18 pts), match/switch 4 (7 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • + 54 more in this group — see findings.md.
D2 · Cognitive Complexity · TypeInferenceBuilder · ×79
  • TypeInferenceBuilder::infer_parameterized_special_form_type_expression (cognitive 225) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2564 — TypeInferenceBuilder::infer_parameterized_special_form_type_expression has cognitive complexity 225 (threshold 15). Drivers by points: if/else 87 (180 pts), loops 8 (29 pts), match/switch 5 (9 pts), boolean chains 7 (nesting depth added 118). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • TypeInferenceBuilder::report_redundant_condition (cognitive 204) crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:61 — TypeInferenceBuilder::report_redundant_condition has cognitive complexity 204 (threshold 15). Drivers by points: if/else 84 (152 pts), boolean chains 26, match/switch 9 (20 pts), loops 2 (6 pts) (nesting depth added 83). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_call_expression_impl (cognitive 204) crates/ty_python_semantic/src/types/infer/builder.rs:9652 — TypeInferenceBuilder::infer_call_expression_impl has cognitive complexity 204 (threshold 15). Drivers by points: if/else 61 (141 pts), match/switch 11 (26 pts), boolean chains 24, loops 4 (13 pts) (nesting depth added 104). Of this number, 198 points are the body's own statements and 6 belong to one function item inside it that branches. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_explicit_callable_specialization_impl (cognitive 175) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:627 — TypeInferenceBuilder::infer_explicit_callable_specialization_impl has cognitive complexity 175 (threshold 15). Drivers by points: if/else 60 (130 pts), boolean chains 18, match/switch 6 (14 pts), loops 6 (13 pts) (nesting depth added 85). Of this number, 174 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_type_expression_no_store (cognitive 163) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:436 — TypeInferenceBuilder::infer_type_expression_no_store has cognitive complexity 163 (threshold 15). Drivers by points: if/else 58 (138 pts), boolean chains 10, match/switch 4 (8 pts), loops 2 (7 pts) (nesting depth added 89). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • TypeInferenceBuilder::infer_annotated_assignment_definition (cognitive 135) crates/ty_python_semantic/src/types/infer/builder.rs:4751 — TypeInferenceBuilder::infer_annotated_assignment_definition has cognitive complexity 135 (threshold 15). Drivers by points: if/else 45 (100 pts), match/switch 6 (20 pts), boolean chains 13, loops 1 (2 pts) (nesting depth added 70). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_subscript_type_expression (cognitive 132) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2029 — TypeInferenceBuilder::infer_subscript_type_expression has cognitive complexity 132 (threshold 15). Drivers by points: if/else 42 (124 pts), match/switch 4 (8 pts) (nesting depth added 86). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • TypeInferenceBuilder::validate_subscript_assignment_impl (cognitive 126) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:1837 — TypeInferenceBuilder::validate_subscript_assignment_impl has cognitive complexity 126 (threshold 15). Drivers by points: if/else 31 (101 pts), boolean chains 11, match/switch 4 (8 pts), loops 3 (6 pts) (nesting depth added 77). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_collection_literal_impl (cognitive 120) crates/ty_python_semantic/src/types/infer/builder.rs:8063 — TypeInferenceBuilder::infer_collection_literal_impl has cognitive complexity 120 (threshold 15). Drivers by points: if/else 33 (79 pts), loops 12 (29 pts), boolean chains 10, match/switch 1 (2 pts) (nesting depth added 64). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::validate_typevar_default (cognitive 117) crates/ty_python_semantic/src/types/infer/builder/typevar.rs:166 — TypeInferenceBuilder::validate_typevar_default has cognitive complexity 117 (threshold 15). Drivers by points: if/else 36 (104 pts), loops 2 (8 pts), match/switch 3 (4 pts), boolean chains 1 (nesting depth added 75). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_namedtuple_call_expression (cognitive 101) crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:30 — TypeInferenceBuilder::infer_namedtuple_call_expression has cognitive complexity 101 (threshold 15). Drivers by points: if/else 27 (62 pts), match/switch 9 (16 pts), boolean chains 15, loops 5 (8 pts) (nesting depth added 45). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_function_definition (cognitive 92) crates/ty_python_semantic/src/types/infer/builder/function.rs:397 — TypeInferenceBuilder::infer_function_definition has cognitive complexity 92 (threshold 15). Drivers by points: if/else 26 (43 pts), match/switch 11 (29 pts), boolean chains 11, loops 5 (9 pts) (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_typealiastype_assignment_deferred (cognitive 78) crates/ty_python_semantic/src/types/infer/builder.rs:4311 — TypeInferenceBuilder::infer_typealiastype_assignment_deferred has cognitive complexity 78 (threshold 15). Drivers by points: if/else 23 (66 pts), loops 3 (5 pts), boolean chains 4, match/switch 1 (3 pts) (nesting depth added 47). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::validate_subscript_deletion_impl (cognitive 76) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:2288 — TypeInferenceBuilder::validate_subscript_deletion_impl has cognitive complexity 76 (threshold 15). Drivers by points: if/else 20 (62 pts), match/switch 3 (6 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 47). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_attribute_load_impl (cognitive 76) crates/ty_python_semantic/src/types/infer/builder.rs:11269 — TypeInferenceBuilder::infer_attribute_load_impl has cognitive complexity 76 (threshold 15). Drivers by points: if/else 26 (58 pts), match/switch 4 (8 pts), boolean chains 5, loops 2 (5 pts) (nesting depth added 39). Of this number, 72 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::validate_attribute_deletion (cognitive 74) crates/ty_python_semantic/src/types/infer/builder.rs:3159 — TypeInferenceBuilder::validate_attribute_deletion has cognitive complexity 74 (threshold 15). Drivers by points: if/else 17 (43 pts), match/switch 8 (20 pts), boolean chains 9, loops 1 (2 pts) (nesting depth added 39). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • TypeInferenceBuilder::infer_binary_expression_type_impl (cognitive 71) crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:470 — TypeInferenceBuilder::infer_binary_expression_type_impl has cognitive complexity 71 (threshold 15). Drivers by points: if/else 23 (46 pts), match/switch 7 (13 pts), boolean chains 12 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_typeddict_call_expression (cognitive 71) crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:73 — TypeInferenceBuilder::infer_typeddict_call_expression has cognitive complexity 71 (threshold 15). Drivers by points: if/else 24 (43 pts), loops 7 (16 pts), boolean chains 8, match/switch 3 (4 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_class_definition (cognitive 70) crates/ty_python_semantic/src/types/infer/builder/class.rs:104 — TypeInferenceBuilder::infer_class_definition has cognitive complexity 70 (threshold 15). Drivers by points: if/else 25 (48 pts), match/switch 5 (9 pts), loops 5 (8 pts), boolean chains 5 (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_function_body (cognitive 70) crates/ty_python_semantic/src/types/infer/builder/function.rs:164 — TypeInferenceBuilder::infer_function_body has cognitive complexity 70 (threshold 15). Drivers by points: if/else 21 (48 pts), loops 5 (12 pts), boolean chains 7, match/switch 1 (3 pts) (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_annotated_assignment_statement (cognitive 68) crates/ty_python_semantic/src/types/infer/builder.rs:4488 — TypeInferenceBuilder::infer_annotated_assignment_statement has cognitive complexity 68 (threshold 15). Drivers by points: if/else 22 (52 pts), boolean chains 7, match/switch 2 (6 pts), loops 1 (3 pts) (nesting depth added 36). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeInferenceBuilder::infer_annotation_expression_impl (cognitive 67) crates/ty_python_semantic/src/types/infer/builder/annotation_expression.rs:100 — TypeInferenceBuilder::infer_annotation_expression_impl has cognitive complexity 67 (threshold 15). Drivers by points: if/else 14 (36 pts), match/switch 9 (21 pts), boolean chains 5, loops 1 (5 pts) (nesting depth added 38). Of this number, 54 points are the body's own statements and 13 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_subscript_load_impl (cognitive 59) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:199 — TypeInferenceBuilder::infer_subscript_load_impl has cognitive complexity 59 (threshold 15). Drivers by points: if/else 17 (41 pts), match/switch 4 (9 pts), boolean chains 5, loops 1 (4 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeInferenceBuilder::infer_tuple_type_expression (cognitive 59) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:1618 — TypeInferenceBuilder::infer_tuple_type_expression has cognitive complexity 59 (threshold 15). Drivers by points: if/else 20 (51 pts), boolean chains 5, loops 1 (2 pts), match/switch 1 (nesting depth added 32). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • TypeInferenceBuilder::infer_dict_expression (cognitive 57) crates/ty_python_semantic/src/types/infer/builder.rs:7856 — TypeInferenceBuilder::infer_dict_expression has cognitive complexity 57 (threshold 15). Drivers by points: if/else 15 (44 pts), loops 3 (12 pts), boolean chains 1 (nesting depth added 38). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • + 54 more in this group — see findings.md.
D3 · God Classes · ClassTooLong · ×54
  • ClassTooLong: TypeInferenceBuilder crates/ty_python_semantic/src/types/infer/builder.rs:306 — ClassTooLong — 8140 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 465 methods, 2 blocks, lines 306-12904. The bar is 400 significant lines; this is 7740 over it, 20.35× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Type crates/ty_python_semantic/src/types.rs:2075 — ClassTooLong — 5667 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 312 methods, 5 blocks, lines 2075-11585. The bar is 400 significant lines; this is 5267 over it, 14.17× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: SemanticIndexBuilder crates/ty_python_core/src/builder.rs:237 — ClassTooLong — 3442 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 127 methods, 4 blocks, lines 237-6043. The bar is 400 significant lines; this is 3042 over it, 8.61× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: StaticClassLiteral crates/ty_python_semantic/src/types/class/static_literal.rs:83 — ClassTooLong — 2091 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 116 methods, 4 blocks, lines 83-3815. The bar is 400 significant lines; this is 1691 over it, 5.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Checker crates/ruff_linter/src/checkers/ast/mod.rs:196 — ClassTooLong — 1921 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 67 methods, 6 blocks, lines 196-3481. The bar is 400 significant lines; this is 1521 over it, 4.80× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: KnownClass crates/ty_python_semantic/src/types/class/known.rs:34 — ClassTooLong — 1869 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 27 methods, 2 blocks, lines 34-2220. The bar is 400 significant lines; this is 1469 over it, 4.67× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Bindings crates/ty_python_semantic/src/types/call/bind.rs:636 — ClassTooLong — 1743 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 58 methods, 4 blocks, lines 636-3492. The bar is 400 significant lines; this is 1343 over it, 4.36× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: NarrowingConstraintsBuilder crates/ty_python_semantic/src/types/narrow.rs:1686 — ClassTooLong — 1686 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 48 methods, 3 blocks, lines 1686-5560. The bar is 400 significant lines; this is 1286 over it, 4.22× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: SpecializationBuilder crates/ty_python_semantic/src/types/generics.rs:2515 — ClassTooLong — 1441 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 36 methods, 2 blocks, lines 2515-5052. The bar is 400 significant lines; this is 1041 over it, 3.60× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: TypeRelationChecker crates/ty_python_semantic/src/types/relation.rs:1253 — ClassTooLong — 1232 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 80 methods, 2 blocks, lines 1253-3444. The bar is 400 significant lines; this is 832 over it, 3.08× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: SolutionWalker crates/ty_python_semantic/src/types/constraints/solutions.rs:73 — ClassTooLong — 1211 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 29 methods, 2 blocks, lines 73-1867. The bar is 400 significant lines; this is 811 over it, 3.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: SemanticModel crates/ruff_python_semantic/src/model.rs:59 — ClassTooLong — 1176 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 145 methods, 2 blocks, lines 59-2521. The bar is 400 significant lines; this is 776 over it, 2.94× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Generator crates/ruff_python_codegen/src/generator.rs:90 — ClassTooLong — 1153 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 39 methods, 3 blocks, lines 90-1638. The bar is 400 significant lines; this is 753 over it, 2.88× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Signature crates/ty_python_semantic/src/types/signatures.rs:688 — ClassTooLong — 1117 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 64 methods, 3 blocks, lines 688-2609. The bar is 400 significant lines; this is 717 over it, 2.79× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: UseDefMapBuilder crates/ty_python_core/src/use_def.rs:2185 — ClassTooLong — 950 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 51 methods, 2 blocks, lines 2185-3653. The bar is 400 significant lines; this is 550 over it, 2.38× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: PatternSuccessAnalyzer crates/ty_python_semantic/src/types/narrow.rs:429 — ClassTooLong — 931 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 41 methods, 2 blocks, lines 429-3503. The bar is 400 significant lines; this is 531 over it, 2.33× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: CallableBinding crates/ty_python_semantic/src/types/call/bind.rs:3505 — ClassTooLong — 865 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 38 methods, 4 blocks, lines 3505-5042. The bar is 400 significant lines; this is 465 over it, 2.16× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: ClassType crates/ty_python_semantic/src/types/class.rs:1178 — ClassTooLong — 852 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 55 methods, 4 blocks, lines 1178-2621. The bar is 400 significant lines; this is 452 over it, 2.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: CallInference crates/ty_python_semantic/src/types/call/bind.rs:6180 — ClassTooLong — 835 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 16 methods, 3 blocks, lines 6180-7730. The bar is 400 significant lines; this is 435 over it, 2.09× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Binding crates/ty_python_semantic/src/types/call/bind.rs:8629 — ClassTooLong — 810 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 43 methods, 2 blocks, lines 8629-9906. The bar is 400 significant lines; this is 410 over it, 2.03× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: DisjointnessChecker crates/ty_python_semantic/src/types/relation.rs:3516 — ClassTooLong — 777 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 23 methods, 2 blocks, lines 3516-4827. The bar is 400 significant lines; this is 377 over it, 1.94× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: AssignmentAttributeWriteEvaluator crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:205 — ClassTooLong — 721 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 16 methods, 2 blocks, lines 205-1206. The bar is 400 significant lines; this is 321 over it, 1.80× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: PathAssignments crates/ty_python_semantic/src/types/constraints/paths.rs:58 — ClassTooLong — 717 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 22 methods, 3 blocks, lines 58-1212. The bar is 400 significant lines; this is 317 over it, 1.79× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: Session crates/ty_server/src/session.rs:61 — ClassTooLong — 716 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 55 methods, 2 blocks, lines 61-1492. The bar is 400 significant lines; this is 316 over it, 1.79× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • ClassTooLong: SemanticTokenVisitor crates/ty_ide/src/semantic_tokens.rs:308 — ClassTooLong — 645 significant lines (blank, comment-only and punctuation-only lines excluded, and inline test code — #[cfg(test)] modules and bare #[test] functions — not counted), 17 methods, 3 blocks, lines 308-1390. The bar is 400 significant lines; this is 245 over it, 1.61× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • + 29 more in this group — see findings.md.
D1 · Cyclomatic Complexity · TypeInferenceBuilder · ×49
  • TypeInferenceBuilder::infer_parameterized_special_form_type_expression (cyclomatic 109) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2564 — TypeInferenceBuilder::infer_parameterized_special_form_type_expression has cyclomatic complexity 109 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_call_expression_impl (cyclomatic 109) crates/ty_python_semantic/src/types/infer/builder.rs:9652 — TypeInferenceBuilder::infer_call_expression_impl has cyclomatic complexity 109 (threshold 15). Of this number, 105 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_type_expression_no_store (cyclomatic 108) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:436 — TypeInferenceBuilder::infer_type_expression_no_store has cyclomatic complexity 108 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::report_redundant_condition (cyclomatic 106) crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:61 — TypeInferenceBuilder::report_redundant_condition has cyclomatic complexity 106 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_binary_expression_type_impl (cyclomatic 85) crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:470 — TypeInferenceBuilder::infer_binary_expression_type_impl has cyclomatic complexity 85 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • TypeInferenceBuilder::infer_explicit_callable_specialization_impl (cyclomatic 80) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:627 — TypeInferenceBuilder::infer_explicit_callable_specialization_impl has cyclomatic complexity 80 (threshold 15). Of this number, 79 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_subscript_type_expression (cyclomatic 69) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2029 — TypeInferenceBuilder::infer_subscript_type_expression has cyclomatic complexity 69 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_namedtuple_call_expression (cyclomatic 63) crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:30 — TypeInferenceBuilder::infer_namedtuple_call_expression has cyclomatic complexity 63 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_annotated_assignment_definition (cyclomatic 63) crates/ty_python_semantic/src/types/infer/builder.rs:4751 — TypeInferenceBuilder::infer_annotated_assignment_definition has cyclomatic complexity 63 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_function_definition (cyclomatic 59) crates/ty_python_semantic/src/types/infer/builder/function.rs:397 — TypeInferenceBuilder::infer_function_definition has cyclomatic complexity 59 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_collection_literal_impl (cyclomatic 53) crates/ty_python_semantic/src/types/infer/builder.rs:8063 — TypeInferenceBuilder::infer_collection_literal_impl has cyclomatic complexity 53 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::validate_subscript_assignment_impl (cyclomatic 51) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:1837 — TypeInferenceBuilder::validate_subscript_assignment_impl has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::validate_attribute_deletion (cyclomatic 45) crates/ty_python_semantic/src/types/infer/builder.rs:3159 — TypeInferenceBuilder::validate_attribute_deletion has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_typeddict_call_expression (cyclomatic 44) crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:73 — TypeInferenceBuilder::infer_typeddict_call_expression has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_legacy_typevar (cyclomatic 44) crates/ty_python_semantic/src/types/infer/builder/typevar.rs:1280 — TypeInferenceBuilder::infer_legacy_typevar has cyclomatic complexity 44 (threshold 15). Of this number, 43 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • TypeInferenceBuilder::infer_legacy_typevartuple (cyclomatic 43) crates/ty_python_semantic/src/types/infer/builder/typevar.rs:755 — TypeInferenceBuilder::infer_legacy_typevartuple has cyclomatic complexity 43 (threshold 15). Of this number, 42 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_class_definition (cyclomatic 41) crates/ty_python_semantic/src/types/infer/builder/class.rs:104 — TypeInferenceBuilder::infer_class_definition has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_attribute_load_impl (cyclomatic 41) crates/ty_python_semantic/src/types/infer/builder.rs:11269 — TypeInferenceBuilder::infer_attribute_load_impl has cyclomatic complexity 41 (threshold 15). Of this number, 38 points are the body's own statements and 3 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_subscript_load_impl (cyclomatic 37) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:199 — TypeInferenceBuilder::infer_subscript_load_impl has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_legacy_paramspec (cyclomatic 37) crates/ty_python_semantic/src/types/infer/builder/typevar.rs:1027 — TypeInferenceBuilder::infer_legacy_paramspec has cyclomatic complexity 37 (threshold 15). Of this number, 36 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • TypeInferenceBuilder::infer_annotation_expression_impl (cyclomatic 36) crates/ty_python_semantic/src/types/infer/builder/annotation_expression.rs:100 — TypeInferenceBuilder::infer_annotation_expression_impl has cyclomatic complexity 36 (threshold 15). Of this number, 28 points are the body's own statements and 8 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_function_body (cyclomatic 34) crates/ty_python_semantic/src/types/infer/builder/function.rs:164 — TypeInferenceBuilder::infer_function_body has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::validate_typevar_default (cyclomatic 34) crates/ty_python_semantic/src/types/infer/builder/typevar.rs:166 — TypeInferenceBuilder::validate_typevar_default has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeInferenceBuilder::infer_typealiastype_assignment_deferred (cyclomatic 31) crates/ty_python_semantic/src/types/infer/builder.rs:4311 — TypeInferenceBuilder::infer_typealiastype_assignment_deferred has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: TypeInferenceBuilder::infer_value_expression_impl (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • TypeInferenceBuilder::infer_enum_call_expression (cyclomatic 30) crates/ty_python_semantic/src/types/infer/builder/enum_call.rs:295 — TypeInferenceBuilder::infer_enum_call_expression has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • + 24 more in this group — see findings.md.
D1 · Cyclomatic Complexity · ty_python_semantic · ×46
  • ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions (cyclomatic 168) crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:144 — ty_python_semantic::types::infer::builder::post_inference::static_class::check_static_class_definitions has cyclomatic complexity 168 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::overrides::check_class_declaration (cyclomatic 96) crates/ty_python_semantic/src/types/overrides.rs:729 — ty_python_semantic::types::overrides::check_class_declaration has cyclomatic complexity 96 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::infer::comparisons::infer_binary_type_comparison_inner (cyclomatic 66) crates/ty_python_semantic/src/types/infer/comparisons.rs:840 — ty_python_semantic::types::infer::comparisons::infer_binary_type_comparison_inner has cyclomatic complexity 66 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ty_python_semantic::types::dedicated::pydantic::lax_input_type_impl (cyclomatic 43) crates/ty_python_semantic/src/types/dedicated/pydantic.rs:1144 — ty_python_semantic::types::dedicated::pydantic::lax_input_type_impl has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::equality::evaluate_structural_comparison (cyclomatic 43) crates/ty_python_semantic/src/types/equality.rs:709 — ty_python_semantic::types::equality::evaluate_structural_comparison has cyclomatic complexity 43 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ty_python_semantic::types::infer::builder::post_inference::overloaded_function::check_overloaded_function (cyclomatic 41) crates/ty_python_semantic/src/types/infer/builder/post_inference/overloaded_function.rs:35 — ty_python_semantic::types::infer::builder::post_inference::overloaded_function::check_overloaded_function has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::enums::enum_metadata (cyclomatic 32) crates/ty_python_semantic/src/types/enums.rs:1005 — ty_python_semantic::types::enums::enum_metadata has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::instance::protocol_materialization_is_noop_with_type_parameters (cyclomatic 30) crates/ty_python_semantic/src/types/instance.rs:608 — ty_python_semantic::types::instance::protocol_materialization_is_noop_with_type_parameters has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::reachability::analyze_single_pattern_predicate_kind (cyclomatic 29) crates/ty_python_semantic/src/reachability.rs:1736 — ty_python_semantic::reachability::analyze_single_pattern_predicate_kind has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::set_theoretic::generic_gradual_intersections::base_top_intersection (cyclomatic 29) crates/ty_python_semantic/src/types/set_theoretic/generic_gradual_intersections.rs:61 — ty_python_semantic::types::set_theoretic::generic_gradual_intersections::base_top_intersection has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::suppression::unused::check_unused_suppressions (cyclomatic 27) crates/ty_python_semantic/src/suppression/unused.rs:20 — ty_python_semantic::suppression::unused::check_unused_suppressions has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::ide_support::unused_bindings::unused_bindings (cyclomatic 26) crates/ty_python_semantic/src/types/ide_support/unused_bindings.rs:105 — ty_python_semantic::types::ide_support::unused_bindings::unused_bindings has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::diagnostic::report_incompatible_method_override (cyclomatic 24) crates/ty_python_semantic/src/types/diagnostic.rs:5277 — ty_python_semantic::types::diagnostic::report_incompatible_method_override has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::infer::comparisons::infer_binary_intersection_type_comparison (cyclomatic 24) crates/ty_python_semantic/src/types/infer/comparisons.rs:1346 — ty_python_semantic::types::infer::comparisons::infer_binary_intersection_type_comparison has cyclomatic complexity 24 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ty_python_semantic::types::overrides::attributes::attribute_violation (cyclomatic 24) crates/ty_python_semantic/src/types/overrides/attributes.rs:457 — ty_python_semantic::types::overrides::attributes::attribute_violation has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • ty_python_semantic::place::place_from_bindings_impl (cyclomatic 23) crates/ty_python_semantic/src/place.rs:1799 — ty_python_semantic::place::place_from_bindings_impl has cyclomatic complexity 23 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ty_python_semantic::types::infer::builder::function::is_instance_truthiness (cyclomatic 23) crates/ty_python_semantic/src/types/infer/builder/function.rs:2335 — ty_python_semantic::types::infer::builder::function::is_instance_truthiness has cyclomatic complexity 23 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • ty_python_semantic::types::set_theoretic::generic_gradual_intersections::dynamic_generalization_intersection (cyclomatic 23) crates/ty_python_semantic/src/types/set_theoretic/generic_gradual_intersections.rs:205 — ty_python_semantic::types::set_theoretic::generic_gradual_intersections::dynamic_generalization_intersection has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::fixes::fix_all (cyclomatic 22) crates/ty_python_semantic/src/fixes.rs:80 — ty_python_semantic::fixes::fix_all has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::overrides::check_inherited_method_conflict (cyclomatic 22) crates/ty_python_semantic/src/types/overrides.rs:350 — ty_python_semantic::types::overrides::check_inherited_method_conflict has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::attribute_write::attribute_write_requirement (cyclomatic 21) crates/ty_python_semantic/src/types/attribute_write.rs:344 — ty_python_semantic::types::attribute_write::attribute_write_requirement has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ty_python_semantic::types::diagnostic::report_dynamic_function_decorator_return (cyclomatic 21) crates/ty_python_semantic/src/types/diagnostic.rs:2768 — ty_python_semantic::types::diagnostic::report_dynamic_function_decorator_return has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::generics::find_typevar_binding (cyclomatic 21) crates/ty_python_semantic/src/types/generics.rs:146 — ty_python_semantic::types::generics::find_typevar_binding has cyclomatic complexity 21 (threshold 15). Of this number, 20 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_python_semantic::types::narrow::containment::containment_behavior (cyclomatic 21) crates/ty_python_semantic/src/types/narrow/containment.rs:16 — ty_python_semantic::types::narrow::containment::containment_behavior has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • ty_python_semantic::types::overrides::attributes::check_inherited_conflict (cyclomatic 21) crates/ty_python_semantic/src/types/overrides/attributes.rs:998 — ty_python_semantic::types::overrides::attributes::check_inherited_conflict has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • + 21 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×46
  • Duplicated block (10 lines × 2) crates/ruff_annotate_snippets/src/renderer/render.rs:1416 — crates/ruff_annotate_snippets/src/renderer/render.rs:1416-1425 | crates/ruff_annotate_snippets/src/renderer/render.rs:1433-1443 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_annotate_snippets/src/renderer/render.rs:1416` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_db/src/diagnostic/render/json.rs:154 — crates/ruff_db/src/diagnostic/render/json.rs:154-163 | crates/ruff_db/src/diagnostic/render/json.rs:165-174 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/fix/edits.rs:241 — crates/ruff_linter/src/fix/edits.rs:241-250 | crates/ruff_linter/src/fix/edits.rs:302-311 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:775 — crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:775-784 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:802-811 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:775` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/rules/isort/order.rs:112 — crates/ruff_linter/src/rules/isort/order.rs:112-121 | crates/ruff_linter/src/rules/isort/order.rs:235-244 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/isort/order.rs:112` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs:123 — crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs:123-132 | crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs:142-151 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs:123` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:276 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:276-287 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:296-305 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:276` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:107 — crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:107-116 | crates/ruff_linter/src/rules/pylint/rules/redefined_slots_in_subclass.rs:125-134 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:107` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:144 — crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:144-153 | crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs:157-166 — before extracting anything, compare `crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs` and `crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:144` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:72 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:72-81 | crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs:71-80 — before extracting anything, compare `crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs` and `crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) crates/ruff_mdtest/src/lib.rs:141 — crates/ruff_mdtest/src/lib.rs:141-150 | crates/ty_test/src/lib.rs:331-340 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) crates/ruff_python_ast/src/visitor.rs:524 — crates/ruff_python_ast/src/visitor.rs:524-533 | crates/ruff_python_ast/src/visitor/transformer.rs:518-527 — before extracting anything, compare `crates/ruff_python_ast/src/visitor.rs` and `crates/ruff_python_ast/src/visitor/transformer.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/visitor.rs:524` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_python_formatter/src/other/parameters.rs:357 — crates/ruff_python_formatter/src/other/parameters.rs:357-366 | crates/ruff_python_formatter/src/other/parameters.rs:390-399 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs:84 — crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs:84-93 | crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs:49-58 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs:84` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&StmtAnnAssign` in one and `&StmtAugAssign` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10 lines × 2) crates/ruff_python_formatter/src/statement/stmt_class_def.rs:27 — crates/ruff_python_formatter/src/statement/stmt_class_def.rs:27-36 | crates/ruff_python_formatter/src/statement/stmt_function_def.rs:22-31 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_class_def.rs:27` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&StmtClassDef` in one and `&StmtFunctionDef` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10 lines × 2) crates/ruff_python_formatter/src/statement/stmt_class_def.rs:59 — crates/ruff_python_formatter/src/statement/stmt_class_def.rs:59-68 | crates/ruff_python_formatter/src/statement/stmt_function_def.rs:54-63 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_class_def.rs:59` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&StmtClassDef` in one and `&StmtFunctionDef` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10 lines × 2) crates/ruff_python_parser/src/lexer.rs:601 — crates/ruff_python_parser/src/lexer.rs:601-610 | crates/ruff_python_parser/src/lexer.rs:614-623 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_parser/src/lexer.rs:614` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_python_parser/src/lexer.rs:612` calls `eat_char` and `crates/ruff_python_parser/src/lexer.rs:600` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) crates/ruff_python_parser/src/lexer.rs:724 — crates/ruff_python_parser/src/lexer.rs:724-733 | crates/ruff_python_parser/src/lexer.rs:874-885 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) crates/ruff_python_semantic/src/cfg/graph.rs:231 — crates/ruff_python_semantic/src/cfg/graph.rs:231-240 | crates/ruff_python_semantic/src/cfg/graph.rs:244-253 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (10 lines × 2) crates/ruff_server/src/server.rs:228 — crates/ruff_server/src/server.rs:228-237 | crates/ty_server/src/capabilities.rs:464-474 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server.rs:228` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ruff_workspace/src/resolver.rs:656 — crates/ruff_workspace/src/resolver.rs:656-665 | crates/ruff_workspace/src/resolver.rs:840-849 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_workspace/src/resolver.rs:656` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ty_python_semantic/src/types.rs:3559 — crates/ty_python_semantic/src/types.rs:3559-3568 | crates/ty_python_semantic/src/types.rs:3598-3607 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types.rs:3597` calls `TypeForm` and `crates/ty_python_semantic/src/types.rs:3558` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) crates/ty_python_semantic/src/types.rs:10714 — crates/ty_python_semantic/src/types.rs:10714-10723 | crates/ty_python_semantic/src/types/infer/comparisons.rs:446-455 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (10 lines × 2) crates/ty_python_semantic/src/types/bound_super.rs:688 — crates/ty_python_semantic/src/types/bound_super.rs:688-697 | crates/ty_python_semantic/src/types/bound_super.rs:794-803 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/bound_super.rs:688` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) crates/ty_python_semantic/src/types/diagnostic.rs:5813 — crates/ty_python_semantic/src/types/diagnostic.rs:5813-5822 | crates/ty_python_semantic/src/types/diagnostic.rs:5976-5985 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/diagnostic.rs:5813` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • + 21 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×45
  • Duplicated block (9 lines × 2) crates/ruff_linter/src/rules/airflow/helpers.rs:315 — crates/ruff_linter/src/rules/airflow/helpers.rs:315-323 | crates/ruff_linter/src/rules/airflow/rules/task_implicit_multiple_outputs.rs:126-134 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs:827 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs:827-835 | crates/ruff_linter/src/rules/flake8_simplify/rules/fix_with.rs:77-85 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:183 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:183-191 | crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:231-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:183` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ruff_linter/src/rules/pep8_naming/helpers.rs:28 — crates/ruff_linter/src/rules/pep8_naming/helpers.rs:28-36 | crates/ruff_linter/src/rules/pep8_naming/helpers.rs:63-71 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pep8_naming/helpers.rs:28` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:188 — crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:188-196 | crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs:195-203 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:188` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ruff_python_codegen/src/generator.rs:268 — crates/ruff_python_codegen/src/generator.rs:268-276 | crates/ruff_python_codegen/src/generator.rs:307-315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_codegen/src/generator.rs:268` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_codegen/src/generator.rs:278` calls `p` and `crates/ruff_python_codegen/src/generator.rs:316` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) crates/ruff_python_formatter/src/comments/placement.rs:917 — crates/ruff_python_formatter/src/comments/placement.rs:917-927 | crates/ruff_python_formatter/src/comments/placement.rs:1011-1019 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/comments/placement.rs:917` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ruff_python_formatter/src/expression/binary_like.rs:888 — crates/ruff_python_formatter/src/expression/binary_like.rs:888-896 | crates/ruff_python_formatter/src/expression/binary_like.rs:939-947 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/expression/binary_like.rs:888` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ruff_python_formatter/src/statement/suite.rs:296 — crates/ruff_python_formatter/src/statement/suite.rs:296-304 | crates/ruff_python_formatter/src/statement/suite.rs:388-396 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/suite.rs:296` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 2) crates/ruff_python_stdlib/src/str.rs:22 — crates/ruff_python_stdlib/src/str.rs:22-30 | crates/ruff_python_stdlib/src/str.rs:59-67 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_stdlib/src/str.rs:22` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ruff_server/src/server/main_loop.rs:39 — crates/ruff_server/src/server/main_loop.rs:39-47 | crates/ty_server/src/server/main_loop.rs:40-48 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/main_loop.rs:39` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ruff_server/src/session/client.rs:207 — crates/ruff_server/src/session/client.rs:207-215 | crates/ty_server/src/session/client.rs:261-269 — before extracting anything, compare `crates/ruff_server/src/session/client.rs` and `crates/ty_server/src/session/client.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/session/client.rs:207` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_completion_bench/src/main.rs:81 — crates/ty_completion_bench/src/main.rs:81-89 | crates/ty_completion_eval/src/main.rs:464-472 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) crates/ty_ide/src/semantic_tokens.rs:1041 — crates/ty_ide/src/semantic_tokens.rs:1041-1049 | crates/ty_ide/src/semantic_tokens.rs:1284-1295 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_ide/src/semantic_tokens.rs:1041` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_python_core/src/builder.rs:3274 — crates/ty_python_core/src/builder.rs:3274-3282 | crates/ty_python_core/src/builder.rs:3293-3301 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/builder.rs:3274` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types.rs:9848 — crates/ty_python_semantic/src/types.rs:9848-9856 | crates/ty_python_semantic/src/types/known_instance.rs:675-683 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:2674 — crates/ty_python_semantic/src/types/call/bind.rs:2674-2682 | crates/ty_python_semantic/src/types/call/bind.rs:2686-2694 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/constraints/paths.rs:188 — crates/ty_python_semantic/src/types/constraints/paths.rs:188-196 | crates/ty_python_semantic/src/types/constraints/paths.rs:282-290 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/paths.rs:188` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:728 — crates/ty_python_semantic/src/types/constraints/sequents.rs:728-736 | crates/ty_python_semantic/src/types/constraints/sequents.rs:754-762 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:728` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:2065 — crates/ty_python_semantic/src/types/constraints/sequents.rs:2065-2073 | crates/ty_python_semantic/src/types/constraints/sequents.rs:2116-2124 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:2065` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/definition.rs:26 — crates/ty_python_semantic/src/types/definition.rs:26-34 | crates/ty_python_semantic/src/types/definition.rs:80-88 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/definition.rs:26` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/definition.rs:28 — crates/ty_python_semantic/src/types/definition.rs:28-36 | crates/ty_python_semantic/src/types/definition.rs:49-57 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/definition.rs:28` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/diagnostic.rs:2105 — crates/ty_python_semantic/src/types/diagnostic.rs:2105-2113 | crates/ty_python_semantic/src/types/ide_support/unused_bindings.rs:30-38 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:4532 — crates/ty_python_semantic/src/types/infer/builder.rs:4532-4540 | crates/ty_python_semantic/src/types/infer/builder/function.rs:1126-1134 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:4532` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `&mut` in one and `super) fn infer_parameter_definition( &mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:5542 — crates/ty_python_semantic/src/types/infer/builder.rs:5542-5550 | crates/ty_python_semantic/src/types/infer/builder.rs:5561-5569 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:5542` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • + 20 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×36
  • Duplicated block (8 lines × 2) crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:78 — crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:78-85 | crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:170-177 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:78` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs:321 — crates/ruff_linter/src/rules/pyupgrade/rules/use_pep604_annotation.rs:321-328 | crates/ruff_python_formatter/src/expression/mod.rs:1450-1457 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:324 — crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:324-331 | crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:345-352 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:324` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ruff_linter/src/settings/types.rs:396 — crates/ruff_linter/src/settings/types.rs:396-403 | crates/ruff_linter/src/settings/types.rs:475-482 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) crates/ruff_python_ast/src/token/parentheses.rs:43 — crates/ruff_python_ast/src/token/parentheses.rs:43-50 | crates/ty_ide/src/completion.rs:1206-1213 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/token/parentheses.rs:43` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ruff_python_formatter/src/other/arguments.rs:32 — crates/ruff_python_formatter/src/other/arguments.rs:32-39 | crates/ruff_python_formatter/src/pattern/pattern_arguments.rs:21-28 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/other/arguments.rs:32` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&Arguments` in one and `&PatternArguments` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) crates/ruff_python_parser/src/semantic_errors.rs:2177 — crates/ruff_python_parser/src/semantic_errors.rs:2177-2184 | crates/ruff_python_parser/src/semantic_errors.rs:2210-2217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_parser/src/semantic_errors.rs:2177` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8 lines × 2) crates/ruff_python_parser/src/string.rs:285 — crates/ruff_python_parser/src/string.rs:285-292 | crates/ruff_python_parser/src/string.rs:460-469 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_parser/src/string.rs:285` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ruff_python_semantic/src/definition.rs:229 — crates/ruff_python_semantic/src/definition.rs:229-236 | crates/ruff_python_semantic/src/definition.rs:251-258 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_semantic/src/definition.rs:229` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ruff_server/src/server/api.rs:166 — crates/ruff_server/src/server/api.rs:166-173 | crates/ty_server/src/server/api.rs:314-321 — before extracting anything, compare `crates/ruff_server/src/server/api.rs` and `crates/ty_server/src/server/api.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/api.rs:166` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ty_completion_bench/src/main.rs:94 — crates/ty_completion_bench/src/main.rs:94-101 | crates/ty_completion_eval/src/main.rs:283-290 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) crates/ty_python_core/src/reachability_constraints.rs:457 — crates/ty_python_core/src/reachability_constraints.rs:457-464 | crates/ty_python_core/src/reachability_constraints.rs:538-545 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/reachability_constraints.rs:457` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ty_python_core/src/use_def.rs:513 — crates/ty_python_core/src/use_def.rs:513-520 | crates/ty_python_core/src/use_def.rs:542-549 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) crates/ty_python_core/src/use_def.rs:581 — crates/ty_python_core/src/use_def.rs:581-588 | crates/ty_python_core/src/use_def.rs:608-615 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:8585 — crates/ty_python_semantic/src/types/call/bind.rs:8585-8592 | crates/ty_python_semantic/src/types/typevar.rs:1007-1014 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:8585` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/class.rs:1261 — crates/ty_python_semantic/src/types/class.rs:1261-1268 | crates/ty_python_semantic/src/types/class.rs:1280-1287 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class.rs:1261` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `crate) fn static_class_literal(` in one and `crate) fn static_class_literal_specialized(` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1476 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1476-1483 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1753-1760 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/diagnostic.rs:5803 — crates/ty_python_semantic/src/types/diagnostic.rs:5803-5810 | crates/ty_python_semantic/src/types/diagnostic.rs:5967-5974 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/diagnostic.rs:5803` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/display.rs:1040 — crates/ty_python_semantic/src/types/display.rs:1040-1047 | crates/ty_python_semantic/src/types/display.rs:1239-1246 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/infer.rs:2092 — crates/ty_python_semantic/src/types/infer.rs:2092-2099 | crates/ty_python_semantic/src/types/infer.rs:2315-2322 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs:440 — crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs:440-447 | crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:945-952 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs:440` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/typevar.rs:660 — crates/ty_python_semantic/src/types/typevar.rs:660-667 | crates/ty_python_semantic/src/types/typevar.rs:807-814 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/typevar.rs:660` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) crates/ty_server/src/server/api/requests/call_hierarchy_incoming_calls.rs:50 — crates/ty_server/src/server/api/requests/call_hierarchy_incoming_calls.rs:50-57 | crates/ty_server/src/server/api/requests/call_hierarchy_outgoing_calls.rs:46-53 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_server/src/server/api/requests/call_hierarchy_incoming_calls.rs:50` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8 lines × 2) crates/ruff_server/src/session/client.rs:138 — crates/ruff_server/src/session/client.rs:138-145 | crates/ty_server/src/session/client.rs:178-185 — before extracting anything, compare `crates/ruff_server/src/session/client.rs` and `crates/ty_server/src/session/client.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (8 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3121 — crates/ty_python_semantic/src/types/signatures.rs:3121-3128 | crates/ty_python_semantic/src/types/signatures.rs:3135-3142 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3121` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 11 more in this group — see findings.md.
D3 · God Classes · TooManyMethods · ×35
  • TooManyMethods: TypeInferenceBuilder crates/ty_python_semantic/src/types/infer/builder.rs:306 — TooManyMethods — 465 methods, declared across 22 files: infer/builder.rs (254), builder/type_expression.rs (37), builder/function.rs (27), builder/subscript.rs (19), +18 more file(s). The bar is 30 methods; this is 435 over it, 15.50× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Type crates/ty_python_semantic/src/types.rs:2075 — TooManyMethods — 312 methods, declared across 21 files: src/types.rs (205), types/relation.rs (33), types/callable.rs (14), types/instance.rs (14), +17 more file(s). The bar is 30 methods; this is 282 over it, 10.40× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Parser crates/ruff_python_parser/src/parser/mod.rs:61 — TooManyMethods — 184 methods, declared across 4 files: parser/statement.rs (63), parser/expression.rs (60), parser/mod.rs (47), parser/pattern.rs (14). The bar is 30 methods; this is 154 over it, 6.13× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: SemanticModel crates/ruff_python_semantic/src/model.rs:59 — TooManyMethods — 145 methods, declared across 2 files: src/model.rs (143), model/all.rs (2). The bar is 30 methods; this is 115 over it, 4.83× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: SemanticIndexBuilder crates/ty_python_core/src/builder.rs:237 — TooManyMethods — 127 methods. The bar is 30 methods; this is 97 over it, 4.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: StaticClassLiteral crates/ty_python_semantic/src/types/class/static_literal.rs:83 — TooManyMethods — 116 methods, declared across 5 files: class/static_literal.rs (95), class/slots.rs (13), class/implicit_attributes.rs (6), types/protocol_class.rs (1), +1 more file(s). The bar is 30 methods; this is 86 over it, 3.87× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: TypeRelationChecker crates/ty_python_semantic/src/types/relation.rs:1253 — TooManyMethods — 80 methods, declared across 15 files: types/relation.rs (32), types/attribute_write.rs (9), types/signatures.rs (8), types/protocol_class.rs (7), +11 more file(s). The bar is 30 methods; this is 50 over it, 2.67× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Checker crates/ruff_linter/src/checkers/ast/mod.rs:196 — TooManyMethods — 67 methods. The bar is 30 methods; this is 37 over it, 2.23× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Signature crates/ty_python_semantic/src/types/signatures.rs:688 — TooManyMethods — 64 methods, declared across 2 files: types/signatures.rs (62), types/display.rs (2). The bar is 30 methods; this is 34 over it, 2.13× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Bindings crates/ty_python_semantic/src/types/call/bind.rs:636 — TooManyMethods — 58 methods, declared across 2 files: call/bind.rs (57), bind/property.rs (1). The bar is 30 methods; this is 28 over it, 1.93× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: FunctionType crates/ty_python_semantic/src/types/function.rs:1214 — TooManyMethods — 56 methods, declared across 2 files: types/function.rs (55), types/display.rs (1). The bar is 30 methods; this is 26 over it, 1.87× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ClassType crates/ty_python_semantic/src/types/class.rs:1178 — TooManyMethods — 55 methods, declared across 4 files: types/class.rs (52), types/abstract_methods.rs (1), types/mro.rs (1), types/protocol_class.rs (1). The bar is 30 methods; this is 25 over it, 1.83× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Session crates/ty_server/src/session.rs:61 — TooManyMethods — 55 methods. The bar is 30 methods; this is 25 over it, 1.83× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: UseDefMapBuilder crates/ty_python_core/src/use_def.rs:2185 — TooManyMethods — 51 methods. The bar is 30 methods; this is 21 over it, 1.70× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Diagnostic crates/ruff_db/src/diagnostic/mod.rs:29 — TooManyMethods — 48 methods. The bar is 30 methods; this is 18 over it, 1.60× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: NarrowingConstraintsBuilder crates/ty_python_semantic/src/types/narrow.rs:1686 — TooManyMethods — 48 methods. The bar is 30 methods; this is 18 over it, 1.60× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: VariableLengthTuple crates/ty_python_semantic/src/types/tuple.rs:1127 — TooManyMethods — 45 methods. The bar is 30 methods; this is 15 over it, 1.50× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: SemanticIndex crates/ty_python_core/src/lib.rs:287 — TooManyMethods — 44 methods. The bar is 30 methods; this is 14 over it, 1.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: ClassLiteral crates/ty_python_semantic/src/types/class.rs:611 — TooManyMethods — 44 methods, declared across 3 files: types/class.rs (42), types/display.rs (1), types/enums.rs (1). The bar is 30 methods; this is 14 over it, 1.47× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Binding crates/ty_python_semantic/src/types/call/bind.rs:8629 — TooManyMethods — 43 methods, declared across 2 files: call/bind.rs (38), bind/constructor.rs (5). The bar is 30 methods; this is 13 over it, 1.43× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: UseDefMap crates/ty_python_core/src/use_def.rs:801 — TooManyMethods — 42 methods. The bar is 30 methods; this is 12 over it, 1.40× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: PatternSuccessAnalyzer crates/ty_python_semantic/src/types/narrow.rs:429 — TooManyMethods — 41 methods. The bar is 30 methods; this is 11 over it, 1.37× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Parameters crates/ty_python_semantic/src/types/signatures.rs:5051 — TooManyMethods — 40 methods, declared across 2 files: types/signatures.rs (39), types/display.rs (1). The bar is 30 methods; this is 10 over it, 1.33× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Generator crates/ruff_python_codegen/src/generator.rs:90 — TooManyMethods — 39 methods. The bar is 30 methods; this is 9 over it, 1.30× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: Parameter crates/ty_python_semantic/src/types/signatures.rs:6046 — TooManyMethods — 39 methods, declared across 2 files: types/signatures.rs (38), types/display.rs (1). The bar is 30 methods; this is 9 over it, 1.30× the bar. That list is where to read them, not a suggestion to split the file: the members belong to the type wherever they are declared, so moving them between files leaves the count unchanged. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • + 10 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×34
  • Duplicated block (11 lines × 2) crates/ruff/src/args.rs:1031 — crates/ruff/src/args.rs:1031-1041 | crates/ruff/src/commands/completions/config.rs:124-134 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (11 lines × 2) crates/ruff/src/version.rs:29 — crates/ruff/src/version.rs:29-39 | crates/ty/src/version.rs:29-39 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (11 lines × 2) crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1199 — crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1199-1209 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs:325-335 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1199` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs:752 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs:752-762 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs:166-176 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs:752` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/flake8_pytest_style/rules/fixture.rs:750` calls `is_rule_enabled` and `crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs:164` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs:310 — crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs:310-320 | crates/ruff_linter/src/rules/flake8_quotes/rules/unnecessary_escaped_quote.rs:131-141 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs:275 — crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs:275-285 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs:291-301 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs:275` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ruff_linter/src/rules/ruff/rules/unnecessary_cast_to_int.rs:81 — crates/ruff_linter/src/rules/ruff/rules/unnecessary_cast_to_int.rs:81-91 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_round.rs:101-111 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) crates/ruff_python_formatter/src/statement/stmt_assign.rs:280 — crates/ruff_python_formatter/src/statement/stmt_assign.rs:280-290 | crates/ruff_python_formatter/src/statement/stmt_assign.rs:550-560 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_assign.rs:550` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_formatter/src/statement/stmt_assign.rs:561` calls `should_non_inlineable_use_best_fit`, `context` and `crates/ruff_python_formatter/src/statement/stmt_assign.rs:291` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11 lines × 2) crates/ruff_python_index/src/multiline_ranges.rs:29 — crates/ruff_python_index/src/multiline_ranges.rs:29-39 | crates/ruff_python_trivia/src/comment_ranges.rs:81-91 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_index/src/multiline_ranges.rs:29` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ruff_python_parser/src/semantic_errors.rs:931 — crates/ruff_python_parser/src/semantic_errors.rs:931-941 | crates/ruff_python_parser/src/semantic_errors.rs:951-961 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_parser/src/semantic_errors.rs:951` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ruff_python_semantic/src/model.rs:524 — crates/ruff_python_semantic/src/model.rs:524-554 | crates/ruff_python_semantic/src/model.rs:874-884 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) crates/ty_python_core/src/narrowing_constraints.rs:150 — crates/ty_python_core/src/narrowing_constraints.rs:150-160 | crates/ty_python_core/src/reachability_constraints.rs:206-216 — before extracting anything, compare `crates/ty_python_core/src/narrowing_constraints.rs` and `crates/ty_python_core/src/reachability_constraints.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/narrowing_constraints.rs:150` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) crates/ty_python_core/src/narrowing_constraints.rs:320 — crates/ty_python_core/src/narrowing_constraints.rs:320-330 | crates/ty_python_core/src/narrowing_constraints.rs:387-398 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/narrowing_constraints.rs:320` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:6925 — crates/ty_python_semantic/src/types/call/bind.rs:6925-6935 | crates/ty_python_semantic/src/types/call/bind.rs:7148-7158 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1577 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1577-1587 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1803-1813 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1577` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/constraints/variables.rs:807 — crates/ty_python_semantic/src/types/constraints/variables.rs:807-817 | crates/ty_python_semantic/src/types/constraints/variables.rs:1188-1198 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/variables.rs:807` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:7568 — crates/ty_python_semantic/src/types/infer/builder.rs:7568-7578 | crates/ty_python_semantic/src/types/infer/builder.rs:8047-8057 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:7568` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:677 — crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:677-687 | crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:764-774 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:764` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/infer/builder/post_inference/overloaded_function.rs:228 — crates/ty_python_semantic/src/types/infer/builder/post_inference/overloaded_function.rs:228-238 | crates/ty_python_semantic/src/types/infer/builder/post_inference/overloaded_function.rs:261-271 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/post_inference/overloaded_function.rs:228` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:1847 — crates/ty_python_semantic/src/types/infer/builder/subscript.rs:1847-1857 | crates/ty_python_semantic/src/types/infer/builder/subscript.rs:2295-2305 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:735 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:735-745 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:1029-1039 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:735` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:1659 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:1659-1669 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:1755-1766 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:1659` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/narrow.rs:5484 — crates/ty_python_semantic/src/types/narrow.rs:5484-5494 | crates/ty_python_semantic/src/types/narrow.rs:5531-5541 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/narrow.rs:5484` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3716 — crates/ty_python_semantic/src/types/signatures.rs:3716-3726 | crates/ty_python_semantic/src/types/signatures.rs:3889-3899 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) crates/ty_python_semantic/src/types/typed_dict.rs:2449 — crates/ty_python_semantic/src/types/typed_dict.rs:2449-2459 | crates/ty_python_semantic/src/types/typed_dict.rs:2468-2478 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/typed_dict.rs:2449` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ty_python_semantic/src/types/typed_dict.rs:2461` calls `is_assignable_to` and `crates/ty_python_semantic/src/types/typed_dict.rs:2480` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • + 9 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×34
  • Duplicated block (6 lines × 2) crates/ruff_dev/src/generate_options.rs:28 — crates/ruff_dev/src/generate_options.rs:28-33 | crates/ruff_dev/src/generate_ty_options.rs:71-76 — before extracting anything, compare `crates/ruff_dev/src/generate_options.rs` and `crates/ruff_dev/src/generate_ty_options.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 63 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_dev/src/generate_options.rs:28` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs:69 — crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs:69-74 | crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs:98-103 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs:69` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:164 — crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:164-169 | crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs:186-192 — before extracting anything, compare `crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs` and `crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:164` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6 lines × 2) crates/ruff_macros/src/map_codes.rs:158 — crates/ruff_macros/src/map_codes.rs:158-163 | crates/ruff_macros/src/map_codes.rs:177-182 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_macros/src/map_codes.rs:158` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ruff_python_formatter/src/comments/placement.rs:1606 — crates/ruff_python_formatter/src/comments/placement.rs:1606-1613 | crates/ruff_python_formatter/src/comments/placement.rs:1776-1781 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/comments/placement.rs:1606` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ruff_python_formatter/src/expression/mod.rs:421 — crates/ruff_python_formatter/src/expression/mod.rs:421-426 | crates/ruff_python_formatter/src/pattern/mod.rs:199-204 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/expression/mod.rs:421` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `f` to `&mut PyFormatter` in one and `&mut Formatter<PyFormatContext<'_>>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_python_formatter/src/expression/mod.rs:418` calls `fmt` and `crates/ruff_python_formatter/src/pattern/mod.rs:197` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (6 lines × 2) crates/ruff_python_parser/src/lexer.rs:1323 — crates/ruff_python_parser/src/lexer.rs:1323-1330 | crates/ruff_python_parser/src/lexer.rs:1363-1368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `crate) fn re_lex_string_token_in_interpolation_element( &mut` in one and `crate) fn re_lex_raw_string_in_format_spec(&mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) crates/ruff_workspace/src/configuration.rs:1119 — crates/ruff_workspace/src/configuration.rs:1119-1124 | crates/ruff_workspace/src/configuration.rs:1164-1169 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_workspace/src/configuration.rs:1119` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ty_ide/src/call_hierarchy/incoming_calls.rs:35 — crates/ty_ide/src/call_hierarchy/incoming_calls.rs:35-41 | crates/ty_ide/src/call_hierarchy/outgoing_calls.rs:35-40 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (6 lines × 2) crates/ty_python_core/src/builder.rs:1925 — crates/ty_python_core/src/builder.rs:1925-1933 | crates/ty_python_core/src/builder.rs:2003-2008 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/builder.rs:1925` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ty_python_semantic/src/types/equality/enums.rs:784 — crates/ty_python_semantic/src/types/equality/enums.rs:784-789 | crates/ty_python_semantic/src/types/equality/enums.rs:804-809 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/equality/enums.rs:784` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:700 — crates/ty_python_semantic/src/types/infer/builder.rs:700-705 | crates/ty_python_semantic/src/types/infer/builder.rs:755-760 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) crates/ty_python_semantic/src/types/method.rs:818 — crates/ty_python_semantic/src/types/method.rs:818-823 | crates/ty_python_semantic/src/types/method.rs:839-844 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/method.rs:818` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ty_python_semantic/src/types/relation.rs:1484 — crates/ty_python_semantic/src/types/relation.rs:1484-1489 | crates/ty_python_semantic/src/types/relation.rs:1697-1702 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/relation.rs:1484` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ty_python_semantic/src/types/set_theoretic.rs:110 — crates/ty_python_semantic/src/types/set_theoretic.rs:110-115 | crates/ty_python_semantic/src/types/set_theoretic.rs:194-199 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic.rs:110` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) crates/ruff_python_formatter/src/statement/stmt_global.rs:14 — crates/ruff_python_formatter/src/statement/stmt_global.rs:14-19 | crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs:14-19 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_global.rs:14` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&StmtGlobal` in one and `&StmtNonlocal` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1528 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1528-1533 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1587-1592 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1528` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (6 lines × 2) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:653 — crates/ty_python_semantic/src/types/infer/builder/subscript.rs:653-658 | crates/ty_python_semantic/src/types/infer/builder/subscript.rs:1060-1065 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/subscript.rs:653` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 2) crates/ruff_linter/src/rules/flake8_datetimez/rules/datetime_min_max.rs:121 — crates/ruff_linter/src/rules/flake8_datetimez/rules/datetime_min_max.rs:121-126 | crates/ruff_linter/src/rules/pylint/rules/nested_min_max.rs:119-124 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `f` to `&mut Formatter<'_>` in one and `&mut std::fmt::Formatter<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) crates/ruff_linter/src/rules/flake8_return/visitor.rs:213 — crates/ruff_linter/src/rules/flake8_return/visitor.rs:213-218 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_assign_before_yield.rs:232-237 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) crates/ruff_server/src/session/index.rs:98 — crates/ruff_server/src/session/index.rs:98-103 | crates/ty_server/src/session/index.rs:62-67 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) crates/ruff_server/src/session/index.rs:515 — crates/ruff_server/src/session/index.rs:515-520 | crates/ty_server/src/session/index.rs:261-266 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) crates/ruff_server/src/session/index.rs:536 — crates/ruff_server/src/session/index.rs:536-541 | crates/ty_server/src/session/index.rs:282-287 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `&mut` in one and `crate) fn as_text_mut(&mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 2) crates/ty_ide/src/docstring/document/google.rs:451 — crates/ty_ide/src/docstring/document/google.rs:451-456 | crates/ty_ide/src/docstring/document/numpy.rs:363-368 — before extracting anything, compare `crates/ty_ide/src/docstring/document/google.rs` and `crates/ty_ide/src/docstring/document/numpy.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (6 lines × 2) crates/ty_ide/src/docstring/document/google.rs:623 — crates/ty_ide/src/docstring/document/google.rs:623-628 | crates/ty_ide/src/docstring/document/numpy.rs:559-564 — before extracting anything, compare `crates/ty_ide/src/docstring/document/google.rs` and `crates/ty_ide/src/docstring/document/numpy.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • + 9 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×33
  • Duplicated block (13 lines × 2) crates/ruff/src/printer.rs:226 — crates/ruff/src/printer.rs:226-238 | crates/ruff/src/printer.rs:255-267 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) crates/ruff_annotate_snippets/src/renderer/render.rs:363 — crates/ruff_annotate_snippets/src/renderer/render.rs:363-375 | crates/ruff_annotate_snippets/src/renderer/render.rs:393-405 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/fix/mod.rs:99 — crates/ruff_linter/src/fix/mod.rs:99-111 | crates/ty_python_semantic/src/fixes.rs:550-562 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/noqa.rs:994 — crates/ruff_linter/src/noqa.rs:994-1006 | crates/ruff_linter/src/noqa.rs:1020-1032 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/noqa.rs:994` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_linter/src/noqa.rs:1033` calls `Some`, `Noqa` and `crates/ruff_linter/src/noqa.rs:1007` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:888 — crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:888-900 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:923-935 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:888` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs:188 — crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs:188-200 | crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs:227-239 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs:245 — crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs:245-257 | crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs:262-274 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs:55 — crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs:55-67 | crates/ruff_linter/src/rules/pylint/rules/comparison_with_itself.rs:103-115 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:90 — crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:90-102 | crates/ruff_linter/src/rules/pylint/rules/super_without_brackets.rs:107-119 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:90` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (13 lines × 2) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:201 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:201-213 | crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs:220-232 — before extracting anything, compare `crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs` and `crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:201` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ruff_python_ast/src/int.rs:15 — crates/ruff_python_ast/src/int.rs:15-27 | crates/ruff_python_ast/src/int.rs:54-66 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/int.rs:15` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ruff_python_formatter/src/string/implicit.rs:179 — crates/ruff_python_formatter/src/string/implicit.rs:179-191 | crates/ruff_python_formatter/src/string/implicit.rs:209-221 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/string/implicit.rs:179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ruff_server/src/server/schedule/thread/pool.rs:115 — crates/ruff_server/src/server/schedule/thread/pool.rs:115-127 | crates/ty_server/src/server/schedule/thread/pool.rs:118-130 — before extracting anything, compare `crates/ruff_server/src/server/schedule/thread/pool.rs` and `crates/ty_server/src/server/schedule/thread/pool.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 71 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (13 lines × 2) crates/ruff_server/src/session/client.rs:61 — crates/ruff_server/src/session/client.rs:61-73 | crates/ty_server/src/session/client.rs:317-329 — before extracting anything, compare `crates/ruff_server/src/session/client.rs` and `crates/ty_server/src/session/client.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/session/client.rs:61` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ty_python_core/src/builder.rs:5412 — crates/ty_python_core/src/builder.rs:5412-5424 | crates/ty_python_core/src/builder.rs:5466-5478 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/builder.rs:5412` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) crates/ty_python_core/src/builder.rs:5821 — crates/ty_python_core/src/builder.rs:5821-5833 | crates/ty_python_core/src/builder.rs:5842-5854 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/builder.rs:5821` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ty_python_core/src/narrowing_constraints.rs:334 — crates/ty_python_core/src/narrowing_constraints.rs:334-346 | crates/ty_python_core/src/narrowing_constraints.rs:415-427 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/narrowing_constraints.rs:334` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:11398 — crates/ty_python_semantic/src/types/call/bind.rs:11398-11410 | crates/ty_python_semantic/src/types/call/bind.rs:11434-11446 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:11398` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/class/static_literal.rs:558 — crates/ty_python_semantic/src/types/class/static_literal.rs:558-570 | crates/ty_python_semantic/src/types/generics.rs:782-794 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/static_literal.rs:558` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:2075 — crates/ty_python_semantic/src/types/constraints/sequents.rs:2075-2087 | crates/ty_python_semantic/src/types/constraints/sequents.rs:2126-2138 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:2075` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/infer.rs:660 — crates/ty_python_semantic/src/types/infer.rs:660-672 | crates/ty_python_semantic/src/types/infer.rs:781-793 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer.rs:660` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:2961 — crates/ty_python_semantic/src/types/infer/builder.rs:2961-2973 | crates/ty_python_semantic/src/types/infer/builder.rs:3016-3028 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:2961` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:12299 — crates/ty_python_semantic/src/types/infer/builder.rs:12299-12311 | crates/ty_python_semantic/src/types/infer/builder.rs:12702-12714 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:12299` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `super) fn finish_statement(mut` in one and `super) fn finish_scope(mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs:571 — crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs:571-583 | crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:907-919 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs:571` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3488 — crates/ty_python_semantic/src/types/signatures.rs:3488-3500 | crates/ty_python_semantic/src/types/signatures.rs:3518-3530 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3488` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 8 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×33
  • Duplicated block (5 lines × 2) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:702 — crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:702-706 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:728-735 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:702` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 2) crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:138 — crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:138-144 | crates/ruff_linter/src/rules/flake8_async/rules/long_sleep_not_forever.rs:143-147 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:138` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (5 lines × 2) crates/ruff_linter/src/rules/flake8_return/rules/function.rs:660 — crates/ruff_linter/src/rules/flake8_return/rules/function.rs:660-664 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_assign_before_yield.rs:128-132 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:683 — crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:683-687 | crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:802-806 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) crates/ruff_macros/src/map_codes.rs:368 — crates/ruff_macros/src/map_codes.rs:368-372 | crates/ruff_macros/src/map_codes.rs:375-379 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_macros/src/map_codes.rs:368` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) crates/ruff_python_formatter/src/comments/format.rs:565 — crates/ruff_python_formatter/src/comments/format.rs:565-569 | crates/ruff_python_formatter/src/comments/format.rs:614-618 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/comments/format.rs:565` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_python_formatter/src/comments/format.rs:613` calls `rev` and `crates/ruff_python_formatter/src/comments/format.rs:564` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) crates/ruff_python_formatter/src/comments/placement.rs:1334 — crates/ruff_python_formatter/src/comments/placement.rs:1334-1338 | crates/ruff_python_formatter/src/comments/placement.rs:1738-1742 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_python_formatter/src/comments/placement.rs:1733` calls `start`, `end`, `dangling` and `crates/ruff_python_formatter/src/comments/placement.rs:1330` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) crates/ty_ide/src/goto_type_definition.rs:15 — crates/ty_ide/src/goto_type_definition.rs:15-19 | crates/ty_ide/src/type_hierarchy.rs:38-42 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (5 lines × 2) crates/ty_python_core/src/definition.rs:1047 — crates/ty_python_core/src/definition.rs:1047-1051 | crates/ty_python_core/src/definition.rs:1108-1112 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) crates/ty_python_core/src/place.rs:709 — crates/ty_python_core/src/place.rs:709-713 | crates/ty_python_core/src/place.rs:752-756 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/class/typed_dict.rs:308 — crates/ty_python_semantic/src/types/class/typed_dict.rs:308-312 | crates/ty_python_semantic/src/types/class/typed_dict.rs:693-698 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/typed_dict.rs:308` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/class/typed_dict.rs:408 — crates/ty_python_semantic/src/types/class/typed_dict.rs:408-415 | crates/ty_python_semantic/src/types/class/typed_dict.rs:597-601 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/typed_dict.rs:408` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1499 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1499-1503 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1784-1788 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1499` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/dedicated/pydantic.rs:891 — crates/ty_python_semantic/src/types/dedicated/pydantic.rs:891-895 | crates/ty_python_semantic/src/types/dedicated/pydantic.rs:987-991 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/dedicated/pydantic.rs:891` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:10281 — crates/ty_python_semantic/src/types/infer/builder.rs:10281-10285 | crates/ty_python_semantic/src/types/infer/builder/subscript.rs:1753-1757 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:10281` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/method.rs:699 — crates/ty_python_semantic/src/types/method.rs:699-703 | crates/ty_python_semantic/src/types/method.rs:735-739 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/method.rs:699` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ty_python_semantic/src/types/method.rs:741` calls `positional_only`, `Some`, `new_static` and `crates/ty_python_semantic/src/types/method.rs:705` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/narrow.rs:5261 — crates/ty_python_semantic/src/types/narrow.rs:5261-5267 | crates/ty_python_semantic/src/types/narrow.rs:5294-5298 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/narrow.rs:5261` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/overrides.rs:1495 — crates/ty_python_semantic/src/types/overrides.rs:1495-1499 | crates/ty_python_semantic/src/types/overrides/attributes.rs:754-758 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/overrides.rs:1495` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/type_alias.rs:252 — crates/ty_python_semantic/src/types/type_alias.rs:252-256 | crates/ty_python_semantic/src/types/type_alias.rs:290-294 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (5 lines × 2) crates/ruff/src/stdin.rs:5 — crates/ruff/src/stdin.rs:5-9 | crates/ruff_python_formatter/src/main.rs:11-15 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) crates/ruff_linter/src/checkers/ast/mod.rs:645 — crates/ruff_linter/src/checkers/ast/mod.rs:645-649 | crates/ty_python_core/src/builder.rs:3476-3480 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `f` to `impl FnOnce(&mut SemanticSyntaxChecker, &Checker)` in one and `impl FnOnce(&mut SemanticSyntaxChecker, &Self)` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 2) crates/ruff_python_parser/src/lexer/cursor.rs:48 — crates/ruff_python_parser/src/lexer/cursor.rs:48-52 | crates/ruff_python_trivia/src/cursor.rs:59-63 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) crates/ty_ide/src/docstring/document/google.rs:630 — crates/ty_ide/src/docstring/document/google.rs:630-634 | crates/ty_ide/src/docstring/document/numpy.rs:566-570 — before extracting anything, compare `crates/ty_ide/src/docstring/document/google.rs` and `crates/ty_ide/src/docstring/document/numpy.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (5 lines × 2) crates/ty_python_core/src/reachability_constraints.rs:116 — crates/ty_python_core/src/reachability_constraints.rs:116-120 | crates/ty_python_semantic/src/types/constraints.rs:2378-2384 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (5 lines × 2) crates/ty_python_semantic/src/types/class/static_literal.rs:625 — crates/ty_python_semantic/src/types/class/static_literal.rs:625-629 | crates/ty_python_semantic/src/types/function.rs:462-466 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • + 8 more in this group — see findings.md.
D17 · Explicit Debt · FixmeComment · ×32
  • FixmeComment crates/ty_site_packages/src/lib.rs:2113 — // FIXME: it would be nice to include a "we know the python name" fastpath like in — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_server/src/server/schedule/thread/priority.rs:280 — // FIXME: Windows has QoS APIs, we should use them! — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ruff_server/src/server/schedule/thread/priority.rs:280 — // FIXME: Windows has QoS APIs, we should use them! — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4005 — // FIXME: Should include `foofoo`. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4137 — // FIXME: Should include `foofoo` (but not `foofoofoo`). — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4159 — // FIXME: Should include `foofoo` (but not `foofoofoo`). — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4175 — // FIXME: Should include `foofoo` (but not `foofoofoo`). — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4195 — // FIXME: Should include `foofoo` (but not `foofoofoo`). — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4216 — // FIXME: Should include `foofoo` (but not `foofoofoo`). — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4382 — // FIXME: Should include `foo`. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4474 — // FIXME: Should include `bar`, `quux` and `frob`. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:4494 — // FIXME: Should include `bar`, `quux` and `frob`. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:5770 — // FIXME: Should NOT include `foo` here, since — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/completion.rs:9718 — // FIXME: Should not contain False as we're expecting an iterable — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/importer.rs:1059 — // FIXME: This test (and the one below it) aren't — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/importer.rs:1276 — // FIXME: This test (and the one below it) aren't — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/importer.rs:1145 — // FIXME: This test (and the one below it) aren't quite right. We — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/symbols.rs:563 — // FIXME: We'd ideally include the names — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/symbols.rs:794 — // FIXME: We should do this without copying every — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/symbols.rs:1522 — // FIXME: We don't currently try to evaluate `if` — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/symbols.rs:1954 — // FIXME: This shouldn't include `bar`. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/symbols.rs:1970 — // FIXME: This shouldn't include `bar`. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ty_ide/src/symbols.rs:2005 — // FIXME: This shouldn't include `bar`. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ruff_python_parser/resources/invalid/statements/function_type_parameters.py:1 — # FIXME: The type param related error message and the parser recovery are looking pretty good **except** — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • FixmeComment crates/ruff_python_parser/resources/invalid/statements/if_extra_closing_parentheses.py:1 — # FIXME(micha): This creates two syntax errors instead of just one (and overlapping ones) — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • + 7 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×32
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:244 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:244-255 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:480-491 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/airflow/helpers.rs:142 — crates/ruff_linter/src/rules/airflow/helpers.rs:142-153 | crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:822-833 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/helpers.rs` and `crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:822` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:99 — crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:99-110 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs:115-126 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs:57 — crates/ruff_linter/src/rules/flake8_bandit/rules/request_with_no_cert_validation.rs:57-68 | crates/ruff_linter/src/rules/flake8_bandit/rules/request_without_timeout.rs:66-77 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs:132 — crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs:132-143 | crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs:137-148 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs:129` calls `iter`, `chain`, `default` and `crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs:134` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:578 — crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:578-589 | crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:611-622 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:578` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:188 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:188-199 | crates/ruff_linter/src/rules/pylint/rules/dict_iter_missing_items.rs:80-92 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:188` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:226 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:226-237 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:245-262 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:226` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs:378 — crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs:378-389 | crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs:396-407 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/redefined_loop_name.rs:378` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:172 — crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:172-183 | crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs:157-168 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:172` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ruff_server/src/edit/text_document.rs:114 — crates/ruff_server/src/edit/text_document.rs:114-125 | crates/ty_server/src/document/text_document.rs:124-135 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/edit/text_document.rs:114` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ruff_server/src/server.rs:143 — crates/ruff_server/src/server.rs:143-154 | crates/ty_server/src/server.rs:189-200 — before extracting anything, compare `crates/ruff_server/src/server.rs` and `crates/ty_server/src/server.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) crates/ty/src/python_version.rs:26 — crates/ty/src/python_version.rs:26-37 | crates/ty_project/src/metadata/python_version.rs:55-66 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types.rs:5824 — crates/ty_python_semantic/src/types.rs:5824-5835 | crates/ty_python_semantic/src/types.rs:5879-5890 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types.rs:5824` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:1185 — crates/ty_python_semantic/src/types/call/bind.rs:1185-1196 | crates/ty_python_semantic/src/types/call/bind.rs:1213-1224 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:1185` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:10709 — crates/ty_python_semantic/src/types/call/bind.rs:10709-10720 | crates/ty_python_semantic/src/types/call/bind.rs:10789-10800 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:10709` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:706 — crates/ty_python_semantic/src/types/infer/builder.rs:706-717 | crates/ty_python_semantic/src/types/infer/builder.rs:763-774 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:8864 — crates/ty_python_semantic/src/types/infer/builder.rs:8864-8875 | crates/ty_python_semantic/src/types/infer/builder.rs:8892-8903 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:8864` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types/relation.rs:3024 — crates/ty_python_semantic/src/types/relation.rs:3024-3035 | crates/ty_python_semantic/src/types/relation.rs:3071-3082 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/relation.rs:3024` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:644 — crates/ty_python_semantic/src/types/signatures.rs:644-655 | crates/ty_python_semantic/src/types/signatures.rs:2492-2503 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) crates/ty_python_semantic/src/types/tuple.rs:2831 — crates/ty_python_semantic/src/types/tuple.rs:2831-2842 | crates/ty_python_semantic/src/types/tuple.rs:2861-2872 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/tuple.rs:2831` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 2) crates/ty_site_packages/src/lib.rs:2080 — crates/ty_site_packages/src/lib.rs:2080-2091 | crates/ty_site_packages/src/lib.rs:2152-2163 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_site_packages/src/lib.rs:2152` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_site_packages/src/lib.rs:2076` calls `from_executable_home_path` and `crates/ty_site_packages/src/lib.rs:2147` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12 lines × 2) crates/ruff_python_formatter/src/expression/mod.rs:629 — crates/ruff_python_formatter/src/expression/mod.rs:629-640 | crates/ruff_python_formatter/src/pattern/mod.rs:357-368 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: the declarations holding them bind `count` to `u32` in one and `usize` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/flake8_async/rules/blocking_http_call.rs:74 — crates/ruff_linter/src/rules/flake8_async/rules/blocking_http_call.rs:74-85 | crates/ruff_linter/src/rules/flake8_async/rules/blocking_sleep.rs:54-65 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (12 lines × 2) crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs:244 — crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs:244-255 | crates/ruff_linter/src/rules/pylint/rules/too_many_statements.rs:76-87 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/too_many_branches.rs:244` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • + 7 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×29
  • Duplicated block (7 lines × 2) crates/ruff/src/printer.rs:245 — crates/ruff/src/printer.rs:245-251 | crates/ruff/src/printer.rs:431-437 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff/src/printer.rs:243` calls `try_from` and `crates/ruff/src/printer.rs:430` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:381 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:381-387 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:487-493 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:381` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs:212 — crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs:212-218 | crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs:238-244 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/unnecessary_list_cast.rs:212` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs:162 — crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs:162-168 | crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs:182-188 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/unnecessary_dunder_call.rs:162` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:309 — crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:309-315 | crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:387-393 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:309` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs:197 — crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs:197-203 | crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs:208-214 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs:197` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs:111 — crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs:111-117 | crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs:119-125 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/ruff/rules/collection_literal_concatenation.rs:111` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_python_parser/src/parser/expression.rs:269 — crates/ruff_python_parser/src/parser/expression.rs:269-278 | crates/ruff_python_parser/src/parser/expression.rs:1252-1258 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) crates/ty_ide/src/semantic_tokens.rs:1023 — crates/ty_ide/src/semantic_tokens.rs:1023-1029 | crates/ty_python_core/src/builder/loop_bindings_visitor.rs:93-99 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_ide/src/semantic_tokens.rs:1023` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/class/static_literal.rs:1568 — crates/ty_python_semantic/src/types/class/static_literal.rs:1568-1574 | crates/ty_python_semantic/src/types/class/static_literal.rs:1637-1643 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/static_literal.rs:1568` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/diagnostic.rs:4727 — crates/ty_python_semantic/src/types/diagnostic.rs:4727-4733 | crates/ty_python_semantic/src/types/diagnostic.rs:4776-4782 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/diagnostic.rs:4727` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/display.rs:1230 — crates/ty_python_semantic/src/types/display.rs:1230-1236 | crates/ty_python_semantic/src/types/display.rs:1792-1798 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:304 — crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:304-310 | crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:351-357 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:304` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2917 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2917-2923 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2943-2949 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2917` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/method.rs:714 — crates/ty_python_semantic/src/types/method.rs:714-720 | crates/ty_python_semantic/src/types/method.rs:740-746 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/method.rs:714` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/method.rs:737` calls `positional_only`, `Some`, `new_static` and `crates/ty_python_semantic/src/types/method.rs:712` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/relation.rs:648 — crates/ty_python_semantic/src/types/relation.rs:648-654 | crates/ty_python_semantic/src/types/relation.rs:727-733 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/relation.rs:648` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs:100 — crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs:100-106 | crates/ruff_linter/src/rules/pylint/rules/repeated_equality_comparison.rs:108-114 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs:70 — crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs:70-76 | crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs:68-74 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs:70` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/constraints/variables.rs:1171 — crates/ty_python_semantic/src/types/constraints/variables.rs:1171-1177 | crates/ty_python_semantic/src/types/constraints/variables.rs:1324-1330 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/variables.rs:1171` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/flake8_async/rules/blocking_path_methods.rs:198 — crates/ruff_linter/src/rules/flake8_async/rules/blocking_path_methods.rs:198-204 | crates/ruff_python_semantic/src/analyze/typing.rs:968-974 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_async/rules/blocking_path_methods.rs:198` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `semantic` to `&ruff_python_semantic::SemanticModel` in one and `&SemanticModel` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (7 lines × 2) crates/ruff_server/src/edit.rs:35 — crates/ruff_server/src/edit.rs:35-41 | crates/ty_server/src/document.rs:65-71 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) crates/ruff_server/src/server/schedule.rs:39 — crates/ruff_server/src/server/schedule.rs:39-45 | crates/ty_server/src/server/schedule.rs:39-45 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (7 lines × 2) crates/ty_python_semantic/src/types/narrow.rs:4933 — crates/ty_python_semantic/src/types/narrow.rs:4933-4939 | crates/ty_python_semantic/src/types/unpacker.rs:720-726 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_continue.rs:66 — crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_continue.rs:66-72 | crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_pass.rs:62-68 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_continue.rs:66` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 2) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs:138 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_set.rs:138-144 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_list_call.rs:134-140 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • + 4 more in this group — see findings.md.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×24
  • Duplicated block (15 lines × 2) crates/ruff_db/src/diagnostic/render.rs:177 — crates/ruff_db/src/diagnostic/render.rs:177-191 | crates/ruff_db/src/diagnostic/render.rs:229-243 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `diag` to `&'a Diagnostic` in one and `&'a SubDiagnostic` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (15 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:262 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:262-276 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:519-533 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/statement.rs:563 — crates/ruff_linter/src/checkers/ast/analyze/statement.rs:563-577 | crates/ruff_linter/src/checkers/ast/analyze/statement.rs:725-739 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) crates/ruff_linter/src/rules/airflow/helpers.rs:86 — crates/ruff_linter/src/rules/airflow/helpers.rs:86-100 | crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:759-773 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/helpers.rs` and `crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/helpers.rs:86` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:906 — crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:906-920 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:941-955 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:906` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs:323 — crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs:323-337 | crates/ruff_linter/src/rules/pycodestyle/rules/literal_comparisons.rs:342-356 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:256 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:256-270 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs:183-197 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:256` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:244 — crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:244-258 | crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:264-278 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:244` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ruff_python_formatter/src/statement/stmt_global.rs:22 — crates/ruff_python_formatter/src/statement/stmt_global.rs:22-36 | crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs:22-36 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_global.rs:22` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&StmtGlobal` in one and `&StmtNonlocal` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (15 lines × 2) crates/ruff_server/src/server/api.rs:357 — crates/ruff_server/src/server/api.rs:357-371 | crates/ty_server/src/server/api.rs:552-566 — before extracting anything, compare `crates/ruff_server/src/server/api.rs` and `crates/ty_server/src/server/api.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/api.rs:357` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ruff_server/src/server/api/requests/format.rs:101 — crates/ruff_server/src/server/api/requests/format.rs:101-115 | crates/ruff_server/src/server/api/requests/format_range.rs:62-76 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (15 lines × 2) crates/ty_ide/src/symbols.rs:1313 — crates/ty_ide/src/symbols.rs:1313-1327 | crates/ty_ide/src/symbols.rs:1356-1370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_ide/src/symbols.rs:1313` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/attribute_write.rs:463 — crates/ty_python_semantic/src/types/attribute_write.rs:463-477 | crates/ty_python_semantic/src/types/infer/builder.rs:3255-3269 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/attribute_write.rs:463` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:3782 — crates/ty_python_semantic/src/types/call/bind.rs:3782-3796 | crates/ty_python_semantic/src/types/call/bind.rs:4668-4682 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:3782` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1069 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1069-1083 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1095-1109 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1069` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/generics.rs:1488 — crates/ty_python_semantic/src/types/generics.rs:1488-1502 | crates/ty_python_semantic/src/types/generics.rs:1627-1641 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/generics.rs:1488` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/infer.rs:2130 — crates/ty_python_semantic/src/types/infer.rs:2130-2144 | crates/ty_python_semantic/src/types/infer.rs:2378-2392 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:4546 — crates/ty_python_semantic/src/types/infer/builder.rs:4546-4560 | crates/ty_python_semantic/src/types/infer/builder.rs:4821-4835 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:4546` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/infer/builder/imports.rs:271 — crates/ty_python_semantic/src/types/infer/builder/imports.rs:271-285 | crates/ty_python_semantic/src/types/infer/builder/imports.rs:484-498 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/imports.rs:271` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `super) fn infer_import_definition( &mut` in one and `&mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3723 — crates/ty_python_semantic/src/types/signatures.rs:3723-3737 | crates/ty_python_semantic/src/types/signatures.rs:3869-3884 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3723` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3896 — crates/ty_python_semantic/src/types/signatures.rs:3896-3910 | crates/ty_python_semantic/src/types/signatures.rs:4012-4027 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3896` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (15 lines × 2) crates/ty_python_semantic/src/types/tuple.rs:704 — crates/ty_python_semantic/src/types/tuple.rs:704-718 | crates/ty_python_semantic/src/types/tuple.rs:743-757 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/tuple.rs:704` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) crates/ty_project/src/metadata/options.rs:1887 — crates/ty_project/src/metadata/options.rs:1887-1901 | crates/ty_project/src/metadata/options.rs:1903-1917 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (15 lines × 2) crates/ruff_server/src/edit/notebook.rs:94 — crates/ruff_server/src/edit/notebook.rs:94-108 | crates/ty_server/src/document/notebook.rs:119-133 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/edit/notebook.rs:94` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D2 · Cognitive Complexity · Type · ×21
  • Type::member_lookup_with_policy_and_receiver::member_lookup_with_policy_impl (cognitive 67) crates/ty_python_semantic/src/types.rs:6090 — Type::member_lookup_with_policy_and_receiver::member_lookup_with_policy_impl has cognitive complexity 67 (threshold 15). Drivers by points: boolean chains 27, if/else 16 (26 pts), match/switch 7 (14 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::bindings_with_receiver (cognitive 48) crates/ty_python_semantic/src/types.rs:7162 — Type::bindings_with_receiver has cognitive complexity 48 (threshold 15). Drivers by points: if/else 14 (29 pts), match/switch 7 (14 pts), boolean chains 5 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::apply_type_mapping_impl (cognitive 42) crates/ty_python_semantic/src/types.rs:9931 — Type::apply_type_mapping_impl has cognitive complexity 42 (threshold 15). Drivers by points: if/else 14 (21 pts), match/switch 6 (14 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::constructor_bindings (cognitive 40) crates/ty_python_semantic/src/types.rs:8107 — Type::constructor_bindings has cognitive complexity 40 (threshold 15). Drivers by points: if/else 23 (30 pts), boolean chains 5, match/switch 3 (4 pts), loops 1 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • Type::try_bool_impl (cognitive 38) crates/ty_python_semantic/src/types/bool.rs:66 — Type::try_bool_impl has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (20 pts), match/switch 8 (13 pts), boolean chains 4, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::subscript (cognitive 38) crates/ty_python_semantic/src/types/subscript.rs:647 — Type::subscript has cognitive complexity 38 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 13, match/switch 6 (10 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::generator_types (cognitive 31) crates/ty_python_semantic/src/types.rs:8860 — Type::generator_types has cognitive complexity 31 (threshold 15). Drivers by points: match/switch 7 (13 pts), if/else 7 (10 pts), boolean chains 4, loops 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::try_upcast_to_callable_impl (cognitive 30) crates/ty_python_semantic/src/types/callable.rs:232 — Type::try_upcast_to_callable_impl has cognitive complexity 30 (threshold 15). Drivers by points: loops 3 (11 pts), match/switch 5 (10 pts), if/else 5 (8 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::try_iterate_with_mode::non_async_special_case (cognitive 28) crates/ty_python_semantic/src/types/iteration.rs:246 — Type::try_iterate_with_mode::non_async_special_case has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (17 pts), loops 2 (6 pts), match/switch 3 (5 pts) (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident. This shape REPEATS in the file: one other method here (Type::try_iterate_with_mode) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • Type::find_legacy_typevars_impl (cognitive 26) crates/ty_python_semantic/src/types.rs:10430 — Type::find_legacy_typevars_impl has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 5 (10 pts), match/switch 3 (4 pts) (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Type::in_type_expression_impl (cognitive 25) crates/ty_python_semantic/src/types.rs:9184 — Type::in_type_expression_impl has cognitive complexity 25 (threshold 15). Drivers by points: match/switch 6 (12 pts), if/else 4 (9 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 12). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Type::try_call_dunder_get::try_call_dunder_get_inner (cognitive 24) crates/ty_python_semantic/src/types.rs:5208 — Type::try_call_dunder_get::try_call_dunder_get_inner has cognitive complexity 24 (threshold 15). Drivers by points: if/else 16 (21 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 6). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • Type::visit_specialization_impl (cognitive 23) crates/ty_python_semantic/src/types.rs:4089 — Type::visit_specialization_impl has cognitive complexity 23 (threshold 15). Drivers by points: loops 6 (17 pts), if/else 2 (4 pts), match/switch 1 (2 pts) (nesting depth added 14). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • Type::to_meta_type_with_recursion::to_meta_type_inner (cognitive 21) crates/ty_python_semantic/src/types.rs:9470 — Type::to_meta_type_with_recursion::to_meta_type_inner has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (9 pts), match/switch 4 (8 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Type::map_type (cognitive 20) crates/ty_python_semantic/src/types.rs:10118 — Type::map_type has cognitive complexity 20 (threshold 15). Drivers by points: match/switch 7 (14 pts), if/else 4 (6 pts) (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Type::try_iterate_with_mode (cognitive 18) crates/ty_python_semantic/src/types/iteration.rs:240 — Type::try_iterate_with_mode has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (24 pts), match/switch 8 (16 pts), loops 2 (6 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (Type::try_iterate_with_mode::non_async_special_case) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • Type::class_namespace_member (cognitive 18) crates/ty_python_semantic/src/types.rs:4783 — Type::class_namespace_member has cognitive complexity 18 (threshold 15). Drivers by points: if/else 15, boolean chains 2, match/switch 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • Type::can_suppress_exceptions::can_suppress_exceptions_impl (cognitive 17) crates/ty_python_semantic/src/types/context_manager.rs:73 — Type::can_suppress_exceptions::can_suppress_exceptions_impl has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::identity_comparison_type (cognitive 17) crates/ty_python_semantic/src/types/infer/comparisons.rs:80 — Type::identity_comparison_type has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (9 pts), loops 2 (4 pts), match/switch 3 (4 pts) (nesting depth added 6). Most of this is not in the body itself: 1 of the 17 points is its own statement and the rest belongs to 2 function items inside it that branch (upcast, upcast_partial). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
  • Type::class_member_with_policy_inner (cognitive 17) crates/ty_python_semantic/src/types.rs:4509 — Type::class_member_with_policy_inner has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 3, match/switch 2 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Type::pending_narrowing_normalized (cognitive 16) crates/ty_python_semantic/src/types.rs:3872 — Type::pending_narrowing_normalized has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (13 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (11 corresponding lines) · ×21
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types/literal.rs:140 — crates/ty_python_semantic/src/types/literal.rs:140-150 | crates/ty_python_semantic/src/types/literal.rs:155-165 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types/infer.rs:136 — crates/ty_python_semantic/src/types/infer.rs:136-150 | crates/ty_python_semantic/src/types/infer.rs:176-186 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_server/src/server/api.rs:228 — crates/ruff_server/src/server/api.rs:228-238 | crates/ty_server/src/server/api.rs:417-435 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_python_parser/src/parser/statement.rs:3856 — crates/ruff_python_parser/src/parser/statement.rs:3856-3867 | crates/ruff_python_parser/src/parser/statement.rs:3897-3907 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types/attribute_write.rs:1513 — crates/ty_python_semantic/src/types/attribute_write.rs:1513-1523 | crates/ty_python_semantic/src/types/protocol_class.rs:2525-2538 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_core/src/use_def.rs:1247 — crates/ty_python_core/src/use_def.rs:1247-1257 | crates/ty_python_core/src/use_def.rs:1390-1400 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types/narrow.rs:3777 — crates/ty_python_semantic/src/types/narrow.rs:3777-3792 | crates/ty_python_semantic/src/types/narrow.rs:4857-4867 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/duplicate_entry_in_dunder_all.rs:96 — crates/ruff_linter/src/rules/ruff/rules/duplicate_entry_in_dunder_all.rs:96-106 | crates/ruff_linter/src/rules/ruff/rules/sort_dunder_all.rs:145-160 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_db/src/display.rs:26 — crates/ruff_db/src/display.rs:26-36 | crates/ty_python_semantic/src/types/display.rs:501-511 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_ide/src/docstring/markdown/structured/google.rs:26 — crates/ty_ide/src/docstring/markdown/structured/google.rs:26-36 | crates/ty_ide/src/docstring/markdown/structured/numpy.rs:30-40 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types/signatures.rs:5439 — crates/ty_python_semantic/src/types/signatures.rs:5439-5449 | crates/ty_python_semantic/src/types/signatures.rs:5497-5507 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_python_ast/src/visitor/source_order.rs:191 — crates/ruff_python_ast/src/visitor/source_order.rs:191-201 | crates/ruff_python_ast/src/visitor/source_order.rs:513-524 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types/protocol_class.rs:617 — crates/ty_python_semantic/src/types/protocol_class.rs:617-627 | crates/ty_python_semantic/src/types/protocol_class.rs:639-650 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/non_octal_permissions.rs:173 — crates/ruff_linter/src/rules/ruff/rules/non_octal_permissions.rs:173-183 | crates/ruff_linter/src/rules/ruff/rules/non_octal_permissions.rs:197-207 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_module_resolver/src/resolve/search.rs:964 — crates/ty_module_resolver/src/resolve/search.rs:964-974 | crates/ty_module_resolver/src/resolve/search.rs:980-990 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:4036 — crates/ty_python_semantic/src/types/diagnostic.rs:4036-4047 | crates/ty_python_semantic/src/types/diagnostic.rs:4076-4086 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ty_python_semantic/src/types.rs:2372 — crates/ty_python_semantic/src/types.rs:2372-2384 | crates/ty_python_semantic/src/types/protocol_class.rs:1436-1446 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs:50 — crates/ruff_linter/src/rules/flake8_pyi/rules/numeric_literal_too_long.rs:50-60 | crates/ruff_linter/src/rules/flake8_pyi/rules/pass_statement_stub_body.rs:44-54 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/mdtest/src/lib.rs:276 — crates/mdtest/src/lib.rs:276-286 | crates/ty_server/src/server/api/requests/execute_command.rs:104-114 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs:72 — crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs:72-82 | crates/ruff_linter/src/rules/refurb/rules/if_expr_min_max.rs:74-85 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (11 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_literal_union.rs:55 — crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_literal_union.rs:55-65 | crates/ruff_linter/src/rules/pylint/rules/if_stmt_min_max.rs:60-70 — These two members are one piece of code written twice and then edited apart: 11 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D6 · Cohesion (LCOM4) · Low cohesion · ×21
  • Low cohesion: UnionType (LCOM4 11) crates/ty_python_semantic/src/types/set_theoretic.rs:26 — UnionType's methods fall into 11 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 11 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Project (LCOM4 8) crates/ty_project/src/lib.rs:67 — Project's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Specialization (LCOM4 8) crates/ty_python_semantic/src/types/generics.rs:1156 — Specialization's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ProtocolInterface (LCOM4 8) crates/ty_python_semantic/src/types/protocol_class.rs:447 — ProtocolInterface's methods fall into 8 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 8 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: IntersectionType (LCOM4 7) crates/ty_python_semantic/src/types/set_theoretic.rs:794 — IntersectionType's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: TypeVarConstraints (LCOM4 7) crates/ty_python_semantic/src/types/typevar.rs:2257 — TypeVarConstraints's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: PropertyInstanceType (LCOM4 7) crates/ty_python_semantic/src/types.rs:1647 — PropertyInstanceType's methods fall into 7 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 7 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: File (LCOM4 6) crates/ruff_db/src/files.rs:359 — File's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: OsSystem (LCOM4 6) crates/ruff_db/src/system/os.rs:24 — OsSystem's methods fall into 6 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 6 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ProjectDatabase (LCOM4 5) crates/ty_project/src/db.rs:92 — ProjectDatabase's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: StaticClassLiteral (LCOM4 5) crates/ty_python_semantic/src/types/class/static_literal.rs:83 — StaticClassLiteral's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: GenericAlias (LCOM4 5) crates/ty_python_semantic/src/types/class.rs:392 — GenericAlias's methods fall into 5 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 5 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Rule (LCOM4 4) crates/ruff_macros/src/map_codes.rs:19 — Rule's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: CellOffsets (LCOM4 4) crates/ruff_notebook/src/cell.rs:260 — CellOffsets's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Workspace (LCOM4 4) crates/ruff_wasm/src/lib.rs:269 — Workspace's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: DynamicClassLiteral (LCOM4 4) crates/ty_python_semantic/src/types/class/dynamic_literal.rs:55 — DynamicClassLiteral's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: DynamicEnumLiteral (LCOM4 4) crates/ty_python_semantic/src/types/class/enum_literal.rs:99 — DynamicEnumLiteral's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: Support (LCOM4 4) crates/ty_python_semantic/src/types/constraints/support.rs:22 — Support's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: BoundMethodType (LCOM4 4) crates/ty_python_semantic/src/types/method.rs:23 — BoundMethodType's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: ProtocolClass (LCOM4 4) crates/ty_python_semantic/src/types/protocol_class.rs:59 — ProtocolClass's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
  • Low cohesion: UnionTypeInstance (LCOM4 4) crates/ty_python_semantic/src/types/union_type_instance.rs:15 — UnionTypeInstance's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
D4 · Code Duplication · Edited copy of a member (18 corresponding lines) · ×20
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/display.rs:936 — crates/ty_python_semantic/src/types/display.rs:936-953 | crates/ty_python_semantic/src/types/display.rs:1064-1088 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_wasm/src/lib.rs:637 — crates/ty_wasm/src/lib.rs:637-654 | crates/ty_wasm/src/lib.rs:661-681 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_linter/src/rules/flake8_bugbear/rules/map_without_explicit_strict.rs:65 — crates/ruff_linter/src/rules/flake8_bugbear/rules/map_without_explicit_strict.rs:65-84 | crates/ruff_linter/src/rules/flake8_bugbear/rules/zip_without_explicit_strict.rs:58-75 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/match_pattern.rs:1046 — crates/ty_python_semantic/src/types/match_pattern.rs:1046-1070 | crates/ty_python_semantic/src/types/match_pattern.rs:1081-1098 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_linter/src/checkers/ast/analyze/deferred_lambdas.rs:8 — crates/ruff_linter/src/checkers/ast/analyze/deferred_lambdas.rs:8-29 | crates/ruff_linter/src/checkers/ast/analyze/deferred_with_statements.rs:6-23 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/class/implicit_attributes.rs:535 — crates/ty_python_semantic/src/types/class/implicit_attributes.rs:535-555 | crates/ty_python_semantic/src/types/overrides.rs:317-334 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/class/static_literal.rs:512 — crates/ty_python_semantic/src/types/class/static_literal.rs:512-529 | crates/ty_python_semantic/src/types/function.rs:408-426 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/display.rs:3194 — crates/ty_python_semantic/src/types/display.rs:3194-3213 | crates/ty_python_semantic/src/types/set_theoretic.rs:726-743 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/instance.rs:393 — crates/ty_python_semantic/src/types/instance.rs:393-413 | crates/ty_python_semantic/src/types/instance.rs:442-459 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:3950 — crates/ty_python_semantic/src/types/diagnostic.rs:3950-3968 | crates/ty_python_semantic/src/types/diagnostic.rs:4053-4070 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/infer.rs:324 — crates/ty_python_semantic/src/types/infer.rs:324-342 | crates/ty_python_semantic/src/types/infer.rs:473-490 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_server/src/document/location.rs:32 — crates/ty_server/src/document/location.rs:32-56 | crates/ty_server/src/document/location.rs:71-88 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:145 — crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:145-162 | crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs:130-147 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_python_semantic/src/model.rs:1845 — crates/ruff_python_semantic/src/model.rs:1845-1867 | crates/ruff_python_semantic/src/model.rs:1883-1900 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs:226 — crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs:226-243 | crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs:388-406 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_linter/src/rules/flake8_bandit/rules/django_raw_sql.rs:40 — crates/ruff_linter/src/rules/flake8_bandit/rules/django_raw_sql.rs:40-57 | crates/ruff_linter/src/rules/flake8_django/rules/locals_in_render_function.rs:49-66 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/constraints.rs:551 — crates/ty_python_semantic/src/types/constraints.rs:551-568 | crates/ty_python_semantic/src/types/constraints.rs:633-650 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ty_python_semantic/src/types/narrow.rs:1435 — crates/ty_python_semantic/src/types/narrow.rs:1435-1452 | crates/ty_python_semantic/src/types/narrow.rs:1464-1483 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_python_formatter/src/comments/placement.rs:1256 — crates/ruff_python_formatter/src/comments/placement.rs:1256-1273 | crates/ruff_python_formatter/src/comments/placement.rs:1288-1306 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (18 corresponding lines) crates/ruff_python_ast/src/comparable.rs:1813 — crates/ruff_python_ast/src/comparable.rs:1813-1830 | crates/ruff_python_ast/src/comparable.rs:1945-1962 — These two members are one piece of code written twice and then edited apart: 18 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (9 corresponding lines) · ×19
  • Edited copy of a member (9 corresponding lines) crates/ty_python_semantic/src/types/infer.rs:1412 — crates/ty_python_semantic/src/types/infer.rs:1412-1422 | crates/ty_python_semantic/src/types/infer.rs:1427-1435 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_python_semantic/src/types/dedicated/pytest/collection.rs:269 — crates/ty_python_semantic/src/types/dedicated/pytest/collection.rs:269-282 | crates/ty_python_semantic/src/types/dedicated/pytest/fixtures.rs:1784-1792 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_python_ast/src/expression.rs:182 — crates/ruff_python_ast/src/expression.rs:182-190 | crates/ruff_python_ast/src/expression.rs:196-204 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_python_core/src/narrowing_constraints.rs:168 — crates/ty_python_core/src/narrowing_constraints.rs:168-176 | crates/ty_python_core/src/reachability_constraints.rs:227-235 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_python_literal/src/escape.rs:132 — crates/ruff_python_literal/src/escape.rs:132-140 | crates/ruff_python_literal/src/escape.rs:617-627 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_ide/src/completion.rs:3227 — crates/ty_ide/src/completion.rs:3227-3235 | crates/ty_ide/src/completion.rs:3244-3252 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_python_semantic/src/types/tuple.rs:2132 — crates/ty_python_semantic/src/types/tuple.rs:2132-2142 | crates/ty_python_semantic/src/types/tuple.rs:2168-2176 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_python_semantic/src/types/typevar.rs:75 — crates/ty_python_semantic/src/types/typevar.rs:75-83 | crates/ty_python_semantic/src/types/typevar.rs:105-113 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_python_core/src/use_def.rs:1406 — crates/ty_python_core/src/use_def.rs:1406-1414 | crates/ty_python_core/src/use_def.rs:1420-1428 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_server/src/session/client.rs:67 — crates/ty_server/src/session/client.rs:67-75 | crates/ty_server/src/session/client.rs:87-95 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:341 — crates/ty_python_semantic/src/types/constraints/sequents.rs:341-349 | crates/ty_python_semantic/src/types/constraints/sequents.rs:356-364 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_formatter/src/builders.rs:1727 — crates/ruff_formatter/src/builders.rs:1727-1735 | crates/ruff_formatter/src/builders.rs:2251-2259 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_python_semantic/src/types/infer.rs:924 — crates/ty_python_semantic/src/types/infer.rs:924-932 | crates/ty_python_semantic/src/types/infer.rs:971-979 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs:68 — crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_fromtimestamp.rs:68-79 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_date_today.rs:68-76 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_server/src/server/schedule.rs:21 — crates/ruff_server/src/server/schedule.rs:21-31 | crates/ty_server/src/server/schedule.rs:23-31 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for_loop.rs:204 — crates/ruff_linter/src/rules/flake8_simplify/rules/enumerate_for_loop.rs:204-212 | crates/ruff_linter/src/rules/perflint/rules/try_except_in_loop.rs:127-135 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_python_formatter/src/other/comprehension.rs:155 — crates/ruff_python_formatter/src/other/comprehension.rs:155-163 | crates/ruff_python_formatter/src/statement/stmt_for.rs:16-24 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ty_server/src/server/api/requests/diagnostic.rs:82 — crates/ty_server/src/server/api/requests/diagnostic.rs:82-91 | crates/ty_server/src/server/api/requests/workspace_diagnostic.rs:213-221 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (9 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs:251 — crates/ruff_linter/src/rules/flake8_pyi/rules/unrecognized_version_info.rs:251-259 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs:134-142 — These two members are one piece of code written twice and then edited apart: 9 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D1 · Cyclomatic Complexity · Type · ×18
  • Type::member_lookup_with_policy_and_receiver::member_lookup_with_policy_impl (cyclomatic 118) crates/ty_python_semantic/src/types.rs:6090 — Type::member_lookup_with_policy_and_receiver::member_lookup_with_policy_impl has cyclomatic complexity 118 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::subscript (cyclomatic 64) crates/ty_python_semantic/src/types/subscript.rs:647 — Type::subscript has cyclomatic complexity 64 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::try_bool_impl (cyclomatic 59) crates/ty_python_semantic/src/types/bool.rs:66 — Type::try_bool_impl has cyclomatic complexity 59 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::bindings_with_receiver (cyclomatic 55) crates/ty_python_semantic/src/types.rs:7162 — Type::bindings_with_receiver has cyclomatic complexity 55 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::to_meta_type_with_recursion::to_meta_type_inner (cyclomatic 47) crates/ty_python_semantic/src/types.rs:9470 — Type::to_meta_type_with_recursion::to_meta_type_inner has cyclomatic complexity 47 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::find_legacy_typevars_impl (cyclomatic 47) crates/ty_python_semantic/src/types.rs:10430 — Type::find_legacy_typevars_impl has cyclomatic complexity 47 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::in_type_expression_impl (cyclomatic 46) crates/ty_python_semantic/src/types.rs:9184 — Type::in_type_expression_impl has cyclomatic complexity 46 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::map_type (cyclomatic 44) crates/ty_python_semantic/src/types.rs:10118 — Type::map_type has cyclomatic complexity 44 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::try_upcast_to_callable_impl (cyclomatic 42) crates/ty_python_semantic/src/types/callable.rs:232 — Type::try_upcast_to_callable_impl has cyclomatic complexity 42 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::definition (cyclomatic 39) crates/ty_python_semantic/src/types.rs:10917 — Type::definition has cyclomatic complexity 39 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::recursive_type_normalized_impl (cyclomatic 36) crates/ty_python_semantic/src/types.rs:3949 — Type::recursive_type_normalized_impl has cyclomatic complexity 36 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::identity_comparison_type::upcast (cyclomatic 29) crates/ty_python_semantic/src/types/infer/comparisons.rs:310 — Type::identity_comparison_type::upcast has cyclomatic complexity 29 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::apply_type_mapping_impl (cyclomatic 29) crates/ty_python_semantic/src/types.rs:9931 — Type::apply_type_mapping_impl has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Type::is_singleton (cyclomatic 32) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • Type::constructor_bindings (cyclomatic 28) crates/ty_python_semantic/src/types.rs:8107 — Type::constructor_bindings has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages. This is NOT this file's highest cyclomatic complexity: Type::is_singleton (cyclomatic 32) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • Type::try_iterate_with_mode::non_async_special_case (cyclomatic 27) crates/ty_python_semantic/src/types/iteration.rs:246 — Type::try_iterate_with_mode::non_async_special_case has cyclomatic complexity 27 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Type::generator_types (cyclomatic 26) crates/ty_python_semantic/src/types.rs:8860 — Type::generator_types has cyclomatic complexity 26 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: Type::is_singleton (cyclomatic 32) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • Type::class_member_with_policy_inner (cyclomatic 20) crates/ty_python_semantic/src/types.rs:4509 — Type::class_member_with_policy_inner has cyclomatic complexity 20 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions. This is NOT this file's highest cyclomatic complexity: Type::is_singleton (cyclomatic 32) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • Type::try_call_dunder_get (cyclomatic 17) crates/ty_python_semantic/src/types.rs:5200 — Type::try_call_dunder_get has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 4 of the 17 points are its own statements and the rest belongs to one function item inside it that branches (try_call_dunder_get_inner). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest. This is NOT this file's highest cyclomatic complexity: Type::is_singleton (cyclomatic 32) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D4 · Code Duplication · Edited copy of a member (17 corresponding lines) · ×18
  • Edited copy of a member (17 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:236 — crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:236-252 | crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs:176-192 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_wasm/src/lib.rs:442 — crates/ty_wasm/src/lib.rs:442-458 | crates/ty_wasm/src/lib.rs:496-519 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/constraints/variables.rs:605 — crates/ty_python_semantic/src/types/constraints/variables.rs:605-624 | crates/ty_python_semantic/src/types/constraints/variables.rs:630-646 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/call/bind.rs:1180 — crates/ty_python_semantic/src/types/call/bind.rs:1180-1196 | crates/ty_python_semantic/src/types/call/bind.rs:1208-1224 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/call/bind.rs:3775 — crates/ty_python_semantic/src/types/call/bind.rs:3775-3796 | crates/ty_python_semantic/src/types/call/bind.rs:4666-4682 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/class.rs:640 — crates/ty_python_semantic/src/types/class.rs:640-656 | crates/ty_python_semantic/src/types/instance.rs:2131-2149 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ruff_python_formatter/src/statement/stmt_raise.rs:12 — crates/ruff_python_formatter/src/statement/stmt_raise.rs:12-44 | crates/ruff_python_formatter/src/type_param/type_param_type_var.rs:10-26 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ruff_linter/src/rules/pyflakes/fixes.rs:22 — crates/ruff_linter/src/rules/pyflakes/fixes.rs:22-38 | crates/ruff_linter/src/rules/pyflakes/fixes.rs:46-66 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:5536 — crates/ty_python_semantic/src/types/infer/builder.rs:5536-5554 | crates/ty_python_semantic/src/types/infer/builder.rs:5556-5572 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/class/enum_literal.rs:78 — crates/ty_python_semantic/src/types/class/enum_literal.rs:78-94 | crates/ty_python_semantic/src/types/class/named_tuple.rs:554-571 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ruff_linter/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs:75 — crates/ruff_linter/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs:75-104 | crates/ruff_linter/src/rules/pep8_naming/rules/lowercase_imported_as_non_lowercase.rs:61-77 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ruff_python_ast/src/nodes.rs:2816 — crates/ruff_python_ast/src/nodes.rs:2816-2832 | crates/ruff_python_formatter/src/expression/operator.rs:25-43 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:772 — crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:772-790 | crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:792-808 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:93 — crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:93-119 | crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs:180-196 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:259 — crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:259-275 | crates/ruff_linter/src/rules/ruff/rules/unused_unpacked_variable.rs:91-107 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/ide_support.rs:471 — crates/ty_python_semantic/src/types/ide_support.rs:471-487 | crates/ty_python_semantic/src/types/ide_support.rs:509-532 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:6086 — crates/ty_python_semantic/src/types/diagnostic.rs:6086-6102 | crates/ty_python_semantic/src/types/diagnostic.rs:6110-6127 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (17 corresponding lines) crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:255 — crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:255-271 | crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:305-321 — These two members are one piece of code written twice and then edited apart: 17 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (10 corresponding lines) · ×17
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/attribute_write.rs:1123 — crates/ty_python_semantic/src/types/attribute_write.rs:1123-1132 | crates/ty_python_semantic/src/types/infer/builder.rs:3146-3157 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ruff_python_ast/src/expression.rs:338 — crates/ruff_python_ast/src/expression.rs:338-347 | crates/ruff_python_ast/src/expression.rs:360-369 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ruff_linter/src/cst/matchers.rs:27 — crates/ruff_linter/src/cst/matchers.rs:27-36 | crates/ruff_linter/src/cst/matchers.rs:44-57 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/constraints.rs:2612 — crates/ty_python_semantic/src/types/constraints.rs:2612-2621 | crates/ty_python_semantic/src/types/constraints.rs:2727-2739 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:1148 — crates/ty_python_semantic/src/types/infer/builder.rs:1148-1157 | crates/ty_python_semantic/src/types/infer/builder.rs:1160-1171 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty/src/printer.rs:44 — crates/ty/src/printer.rs:44-53 | crates/ty/src/printer.rs:58-67 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ruff_python_semantic/src/analyze/imports.rs:94 — crates/ruff_python_semantic/src/analyze/imports.rs:94-107 | crates/ruff_python_semantic/src/analyze/imports.rs:115-124 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2067 — crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2067-2076 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2078-2087 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/set_theoretic.rs:1053 — crates/ty_python_semantic/src/types/set_theoretic.rs:1053-1062 | crates/ty_python_semantic/src/types/set_theoretic.rs:1321-1330 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ruff_server/src/server/api/notifications/cancel.rs:16 — crates/ruff_server/src/server/api/notifications/cancel.rs:16-25 | crates/ty_server/src/server/api/notifications/cancel.rs:17-26 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/class.rs:1212 — crates/ty_python_semantic/src/types/class.rs:1212-1221 | crates/ty_python_semantic/src/types/tuple.rs:2687-2696 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ruff_server/src/server/api/requests/format.rs:77 — crates/ruff_server/src/server/api/requests/format.rs:77-92 | crates/ruff_server/src/server/api/requests/format_range.rs:43-52 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/stop_iteration_return.rs:97 — crates/ruff_linter/src/rules/pylint/rules/stop_iteration_return.rs:97-106 | crates/ruff_linter/src/rules/pyupgrade/rules/context_manager_iterator.rs:240-249 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/cyclic.rs:899 — crates/ty_python_semantic/src/types/cyclic.rs:899-908 | crates/ty_python_semantic/src/types/cyclic.rs:1071-1080 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_ide/src/docstring/document/google.rs:340 — crates/ty_ide/src/docstring/document/google.rs:340-349 | crates/ty_ide/src/docstring/document/numpy.rs:241-250 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_semantic/src/types/function.rs:1197 — crates/ty_python_semantic/src/types/function.rs:1197-1208 | crates/ty_python_semantic/src/types/signatures.rs:741-750 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (10 corresponding lines) crates/ty_python_core/src/builder.rs:412 — crates/ty_python_core/src/builder.rs:412-421 | crates/ty_python_core/src/lib.rs:720-729 — These two members are one piece of code written twice and then edited apart: 10 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×17
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:460 — crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:460-475 | crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:476-491 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:460` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1162 — crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1162-1177 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:135-150 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1162` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/flake8_django/rules/all_with_model_form.rs:54 — crates/ruff_linter/src/rules/flake8_django/rules/all_with_model_form.rs:54-69 | crates/ruff_linter/src/rules/flake8_django/rules/exclude_with_model_form.rs:52-67 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_django/rules/all_with_model_form.rs:54` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:387 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:387-402 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:436-451 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:387` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:159 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:159-174 | crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:207-222 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:159` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:229 — crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:229-244 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:314-329 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:229` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs:320 — crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs:320-335 | crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs:628-643 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs:645` calls `iter`, `any` and `crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs:338` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:302 — crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:302-317 | crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:329-344 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:302` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:327` calls `skip` and `crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:300` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs:101 — crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs:101-116 | crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:114-129 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs:101` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:326 — crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:326-341 | crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:401-416 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs:326` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:144 — crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:144-159 | crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs:214-229 — before extracting anything, compare `crates/ruff_linter/src/rules/ruff/rules/needless_else.rs` and `crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:144` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ruff_macros/src/rust_doc.rs:23 — crates/ruff_macros/src/rust_doc.rs:23-38 | crates/ruff_macros/src/violation_metadata.rs:64-79 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (16 lines × 2) crates/ruff_python_formatter/src/comments/placement.rs:135 — crates/ruff_python_formatter/src/comments/placement.rs:135-150 | crates/ruff_python_formatter/src/comments/placement.rs:166-181 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/comments/placement.rs:135` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:4883 — crates/ty_python_semantic/src/types/call/bind.rs:4883-4898 | crates/ty_python_semantic/src/types/call/bind.rs:4904-4919 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:4883` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ty_python_semantic/src/types/constraints/variables.rs:1042 — crates/ty_python_semantic/src/types/constraints/variables.rs:1042-1057 | crates/ty_python_semantic/src/types/constraints/variables.rs:1341-1356 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/variables.rs:1042` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:32 — crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:32-47 | crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:1581-1596 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:32` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:28` calls `use_def_map`, `place_table`, `program_environment` and `crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:1579` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:46 — crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:46-61 | crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:1602-1617 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:46` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×17
  • Duplicated block (14 lines × 2) crates/ruff/src/commands/check.rs:48 — crates/ruff/src/commands/check.rs:48-61 | crates/ruff/src/commands/show_files.rs:24-37 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff/src/commands/check.rs:48` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) crates/ruff_annotate_snippets/src/renderer/render.rs:278 — crates/ruff_annotate_snippets/src/renderer/render.rs:278-291 | crates/ruff_annotate_snippets/src/renderer/render.rs:584-597 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:331 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:331-344 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:453-466 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/checkers/ast/analyze/expression.rs:331` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/checkers/ast/mod.rs:1390 — crates/ruff_linter/src/checkers/ast/mod.rs:1390-1403 | crates/ruff_linter/src/checkers/ast/mod.rs:3346-3359 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/checkers/ast/mod.rs:1390` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:246 — crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:246-259 | crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1079-1092 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs` and `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:246` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:595 — crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:595-608 | crates/ruff_linter/src/rules/flake8_bugbear/rules/abstract_base_class.rs:130-143 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:595` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:208 — crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:208-221 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:295-308 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:208` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:370 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:370-383 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:402-415 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:785 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:785-798 | crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:808-821 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:785` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:117 — crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:117-130 | crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs:130-143 — before extracting anything, compare `crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs` and `crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 49 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) crates/ruff_python_semantic/src/model.rs:1908 — crates/ruff_python_semantic/src/model.rs:1908-1921 | crates/ruff_python_semantic/src/model.rs:1948-1961 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) crates/ruff_server/src/server/api.rs:304 — crates/ruff_server/src/server/api.rs:304-317 | crates/ty_server/src/server/api.rs:502-515 — before extracting anything, compare `crates/ruff_server/src/server/api.rs` and `crates/ty_server/src/server/api.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
  • Duplicated block (14 lines × 2) crates/ty_python_core/src/builder.rs:5435 — crates/ty_python_core/src/builder.rs:5435-5450 | crates/ty_python_core/src/builder.rs:5489-5502 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/builder.rs:5435` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) crates/ty_python_semantic/src/types/class/known.rs:2097 — crates/ty_python_semantic/src/types/class/known.rs:2097-2110 | crates/ty_python_semantic/src/types/class/known.rs:2156-2169 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1171 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1171-1184 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1311-1324 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1171` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) crates/ty_python_semantic/src/types/diagnostic.rs:5570 — crates/ty_python_semantic/src/types/diagnostic.rs:5570-5583 | crates/ty_python_semantic/src/types/diagnostic.rs:5737-5750 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/diagnostic.rs:5570` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 2) crates/ty_python_semantic/src/types/set_theoretic.rs:633 — crates/ty_python_semantic/src/types/set_theoretic.rs:633-646 | crates/ty_python_semantic/src/types/typevar.rs:2341-2354 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic.rs:633` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D2 · Cognitive Complexity · Parser · ×16
  • Parser::parse_impl (cognitive 84) crates/mdtest/src/parser.rs:591 — Parser::parse_impl has cognitive complexity 84 (threshold 15). Drivers by points: if/else 21 (68 pts), match/switch 3 (10 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 56). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Parser::parse_parameters (cognitive 45) crates/ruff_python_parser/src/parser/statement.rs:3326 — Parser::parse_parameters has cognitive complexity 45 (threshold 15). Drivers by points: if/else 25 (39 pts), boolean chains 5, match/switch 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::handle_implicitly_concatenated_strings (cognitive 35) crates/ruff_python_parser/src/parser/expression.rs:1352 — Parser::handle_implicitly_concatenated_strings has cognitive complexity 35 (threshold 15). Drivers by points: match/switch 5 (15 pts), loops 5 (10 pts), if/else 7 (9 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::parse_type_param (cognitive 33) crates/ruff_python_parser/src/parser/statement.rs:3665 — Parser::parse_type_param has cognitive complexity 33 (threshold 15). Drivers by points: if/else 20 (33 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::parse_arguments (cognitive 31) crates/ruff_python_parser/src/parser/expression.rs:721 — Parser::parse_arguments has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (28 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 16). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Parser::parse_lhs_expression (cognitive 29) crates/ruff_python_parser/src/parser/expression.rs:332 — Parser::parse_lhs_expression has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (24 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 16). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Parser::parse_interpolated_element (cognitive 27) crates/ruff_python_parser/src/parser/expression.rs:1698 — Parser::parse_interpolated_element has cognitive complexity 27 (threshold 15). Drivers by points: if/else 14 (19 pts), boolean chains 3, match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::parse_match_pattern_literal (cognitive 26) crates/ruff_python_parser/src/parser/pattern.rs:404 — Parser::parse_match_pattern_literal has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (25 pts), match/switch 1 (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Parser::parse_set_or_dict_like_expression (cognitive 25) crates/ruff_python_parser/src/parser/expression.rs:2096 — Parser::parse_set_or_dict_like_expression has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (21 pts), match/switch 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::parse_ipython_escape_command_value (cognitive 25) crates/ruff_python_parser/src/parser/mod.rs:501 — Parser::parse_ipython_escape_command_value has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 2 (4 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::process_code_block (cognitive 24) crates/mdtest/src/parser.rs:824 — Parser::process_code_block has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 3 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::parse_comma_separated_list (cognitive 23) crates/ruff_python_parser/src/parser/mod.rs:788 — Parser::parse_comma_separated_list has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (21 pts), boolean chains 1, loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::try_parse_parenthesized_with_items (cognitive 21) crates/ruff_python_parser/src/parser/statement.rs:2357 — Parser::try_parse_parenthesized_with_items has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 1 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::parse_simple_statement (cognitive 20) crates/ruff_python_parser/src/parser/statement.rs:269 — Parser::parse_simple_statement has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (13 pts), match/switch 2 (4 pts), boolean chains 3 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Parser::parse_slice (cognitive 19) crates/ruff_python_parser/src/parser/expression.rs:1000 — Parser::parse_slice has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), match/switch 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Parser::parse_except_clause (cognitive 18) crates/ruff_python_parser/src/parser/statement.rs:1694 — Parser::parse_except_clause has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D35 · Change Coupling · Change coupling · ×16
  • Change coupling: fix.rs ↔ lint.rs crates/ruff_server/src/fix.rs:1 — `crates/ruff_server/src/fix.rs` and `crates/ruff_server/src/lint.rs` change together 70% of the time (7 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `0d804975` Lint TOML files in the LSP (#26862); `d8bc7007` LSP: Add support for custom extensions (#24463); `e0704ce3` Exit earlier in LSP when source type unknown (#23874) — run `git show` on any of them.
  • Change coupling: dunder_all.rs ↔ class.rs crates/ty_python_semantic/src/dunder_all.rs:1 — `crates/ty_python_semantic/src/dunder_all.rs` and `crates/ty_python_semantic/src/types/class.rs` change together 67% of the time (10 of the 15 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 10 shared commits counted here, the most recent 3 are `e2e1e647` [ty] Remove excess capacity from more Salsa cached collections (#25411); `4bd03427` [ty] Inline cycle initial and recovery functions (#22814); `83a00c0a` [ty] follow the breaking API changes made in salsa-rs/salsa#1015 (#21… — run `git show` on any of them.
  • Change coupling: symbol.rs ↔ infer.rs crates/ty_python_core/src/symbol.rs:1 — `crates/ty_python_core/src/symbol.rs` and `crates/ty_python_semantic/src/types/infer.rs` change together 61% of the time (14 of the 23 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 14 shared commits counted here, the most recent 3 are `7d31eb42` [ty] Compute reaching definitions from inferred deferredness. (#29685); `827456f9` [ty] more cases for the class body global fallback (at that commit the file was still `crates/ty_python_semantic/src/semantic_index/symbol.rs`); `41463396` [ty] Add a subdiagnostic if `invalid-return-type` is emitted on a met… (at that commit the file was still `crates/ty_python_semantic/src/semantic_index/symbol.rs`) — run `git show` on any of them.
  • Change coupling: check.rs ↔ test.rs crates/ruff/src/commands/check.rs:1 — `crates/ruff/src/commands/check.rs` and `crates/ruff_linter/src/test.rs` change together 60% of the time (6 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `1267effe` Use the shared diagnostic rendering order in Ruff (#30291); `7060eed2` Clean up `Emitter` trait (#29680); `8cfeae89` JUnit output for `ty` lints (#22125) — run `git show` on any of them.
  • Change coupling: preview.rs ↔ violations.rs crates/ruff_linter/src/preview.rs:1 — `crates/ruff_linter/src/preview.rs` and `crates/ruff_linter/src/rules/flake8_use_pathlib/violations.rs` change together 60% of the time (6 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `99d68da2` [`flake8-use-pathlib`] Add autofixes for `PTH116` (#26460); `bfb09024` [`flake8-use-pathlib`] Add fix for `PTH123` (#20169); `0be3e1fb` [`flake8-use-pathlib`] Add autofix for `PTH211` (#20009) — run `git show` on any of them.
  • Change coupling: builder.rs ↔ narrowing_constraints.rs crates/ty_python_core/src/builder.rs:1 — `crates/ty_python_core/src/builder.rs` and `crates/ty_python_core/src/narrowing_constraints.rs` change together 59% of the time (10 of the 17 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 10 shared commits counted here, the most recent 3 are `a5ef1f43` [ty] Add assert_never fixes for redundant final elif branches (#28178); `7e315717` [ty] Propagate narrowing through statically known branches (#27752); `b708d72b` [ty] Add dedicated TDDs for narrowing constraints (#25834) — run `git show` on any of them.
  • Change coupling: expression.rs ↔ codes.rs crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1 — `crates/ruff_linter/src/checkers/ast/analyze/expression.rs` and `crates/ruff_linter/src/codes.rs` change together 55% of the time (67 of the 121 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 67 shared commits counted here, the most recent 3 are `ff1770df` [`flake8-async`] Implement `pytest-raises-exception-group` (`ASYNC401…; `19c01a66` [`security`] Implement `tarfile-ignore-zeros-true` (#28680); `9525a0c4` [suspicious] Add `shared-clock-mock` (#29074) — run `git show` on any of them.
  • Change coupling: goto_definition.rs ↔ ide_support.rs crates/ty_ide/src/goto_definition.rs:1 — `crates/ty_ide/src/goto_definition.rs` and `crates/ty_python_semantic/src/types/ide_support.rs` change together 54% of the time (19 of the 35 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 19 shared commits counted here, the most recent 3 are `9d07aa09` [ty] Support comprehension walruses in IDE features (#26476); `986ea67d` [ty] Implement LSP `textDocument/implementation` request (#25410); `0909c7ec` [ty] Follow aliases when resolving stub mappings (#25328) — run `git show` on any of them.
  • Change coupling: testing.rs ↔ options.rs crates/ty_module_resolver/src/testing.rs:1 — `crates/ty_module_resolver/src/testing.rs` and `crates/ty_project/src/metadata/options.rs` change together 54% of the time (7 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `1dcdf7f4` [ty] Resolve python environment in `Options::to_program_settings` (#1… (at that commit the file was still `crates/ty_python_semantic/src/module_resolver/testing.rs`); `76387295` [ty] Move venv and conda env discovery to `SearchPath::from_settings`… (at that commit the file was still `crates/ty_python_semantic/src/module_resolver/testing.rs`); `88866f00` [ty] Infer the Python version from the environment if feasible (#18057) (at that commit the file was still `crates/ty_python_semantic/src/module_resolver/testing.rs`) — run `git show` on any of them.
  • Change coupling: testing.rs ↔ program.rs crates/ty_module_resolver/src/testing.rs:1 — `crates/ty_module_resolver/src/testing.rs` and `crates/ty_python_core/src/program.rs` change together 54% of the time (7 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `1dcdf7f4` [ty] Resolve python environment in `Options::to_program_settings` (#1… (at that commit the files were still `crates/ty_python_semantic/src/module_resolver/testing.rs` and `crates/ty_python_semantic/src/program.rs`); `76387295` [ty] Move venv and conda env discovery to `SearchPath::from_settings`… (at that commit the files were still `crates/ty_python_semantic/src/module_resolver/testing.rs` and `crates/ty_python_semantic/src/program.rs`); `88866f00` [ty] Infer the Python version from the environment if feasible (#18057) (at that commit the files were still `crates/ty_python_semantic/src/module_resolver/testing.rs` and `crates/ty_python_semantic/src/program.rs`) — run `git show` on any of them.
  • Change coupling: moved_to_provider_in_3.rs ↔ suggested_to_move_to_provider_in_3.rs crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1 — `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs` change together 54% of the time (7 of the 13 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 7 shared commits counted here, the most recent 3 are `7fee877c` [`airflow`]: rename `AutoImport` as `Rename` (internal) (#20563); `c452a2cb` [`airflow`] Move `airflow.operators.postgres_operator.Mapping` from `…; `99cb89f9` [`airflow`] Move rules from `AIR312` to `AIR302` (#17940) — run `git show` on any of them.
  • Change coupling: preview.rs ↔ mod.rs crates/ruff_linter/src/preview.rs:1 — `crates/ruff_linter/src/preview.rs` and `crates/ruff_linter/src/rules/flake8_simplify/mod.rs` change together 53% of the time (8 of the 15 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `51f179e5` Stabilize checking additional key expression types in `SIM910` (#22976); `c780e7b7` Stabilize the fix for `SIM905` when `maxsplit` is provided (#22975); `8a85a296` [`flake8-simplify`] Apply `SIM113` when index variable is of type `in… — run `git show` on any of them.
  • Change coupling: builder.rs ↔ dunder_all.rs crates/ty_python_core/src/builder.rs:1 — `crates/ty_python_core/src/builder.rs` and `crates/ty_python_semantic/src/dunder_all.rs` change together 53% of the time (8 of the 15 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 8 shared commits counted here, the most recent 3 are `3ac6b4c3` [ty] Represent uninhabited truthiness explicitly (#28843); `e7f1c3bb` [ty] Introduce a helper to centralize logic for resolving modules ref…; `e2e1e647` [ty] Remove excess capacity from more Salsa cached collections (#25411) — run `git show` on any of them.
  • Change coupling: removal_in_3.rs ↔ suggested_to_update_3_0.rs crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1 — `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs` change together 53% of the time (9 of the 17 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency between them. They sit in the same directory, but in this ecosystem each file is its own module — a sibling reference still needs an import — so the missing import edge is real: the coupling runs through shared behaviour, not a declared dependency. If they duplicate structure, extract the common part into one unit; otherwise the coupling is hidden and worth breaking. You can check this without leaving the row: of the 9 shared commits counted here, the most recent 3 are `f055f393` [`airflow`] Add ruff rules to catch deprecated Airflow imports for Ai…; `d38a5292` [`airflow`] warning `airflow....DAG.create_dagrun` has been removed (…; `7fee877c` [`airflow`]: rename `AutoImport` as `Rename` (internal) (#20563) — run `git show` on any of them.
  • Change coupling: use_def.rs ↔ unused_bindings.rs crates/ty_python_core/src/use_def.rs:1 — `crates/ty_python_core/src/use_def.rs` and `crates/ty_python_semantic/src/types/ide_support/unused_bindings.rs` change together 50% of the time (6 of the 12 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 6 shared commits counted here, the most recent 3 are `2668df9b` [ty] Preserve declared types in exception handlers (#27817); `52637fc9` [ty] Store loop headers in use-def maps (#26266); `dc3637d0` [ty] Track unused-binding captures across nested scopes (#25536) — run `git show` on any of them.
  • Change coupling: source.rs ↔ infer.rs crates/ruff_db/src/source.rs:1 — `crates/ruff_db/src/source.rs` and `crates/ty_python_semantic/src/types/infer.rs` change together 50% of the time (5 of the 10 commits that touched whichever of the two files changed less often, counting a file under its earlier names as well, and counted over this repository's 10,000 most recent commits rather than its whole history — a repo-wide or module-wide sweep is evidence about the sweep rather than about any pair inside it and is left out of BOTH sides of this ratio, while a dependency bump, a formatter/rename sweep, or a commit whose edit to one of the two files was a tool directive such as //go:generate or whitespace only is left out of the shared count ONLY, so the two sides are not taken over identical commit sets) with no explicit dependency — the edge is real but nothing declares it. Read the pair before acting: if one registers itself into the other through a hook or an initialiser, the missing dependency is DELIBERATE — the registration is the link, and it is meant not to be an import — and the thing to add is a comment on each side naming the other, not a merge; if they simply belong together, co-locate them; if neither holds, the coupling is hidden and worth breaking. You can check this without leaving the row: of the 5 shared commits counted here, the most recent 3 are `21ac16db` [ty] Avoid overcounting shared memory usage (#19773); `8f8c39c4` Simplify `get_size2` usage (#19643); `5e29278a` [ty] Reduce size of `TypeInference` (#19435) — run `git show` on any of them.
D4 · Code Duplication · Edited copy of a member (19 corresponding lines) · ×15
  • Edited copy of a member (19 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/unraw_re_pattern.rs:181 — crates/ruff_linter/src/rules/ruff/rules/unraw_re_pattern.rs:181-199 | crates/ruff_linter/src/rules/ruff/rules/unraw_re_pattern.rs:231-249 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_python_codegen/src/generator.rs:185 — crates/ruff_python_codegen/src/generator.rs:185-206 | crates/ruff_python_codegen/src/generator.rs:208-226 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:78 — crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:78-96 | crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs:96-122 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_python_formatter/src/expression/expr_bin_op.rs:25 — crates/ruff_python_formatter/src/expression/expr_bin_op.rs:25-44 | crates/ruff_python_formatter/src/expression/expr_compare.rs:26-44 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:165 — crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:165-183 | crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs:150-168 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_python_semantic/src/model.rs:1906 — crates/ruff_python_semantic/src/model.rs:1906-1924 | crates/ruff_python_semantic/src/model.rs:1946-1966 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:4112 — crates/ty_python_semantic/src/types/diagnostic.rs:4112-4131 | crates/ty_python_semantic/src/types/diagnostic.rs:4138-4156 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_python_semantic/src/analyze/typing.rs:1053 — crates/ruff_python_semantic/src/analyze/typing.rs:1053-1071 | crates/ruff_python_semantic/src/analyze/typing.rs:1106-1124 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_db/src/files.rs:407 — crates/ruff_db/src/files.rs:407-425 | crates/ruff_db/src/files.rs:431-452 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ty_python_semantic/src/types/signatures.rs:1340 — crates/ty_python_semantic/src/types/signatures.rs:1340-1358 | crates/ty_python_semantic/src/types/tuple.rs:2306-2327 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ty_python_semantic/src/types/call/bind.rs:11363 — crates/ty_python_semantic/src/types/call/bind.rs:11363-11381 | crates/ty_python_semantic/src/types/call/bind.rs:11397-11415 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ty_python_semantic/src/types/instance.rs:2029 — crates/ty_python_semantic/src/types/instance.rs:2029-2047 | crates/ty_python_semantic/src/types/subclass_of.rs:248-267 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/suppression_comment_visitor.rs:177 — crates/ruff_linter/src/rules/ruff/rules/suppression_comment_visitor.rs:177-197 | crates/ruff_python_formatter/src/comments/visitor.rs:150-168 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:80 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:80-100 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:102-120 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (19 corresponding lines) crates/ruff_python_formatter/src/expression/expr_f_string.rs:40 — crates/ruff_python_formatter/src/expression/expr_f_string.rs:40-58 | crates/ruff_python_formatter/src/expression/expr_t_string.rs:40-58 — These two members are one piece of code written twice and then edited apart: 19 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (13 corresponding lines) · ×15
  • Edited copy of a member (13 corresponding lines) crates/ty_python_semantic/src/types/equality/enums.rs:859 — crates/ty_python_semantic/src/types/equality/enums.rs:859-871 | crates/ty_python_semantic/src/types/equality/enums.rs:880-893 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ty_python_semantic/src/reachability.rs:598 — crates/ty_python_semantic/src/reachability.rs:598-610 | crates/ty_python_semantic/src/types/narrow.rs:3528-3543 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_linter/src/rules/pylint/settings.rs:107 — crates/ruff_linter/src/rules/pylint/settings.rs:107-120 | crates/ruff_linter/src/rules/pyupgrade/types.rs:15-27 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_python_ast/src/name.rs:762 — crates/ruff_python_ast/src/name.rs:762-776 | crates/ruff_python_ast/src/name.rs:790-802 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs:182 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_dict_comprehension_for_iterable.rs:182-201 | crates/ruff_linter/src/rules/ruff/rules/default_factory_kwarg.rs:116-128 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_linter/src/rules/airflow/helpers.rs:141 — crates/ruff_linter/src/rules/airflow/helpers.rs:141-153 | crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:813-833 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ty_ide/src/docstring/markdown/structured/google.rs:12 — crates/ty_ide/src/docstring/markdown/structured/google.rs:12-24 | crates/ty_ide/src/docstring/markdown/structured/numpy.rs:13-28 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ty_ide/src/docstring/markdown/general/inline.rs:624 — crates/ty_ide/src/docstring/markdown/general/inline.rs:624-636 | crates/ty_ide/src/docstring/markdown/structured.rs:501-516 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_python_formatter/src/statement/stmt_assert.rs:13 — crates/ruff_python_formatter/src/statement/stmt_assert.rs:13-42 | crates/ruff_python_formatter/src/type_param/type_param_type_var_tuple.rs:10-22 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ty_python_core/src/narrowing_constraints.rs:117 — crates/ty_python_core/src/narrowing_constraints.rs:117-129 | crates/ty_python_core/src/reachability_constraints.rs:156-169 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_linter/src/checkers/ast/mod.rs:923 — crates/ruff_linter/src/checkers/ast/mod.rs:923-939 | crates/ruff_python_semantic/src/model.rs:1829-1841 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ty_server/src/server/api/traits.rs:112 — crates/ty_server/src/server/api/traits.rs:112-124 | crates/ty_server/src/server/api/traits.rs:159-171 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_python_parser/src/parser/expression.rs:1108 — crates/ruff_python_parser/src/parser/expression.rs:1108-1120 | crates/ruff_python_parser/src/parser/expression.rs:2736-2750 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_linter/src/rules/flake8_async/rules/yield_in_context_manager_in_async_generator.rs:130 — crates/ruff_linter/src/rules/flake8_async/rules/yield_in_context_manager_in_async_generator.rs:130-144 | crates/ruff_linter/src/rules/ruff/rules/fallible_context_manager.rs:73-85 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (13 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs:305 — crates/ruff_linter/src/rules/pyupgrade/rules/convert_typed_dict_functional_to_class.rs:305-319 | crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs:262-274 — These two members are one piece of code written twice and then edited apart: 13 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×15
  • Duplicated block (17 lines × 2) crates/ruff_linter/src/fix/codemods.rs:63 — crates/ruff_linter/src/fix/codemods.rs:63-79 | crates/ruff_linter/src/fix/codemods.rs:155-171 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/fix/codemods.rs:63` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:86 — crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:86-102 | crates/ruff_linter/src/rules/pylint/rules/type_param_name_mismatch.rs:94-110 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:86` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs:491 — crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs:491-507 | crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs:522-538 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs:491` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:447 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:447-463 | crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:480-496 — before extracting anything, compare `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs` and `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:445` calls `statement_deletion_range` and `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:478` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (17 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:322 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:322-338 | crates/ruff_python_ast/src/token.rs:413-429 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (17 lines × 2) crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:130 — crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:130-146 | crates/ruff_linter/src/rules/pylint/rules/too_many_positional_arguments.rs:134-150 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:130` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs:190 — crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs:190-206 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_iterable_allocation_for_first_element.rs:220-236 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) crates/ty_python_core/src/builder.rs:4684 — crates/ty_python_core/src/builder.rs:4684-4700 | crates/ty_python_core/src/builder.rs:4887-4903 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:3207 — crates/ty_python_semantic/src/types/call/bind.rs:3207-3223 | crates/ty_python_semantic/src/types/call/bind.rs:3299-3315 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:3207` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ty_python_semantic/src/types/definition_resolution.rs:402 — crates/ty_python_semantic/src/types/definition_resolution.rs:402-418 | crates/ty_python_semantic/src/types/definition_resolution.rs:426-442 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:5513 — crates/ty_python_semantic/src/types/infer/builder.rs:5513-5529 | crates/ty_python_semantic/src/types/infer/builder.rs:9058-9074 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:5513` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:2452 — crates/ty_python_semantic/src/types/infer/builder/subscript.rs:2452-2468 | crates/ty_python_semantic/src/types/infer/builder/subscript.rs:2469-2485 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/subscript.rs:2452` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ty_python_semantic/src/types/method.rs:982 — crates/ty_python_semantic/src/types/method.rs:982-998 | crates/ty_python_semantic/src/types/method.rs:1006-1022 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (17 lines × 2) crates/ty_python_semantic/src/types/narrow.rs:4557 — crates/ty_python_semantic/src/types/narrow.rs:4557-4573 | crates/ty_python_semantic/src/types/narrow.rs:4585-4601 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/narrow.rs:4557` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) crates/ty_server/src/server/api.rs:280 — crates/ty_server/src/server/api.rs:280-296 | crates/ty_server/src/server/api.rs:348-364 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_server/src/server/api.rs:280` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Edited copy of a member (12 corresponding lines) · ×14
  • Edited copy of a member (12 corresponding lines) crates/ty_python_semantic/src/types/class/static_literal.rs:427 — crates/ty_python_semantic/src/types/class/static_literal.rs:427-438 | crates/ty_python_semantic/src/types/type_alias.rs:289-305 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:1617 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1617-1628 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1843-1854 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_linter/src/settings/types.rs:395 — crates/ruff_linter/src/settings/types.rs:395-406 | crates/ruff_linter/src/settings/types.rs:474-488 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_server/src/session/client.rs:137 — crates/ruff_server/src/session/client.rs:137-148 | crates/ty_server/src/session/client.rs:177-188 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_graph/src/resolver.rs:111 — crates/ruff_graph/src/resolver.rs:111-122 | crates/ruff_graph/src/resolver.rs:125-136 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ty_ide/src/symbols.rs:546 — crates/ty_ide/src/symbols.rs:546-557 | crates/ty_ide/src/symbols.rs:560-583 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ty_python_semantic/src/types/protocol_class.rs:810 — crates/ty_python_semantic/src/types/protocol_class.rs:810-821 | crates/ty_python_semantic/src/types/protocol_class.rs:831-842 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ty_server/src/server/api/diagnostics.rs:582 — crates/ty_server/src/server/api/diagnostics.rs:582-593 | crates/ty_server/src/server/api/diagnostics.rs:600-611 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_linter/src/rules/isort/categorize.rs:416 — crates/ruff_linter/src/rules/isort/categorize.rs:416-427 | crates/ruff_linter/src/settings/types.rs:890-901 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_linter/src/registry/rule_set.rs:295 — crates/ruff_linter/src/registry/rule_set.rs:295-306 | crates/ruff_linter/src/settings/types.rs:289-300 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_python_ast/src/token/tokens.rs:148 — crates/ruff_python_ast/src/token/tokens.rs:148-162 | crates/ruff_python_ast/src/token/tokens.rs:204-215 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ty_python_semantic/src/types/protocol_class.rs:1243 — crates/ty_python_semantic/src/types/protocol_class.rs:1243-1258 | crates/ty_python_semantic/src/types.rs:2619-2630 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs:283 — crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs:283-294 | crates/ruff_python_semantic/src/analyze/visibility.rs:44-61 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (12 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/global_statement.rs:58 — crates/ruff_linter/src/rules/pylint/rules/global_statement.rs:58-69 | crates/ruff_linter/src/rules/pylint/rules/nonlocal_and_global.rs:59-72 — These two members are one piece of code written twice and then edited apart: 12 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (16 corresponding lines) · ×14
  • Edited copy of a member (16 corresponding lines) crates/ty_module_resolver/src/resolve.rs:259 — crates/ty_module_resolver/src/resolve.rs:259-274 | crates/ty_module_resolver/src/resolve.rs:293-317 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ty_server/src/server/api/requests/prepare_call_hierarchy.rs:83 — crates/ty_server/src/server/api/requests/prepare_call_hierarchy.rs:83-102 | crates/ty_server/src/server/api/type_hierarchy.rs:54-69 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ty_python_semantic/src/types/recursive.rs:331 — crates/ty_python_semantic/src/types/recursive.rs:331-346 | crates/ty_python_semantic/src/types/type_alias.rs:541-556 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_python_ast/src/nodes.rs:3196 — crates/ruff_python_ast/src/nodes.rs:3196-3211 | crates/ruff_python_ast/src/nodes.rs:3850-3865 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_linter/src/source_kind.rs:113 — crates/ruff_linter/src/source_kind.rs:113-134 | crates/ruff_linter/src/source_kind.rs:141-156 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:831 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:831-846 | crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:849-864 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_python_stdlib/src/str.rs:21 — crates/ruff_python_stdlib/src/str.rs:21-36 | crates/ruff_python_stdlib/src/str.rs:58-73 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ty_python_semantic/src/types.rs:9904 — crates/ty_python_semantic/src/types.rs:9904-9919 | crates/ty_python_semantic/src/types/type_alias.rs:461-477 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:85 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:85-100 | crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs:84-99 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_import_shadowing.rs:59 — crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_import_shadowing.rs:59-74 | crates/ruff_linter/src/rules/flake8_builtins/rules/builtin_lambda_argument_shadowing.rs:39-59 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ty_ide/src/docstring/document/google.rs:50 — crates/ty_ide/src/docstring/document/google.rs:50-66 | crates/ty_ide/src/docstring/document/numpy.rs:41-56 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs:40 — crates/ruff_linter/src/rules/flake8_bandit/rules/logging_config_insecure_listen.rs:40-55 | crates/ruff_linter/src/rules/pylint/rules/subprocess_popen_preexec_fn.rs:55-72 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_python_ast/src/nodes.rs:1151 — crates/ruff_python_ast/src/nodes.rs:1151-1166 | crates/ruff_python_ast/src/nodes.rs:1254-1269 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (16 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:453 — crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:453-468 | crates/ruff_python_semantic/src/analyze/typing.rs:1012-1027 — These two members are one piece of code written twice and then edited apart: 16 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (8 corresponding lines) · ×14
  • Edited copy of a member (8 corresponding lines) crates/ruff_server/src/server/api.rs:149 — crates/ruff_server/src/server/api.rs:149-156 | crates/ty_server/src/server/api.rs:247-254 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ruff_python_ast/src/expression.rs:117 — crates/ruff_python_ast/src/expression.rs:117-124 | crates/ruff_python_ast/src/expression.rs:152-159 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_python_core/src/place.rs:292 — crates/ty_python_core/src/place.rs:292-301 | crates/ty_python_core/src/place.rs:331-338 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_python_semantic/src/reachability.rs:585 — crates/ty_python_semantic/src/reachability.rs:585-592 | crates/ty_python_semantic/src/types/context_manager.rs:315-322 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_python_semantic/src/types/subclass_of.rs:318 — crates/ty_python_semantic/src/types/subclass_of.rs:318-325 | crates/ty_python_semantic/src/types/subclass_of.rs:697-704 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_python_semantic/src/types/display.rs:331 — crates/ty_python_semantic/src/types/display.rs:331-338 | crates/ty_python_semantic/src/types/display.rs:2675-2683 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:173 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:173-180 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs:334-341 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_python_semantic/src/types/function.rs:2191 — crates/ty_python_semantic/src/types/function.rs:2191-2199 | crates/ruff_python_ast/src/helpers.rs:1266-1273 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs:69 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs:69-76 | crates/ruff_linter/src/rules/flake8_simplify/rules/zip_dict_keys_and_values.rs:58-65 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs:112 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs:112-119 | crates/ruff_linter/src/rules/flake8_simplify/rules/zip_dict_keys_and_values.rs:49-56 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_python_core/src/frozen.rs:219 — crates/ty_python_core/src/frozen.rs:219-226 | crates/ty_python_core/src/frozen.rs:251-259 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_python_semantic/src/types/class/named_tuple.rs:184 — crates/ty_python_semantic/src/types/class/named_tuple.rs:184-191 | crates/ty_python_semantic/src/types/class/typed_dict.rs:919-927 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ty_ide/src/semantic_tokens.rs:1380 — crates/ty_ide/src/semantic_tokens.rs:1380-1389 | crates/ty_ide/src/symbols.rs:1584-1591 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (8 corresponding lines) crates/ruff_linter/src/rules/flynt/rules/static_join_to_fstring.rs:50 — crates/ruff_linter/src/rules/flynt/rules/static_join_to_fstring.rs:50-57 | crates/ruff_linter/src/rules/refurb/rules/bit_count.rs:57-64 — These two members are one piece of code written twice and then edited apart: 8 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (15 corresponding lines) · ×13
  • Edited copy of a member (15 corresponding lines) crates/ty_python_semantic/src/types/relation.rs:3370 — crates/ty_python_semantic/src/types/relation.rs:3370-3396 | crates/ty_python_semantic/src/types/relation.rs:4812-4826 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ty_python_semantic/src/types/infer/builder/post_inference/typed_dict.rs:529 — crates/ty_python_semantic/src/types/infer/builder/post_inference/typed_dict.rs:529-544 | crates/ty_python_semantic/src/types/typed_dict.rs:1756-1770 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs:270 — crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs:270-285 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_if_exp.rs:287-301 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ty_python_semantic/src/types/equality.rs:1222 — crates/ty_python_semantic/src/types/equality.rs:1222-1236 | crates/ty_python_semantic/src/types/equality.rs:1331-1351 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ruff_linter/src/rules/pyflakes/rules/raise_not_implemented.rs:73 — crates/ruff_linter/src/rules/pyflakes/rules/raise_not_implemented.rs:73-89 | crates/ruff_linter/src/rules/refurb/rules/hardcoded_string_charset.rs:99-113 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:156 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:156-170 | crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs:170-185 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ruff_python_ast/src/int.rs:13 — crates/ruff_python_ast/src/int.rs:13-27 | crates/ruff_python_ast/src/int.rs:52-66 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ty_python_semantic/src/types/protocol_class.rs:991 — crates/ty_python_semantic/src/types/protocol_class.rs:991-1005 | crates/ty_python_semantic/src/types/protocol_class.rs:1013-1027 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs:397 — crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs:397-411 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs:417-431 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ty_python_semantic/src/types/constraints/variables.rs:1064 — crates/ty_python_semantic/src/types/constraints/variables.rs:1064-1078 | crates/ty_python_semantic/src/types/constraints/variables.rs:1358-1372 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ruff_linter/src/rules/flake8_bugbear/rules/return_in_generator.rs:130 — crates/ruff_linter/src/rules/flake8_bugbear/rules/return_in_generator.rs:130-145 | crates/ruff_python_parser/src/semantic_errors.rs:2245-2259 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:4092 — crates/ty_python_semantic/src/types/diagnostic.rs:4092-4106 | crates/ty_python_semantic/src/types/diagnostic.rs:4353-4368 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (15 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/renamed_rule.rs:70 — crates/ruff_linter/src/rules/ruff/rules/renamed_rule.rs:70-85 | crates/ruff_linter/src/rules/ruff/rules/rule_codes_in_selectors.rs:67-81 — These two members are one piece of code written twice and then edited apart: 15 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (14 corresponding lines) · ×13
  • Edited copy of a member (14 corresponding lines) crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs:116 — crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs:116-129 | crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs:78-92 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ty_python_semantic/src/types/tuple.rs:270 — crates/ty_python_semantic/src/types/tuple.rs:270-284 | crates/ty_python_semantic/src/types/tuple.rs:892-905 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ty_python_semantic/src/types/protocol_class.rs:657 — crates/ty_python_semantic/src/types/protocol_class.rs:657-670 | crates/ty_python_semantic/src/types/protocol_class.rs:682-695 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ruff_dev/src/print_ast.rs:18 — crates/ruff_dev/src/print_ast.rs:18-31 | crates/ruff_dev/src/print_tokens.rs:18-32 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ruff_linter/src/rules/pep8_naming/helpers.rs:27 — crates/ruff_linter/src/rules/pep8_naming/helpers.rs:27-40 | crates/ruff_linter/src/rules/pep8_naming/helpers.rs:58-75 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ruff_python_formatter/src/expression/parentheses.rs:321 — crates/ruff_python_formatter/src/expression/parentheses.rs:321-336 | crates/ruff_python_formatter/src/expression/parentheses.rs:338-351 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:2745 — crates/ty_python_semantic/src/types/diagnostic.rs:2745-2766 | crates/ty_python_semantic/src/types/diagnostic.rs:4568-4581 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ruff/src/commands/version.rs:8 — crates/ruff/src/commands/version.rs:8-21 | crates/ty/src/lib.rs:80-93 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ruff_python_ast/src/nodes.rs:2942 — crates/ruff_python_ast/src/nodes.rs:2942-2955 | crates/ruff_python_formatter/src/expression/expr_compare.rs:67-82 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:359 — crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:359-372 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:380-393 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ty_python_semantic/src/types/relation.rs:3412 — crates/ty_python_semantic/src/types/relation.rs:3412-3425 | crates/ty_python_semantic/src/types/relation.rs:3563-3578 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:56 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:56-69 | crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs:56-69 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (14 corresponding lines) crates/ty_python_core/src/narrowing_constraints.rs:238 — crates/ty_python_core/src/narrowing_constraints.rs:238-251 | crates/ty_python_core/src/reachability_constraints.rs:377-390 — These two members are one piece of code written twice and then edited apart: 14 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D2 · Cognitive Complexity · StaticClassLiteral · ×11
  • StaticClassLiteral::own_generated_member (cognitive 94) crates/ty_python_semantic/src/types/class/static_literal.rs:1868 — StaticClassLiteral::own_generated_member has cognitive complexity 94 (threshold 15). Drivers by points: if/else 34 (62 pts), boolean chains 18, match/switch 5 (9 pts), loops 2 (5 pts) (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • StaticClassLiteral::own_instance_member (cognitive 63) crates/ty_python_semantic/src/types/class/static_literal.rs:3145 — StaticClassLiteral::own_instance_member has cognitive complexity 63 (threshold 15). Drivers by points: if/else 18 (45 pts), match/switch 3 (11 pts), boolean chains 7 (nesting depth added 35). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • StaticClassLiteral::implicit_attribute_impl (cognitive 59) crates/ty_python_semantic/src/types/class/implicit_attributes.rs:114 — StaticClassLiteral::implicit_attribute_impl has cognitive complexity 59 (threshold 15). Drivers by points: if/else 23 (46 pts), loops 5 (7 pts), match/switch 2 (4 pts), boolean chains 2 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • StaticClassLiteral::own_fields_inner (cognitive 52) crates/ty_python_semantic/src/types/class/static_literal.rs:2823 — StaticClassLiteral::own_fields_inner has cognitive complexity 52 (threshold 15). Drivers by points: if/else 19 (41 pts), boolean chains 6, match/switch 1 (3 pts), loops 2 (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • StaticClassLiteral::try_metaclass::try_metaclass_inner (cognitive 28) crates/ty_python_semantic/src/types/class/static_literal.rs:1324 — StaticClassLiteral::try_metaclass::try_metaclass_inner has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (21 pts), boolean chains 3, match/switch 2 (3 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • StaticClassLiteral::own_class_member (cognitive 28) crates/ty_python_semantic/src/types/class/static_literal.rs:1628 — StaticClassLiteral::own_class_member has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (19 pts), boolean chains 7, match/switch 2 (nesting depth added 4). Of this number, 26 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • StaticClassLiteral::merged_dataclass_params (cognitive 23) crates/ty_python_semantic/src/types/class/static_literal.rs:1159 — StaticClassLiteral::merged_dataclass_params has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 2 (8 pts), boolean chains 2 (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • StaticClassLiteral::validate_members (cognitive 22) crates/ty_python_semantic/src/types/class/static_literal.rs:2715 — StaticClassLiteral::validate_members has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (17 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • StaticClassLiteral::total_ordering_root_method (cognitive 21) crates/ty_python_semantic/src/types/class/static_literal.rs:331 — StaticClassLiteral::total_ordering_root_method has cognitive complexity 21 (threshold 15). Drivers by points: if/else 4 (15 pts), loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • StaticClassLiteral::slot_definition (cognitive 18) crates/ty_python_semantic/src/types/class/slots.rs:290 — StaticClassLiteral::slot_definition has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • StaticClassLiteral::variance_equation (cognitive 16) crates/ty_python_semantic/src/types/class/static_literal.rs:3636 — StaticClassLiteral::variance_equation has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10, boolean chains 5, match/switch 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ruff · ×11
  • ruff::check (cognitive 78) crates/ruff/src/lib.rs:237 — ruff::check has cognitive complexity 78 (threshold 15). Drivers by points: if/else 37 (65 pts), boolean chains 5, loops 2 (4 pts), match/switch 2 (4 pts) (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff::commands::format::warn_incompatible_formatter_settings (cognitive 51) crates/ruff/src/commands/format.rs:1084 — ruff::commands::format::warn_incompatible_formatter_settings has cognitive complexity 51 (threshold 15). Drivers by points: if/else 17 (37 pts), boolean chains 7, loops 3 (4 pts), match/switch 1 (3 pts) (nesting depth added 23). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff::diagnostics::lint_path (cognitive 45) crates/ruff/src/diagnostics.rs:182 — ruff::diagnostics::lint_path has cognitive complexity 45 (threshold 15). Drivers by points: if/else 16 (28 pts), match/switch 8 (16 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff::commands::format::format (cognitive 43) crates/ruff/src/commands/format.rs:71 — ruff::commands::format::format has cognitive complexity 43 (threshold 15). Drivers by points: if/else 21 (31 pts), boolean chains 5, match/switch 4 (5 pts), loops 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff::diagnostics::lint_stdin (cognitive 35) crates/ruff/src/diagnostics.rs:383 — ruff::diagnostics::lint_stdin has cognitive complexity 35 (threshold 15). Drivers by points: if/else 14 (27 pts), match/switch 4 (8 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff::commands::format::format_source (cognitive 31) crates/ruff/src/commands/format.rs:348 — ruff::commands::format::format_source has cognitive complexity 31 (threshold 15). Drivers by points: if/else 13 (24 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff::commands::format_stdin::format_stdin (cognitive 27) crates/ruff/src/commands/format_stdin.rs:21 — ruff::commands::format_stdin::format_stdin has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (24 pts), match/switch 2 (3 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff::commands::format::format_path (cognitive 22) crates/ruff/src/commands/format.rs:252 — ruff::commands::format::format_path has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 3 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff::commands::analyze_graph::analyze_graph (cognitive 20) crates/ruff/src/commands/analyze_graph.rs:23 — ruff::commands::analyze_graph::analyze_graph has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff::commands::check::check (cognitive 20) crates/ruff/src/commands/check.rs:33 — ruff::commands::check::check has cognitive complexity 20 (threshold 15). Drivers by points: if/else 12 (15 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • ruff::commands::check_stdin::check_stdin (cognitive 17) crates/ruff/src/commands/check_stdin.rs:15 — ruff::commands::check_stdin::check_stdin has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (17 pts) (nesting depth added 11). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D4 · Code Duplication · Edited copy of a member (20 corresponding lines) · ×11
  • Edited copy of a member (20 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:50 — crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:50-69 | crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:51-72 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ty_python_semantic/src/types/constraints/paths.rs:187 — crates/ty_python_semantic/src/types/constraints/paths.rs:187-206 | crates/ty_python_semantic/src/types/constraints/paths.rs:277-300 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ty_python_core/src/member.rs:623 — crates/ty_python_core/src/member.rs:623-642 | crates/ty_python_core/src/symbol.rs:286-305 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ty_python_core/src/narrowing_constraints.rs:147 — crates/ty_python_core/src/narrowing_constraints.rs:147-166 | crates/ty_python_core/src/reachability_constraints.rs:203-222 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:688 — crates/ty_python_semantic/src/types/constraints/sequents.rs:688-736 | crates/ty_python_semantic/src/types/constraints/sequents.rs:744-763 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ruff_macros/src/rust_doc.rs:43 — crates/ruff_macros/src/rust_doc.rs:43-62 | crates/ruff_macros/src/violation_metadata.rs:136-155 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_str_subclass.rs:54 — crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_str_subclass.rs:54-79 | crates/ruff_linter/src/rules/flake8_slots/rules/no_slots_in_tuple_subclass.rs:55-74 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs:93 — crates/ruff_linter/src/rules/pycodestyle/rules/doc_line_too_long.rs:93-114 | crates/ruff_linter/src/rules/pycodestyle/rules/line_too_long.rs:91-110 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:110 — crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:110-129 | crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:131-150 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ruff_python_ast/src/nodes.rs:1168 — crates/ruff_python_ast/src/nodes.rs:1168-1187 | crates/ruff_python_ast/src/nodes.rs:1271-1290 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (20 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/unused_async.rs:113 — crates/ruff_linter/src/rules/ruff/rules/unused_async.rs:113-135 | crates/ruff_linter/src/rules/ruff/rules/unused_async.rs:142-161 — These two members are one piece of code written twice and then edited apart: 20 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×11
  • Duplicated block (18 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/statement.rs:584 — crates/ruff_linter/src/checkers/ast/analyze/statement.rs:584-601 | crates/ruff_linter/src/checkers/ast/analyze/statement.rs:761-778 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) crates/ruff_linter/src/checkers/ast/mod.rs:1414 — crates/ruff_linter/src/checkers/ast/mod.rs:1414-1431 | crates/ruff_linter/src/checkers/ast/mod.rs:1435-1452 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/checkers/ast/mod.rs:1414` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) crates/ruff_python_formatter/src/expression/expr_list_comp.rs:14 — crates/ruff_python_formatter/src/expression/expr_list_comp.rs:14-31 | crates/ruff_python_formatter/src/expression/expr_set_comp.rs:14-31 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/expression/expr_list_comp.rs:14` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&ExprListComp` in one and `&ExprSetComp` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (18 lines × 2) crates/ty_python_core/src/use_def.rs:2487 — crates/ty_python_core/src/use_def.rs:2487-2504 | crates/ty_python_core/src/use_def.rs:2519-2536 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) crates/ty_python_semantic/src/dunder_all.rs:283 — crates/ty_python_semantic/src/dunder_all.rs:283-300 | crates/ty_python_semantic/src/dunder_all.rs:325-342 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/dunder_all.rs:283` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1200 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1200-1217 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1235-1252 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1200` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) crates/ty_python_semantic/src/types/constraints/sequents.rs:1270 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1270-1287 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1340-1357 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1270` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (18 lines × 2) crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:654 — crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:654-671 | crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:676-693 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (18 lines × 2) crates/ty_python_semantic/src/types/typed_dict.rs:1015 — crates/ty_python_semantic/src/types/typed_dict.rs:1015-1032 | crates/ty_python_semantic/src/types/typed_dict.rs:1036-1053 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/typed_dict.rs:1015` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs:206 — crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs:206-223 | crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs:233-250 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) crates/ruff_linter/src/rules/flake8_async/rules/blocking_path_methods.rs:156 — crates/ruff_linter/src/rules/flake8_async/rules/blocking_path_methods.rs:156-173 | crates/ruff_python_semantic/src/analyze/typing.rs:943-960 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_async/rules/blocking_path_methods.rs:156` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `semantic` to `&ruff_python_semantic::SemanticModel` in one and `&SemanticModel` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Edited copy of a member (21 corresponding lines) · ×10
  • Edited copy of a member (21 corresponding lines) crates/ty_python_semantic/src/types/constraints/paths.rs:1101 — crates/ty_python_semantic/src/types/constraints/paths.rs:1101-1121 | crates/ty_python_semantic/src/types/constraints/paths.rs:1131-1155 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ruff_python_formatter/src/comments/format.rs:561 — crates/ruff_python_formatter/src/comments/format.rs:561-581 | crates/ruff_python_formatter/src/comments/format.rs:609-641 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ruff_linter/src/rules/flake8_logging/rules/direct_logger_instantiation.rs:63 — crates/ruff_linter/src/rules/flake8_logging/rules/direct_logger_instantiation.rs:63-84 | crates/ruff_linter/src/rules/flake8_logging/rules/undocumented_warn.rs:54-74 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:2082 — crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:2082-2108 | crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:2115-2135 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ruff_annotate_snippets/src/renderer/source_map.rs:362 — crates/ruff_annotate_snippets/src/renderer/source_map.rs:362-382 | crates/ruff_annotate_snippets/src/renderer/source_map.rs:384-404 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/invalid_envvar_default.rs:53 — crates/ruff_linter/src/rules/pylint/rules/invalid_envvar_default.rs:53-76 | crates/ruff_linter/src/rules/pylint/rules/invalid_envvar_value.rs:50-70 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ruff_linter/src/rules/flake8_slots/helpers.rs:4 — crates/ruff_linter/src/rules/flake8_slots/helpers.rs:4-27 | crates/ruff_python_ast/src/helpers.rs:792-812 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ty_python_semantic/src/types/type_alias.rs:687 — crates/ty_python_semantic/src/types/type_alias.rs:687-707 | crates/ty_python_semantic/src/types/type_alias.rs:720-744 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ruff_linter/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs:64 — crates/ruff_linter/src/rules/pep8_naming/rules/mixed_case_variable_in_class_scope.rs:64-87 | crates/ruff_linter/src/rules/pep8_naming/rules/mixed_case_variable_in_global_scope.rs:68-88 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (21 corresponding lines) crates/ty_ide/src/docstring/document/google.rs:191 — crates/ty_ide/src/docstring/document/google.rs:191-211 | crates/ty_ide/src/docstring/document/numpy.rs:62-86 — These two members are one piece of code written twice and then edited apart: 21 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (7 corresponding lines) · ×10
  • Edited copy of a member (7 corresponding lines) crates/ty_python_core/src/definition.rs:1320 — crates/ty_python_core/src/definition.rs:1320-1326 | crates/ty_python_core/src/definition.rs:1328-1334 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ty_python_semantic/src/types/class/slots.rs:195 — crates/ty_python_semantic/src/types/class/slots.rs:195-201 | crates/ruff_python_ast/src/helpers.rs:65-71 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ruff_linter/src/rules/flake8_annotations/helpers.rs:123 — crates/ruff_linter/src/rules/flake8_annotations/helpers.rs:123-129 | crates/ruff_python_ast/src/helpers.rs:1157-1165 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ruff_server/src/edit/range.rs:119 — crates/ruff_server/src/edit/range.rs:119-125 | crates/ty_server/src/document/range.rs:349-355 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:198 — crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:198-204 | crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs:226-232 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/suppressible_exception.rs:69 — crates/ruff_linter/src/rules/flake8_simplify/rules/suppressible_exception.rs:69-81 | crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:81-87 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:19 — crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:19-25 | crates/ruff_linter/src/rules/pylint/rules/type_param_name_mismatch.rs:143-150 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ty_ide/src/docstring/document/google.rs:585 — crates/ty_ide/src/docstring/document/google.rs:585-591 | crates/ty_ide/src/docstring/document/numpy.rs:509-515 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ty_ide/src/docstring/document/google.rs:661 — crates/ty_ide/src/docstring/document/google.rs:661-667 | crates/ty_ide/src/docstring/document/numpy.rs:729-735 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (7 corresponding lines) crates/ty_python_semantic/src/types/class.rs:3412 — crates/ty_python_semantic/src/types/class.rs:3412-3418 | crates/ty_python_semantic/src/types/type_alias.rs:1015-1021 — These two members are one piece of code written twice and then edited apart: 7 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×10
  • Duplicated block (7 lines × 3) crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:36 — crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:36-42 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:98-104 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:157-164 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (7 lines × 3) crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:436 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:436-442 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:194-200 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:296-302 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:436` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (7 lines × 3) crates/ruff_linter/src/rules/flake8_simplify/rules/needless_bool.rs:278 — crates/ruff_linter/src/rules/flake8_simplify/rules/needless_bool.rs:278-284 | crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:252-258 | crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:272-278 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/needless_bool.rs:278` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:222 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:222-228 | crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:244-250 | crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs:234-240 — before extracting anything, compare `crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs` and `crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (7 lines × 3) crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:178 — crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:178-187 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_if.rs:199-205 | crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs:239-248 — before extracting anything, compare `crates/ruff_linter/src/rules/ruff/rules/needless_else.rs` and `crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:178` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 3) crates/ruff_python_formatter/src/expression/binary_like.rs:184 — crates/ruff_python_formatter/src/expression/binary_like.rs:184-190 | crates/ruff_python_formatter/src/expression/binary_like.rs:202-208 | crates/ruff_python_formatter/src/expression/binary_like.rs:220-226 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (7 lines × 3) crates/ty_python_semantic/src/types.rs:1874 — crates/ty_python_semantic/src/types.rs:1874-1880 | crates/ty_python_semantic/src/types.rs:1882-1888 | crates/ty_python_semantic/src/types.rs:1890-1896 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (7 lines × 3) crates/ty_python_semantic/src/types/class/dynamic_literal.rs:205 — crates/ty_python_semantic/src/types/class/dynamic_literal.rs:205-212 | crates/ty_python_semantic/src/types/typed_dict.rs:1461-1467 | crates/ty_python_semantic/src/types/typed_dict.rs:1526-1532 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (7 lines × 3) crates/ty_python_semantic/src/types/class/typed_dict.rs:237 — crates/ty_python_semantic/src/types/class/typed_dict.rs:237-243 | crates/ty_python_semantic/src/types/class/typed_dict.rs:353-359 | crates/ty_python_semantic/src/types/class/typed_dict.rs:406-413 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (7 lines × 3) crates/ty_python_semantic/src/types/typevar.rs:1783 — crates/ty_python_semantic/src/types/typevar.rs:1783-1789 | crates/ty_python_semantic/src/types/typevar.rs:1805-1811 | crates/ty_python_semantic/src/types/typevar.rs:1826-1832 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/typevar.rs:1783` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D5 · Coupling · Off the main sequence · ×10
  • Off the main sequence: ruff_memory_usage — ruff_memory_usage: abstractness 0.00, instability 0.00, distance 1.00 — zone of pain — concrete and depended on by 6 project(s), so it's rigid to change.
  • Off the main sequence: ruff_annotate_snippets — ruff_annotate_snippets: abstractness 0.03, instability 0.00, distance 0.97 — zone of pain — concrete and depended on by 2 project(s), so it's rigid to change.
  • Off the main sequence: ruff_diagnostics — ruff_diagnostics: abstractness 0.00, instability 0.08, distance 0.92 — zone of pain — concrete and depended on by 12 project(s), so it's rigid to change.
  • Off the main sequence: ty_static — ty_static: abstractness 0.00, instability 0.13, distance 0.88 — zone of pain — concrete and depended on by 7 project(s), so it's rigid to change.
  • Off the main sequence: ruff_source_file — ruff_source_file: abstractness 0.14, instability 0.04, distance 0.81 — zone of pain — concrete and depended on by 22 project(s), so it's rigid to change.
  • Off the main sequence: ruff_python_ast — ruff_python_ast: abstractness 0.05, instability 0.15, distance 0.80 — zone of pain — concrete and depended on by 29 project(s), so it's rigid to change.
  • Off the main sequence: ruff_ranged_value — ruff_ranged_value: abstractness 0.00, instability 0.21, distance 0.79 — zone of pain — concrete and depended on by 11 project(s), so it's rigid to change.
  • Off the main sequence: ruff_python_trivia — ruff_python_trivia: abstractness 0.11, instability 0.11, distance 0.78 — zone of pain — concrete and depended on by 16 project(s), so it's rigid to change.
  • Off the main sequence: ruff_python_parser — ruff_python_parser: abstractness 0.04, instability 0.21, distance 0.75 — zone of pain — concrete and depended on by 15 project(s), so it's rigid to change.
  • Off the main sequence: ruff_options_metadata — ruff_options_metadata: abstractness 0.29, instability 0.00, distance 0.71 — zone of pain — concrete and depended on by 4 project(s), so it's rigid to change.
D1 · Cyclomatic Complexity · TypeRelationChecker · ×9
  • TypeRelationChecker::check_signature_pair_inner (cyclomatic 236) crates/ty_python_semantic/src/types/signatures.rs:3100 — TypeRelationChecker::check_signature_pair_inner has cyclomatic complexity 236 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeRelationChecker::check_type_pair (cyclomatic 192) crates/ty_python_semantic/src/types/relation.rs:2058 — TypeRelationChecker::check_type_pair has cyclomatic complexity 192 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • TypeRelationChecker::check_typeddict_pair (cyclomatic 56) crates/ty_python_semantic/src/types/typed_dict.rs:717 — TypeRelationChecker::check_typeddict_pair has cyclomatic complexity 56 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeRelationChecker::check_variable_length_vs_tuple_spec (cyclomatic 41) crates/ty_python_semantic/src/types/tuple.rs:460 — TypeRelationChecker::check_variable_length_vs_tuple_spec has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeRelationChecker::check_type_satisfies_protocol (cyclomatic 31) crates/ty_python_semantic/src/types/instance.rs:822 — TypeRelationChecker::check_type_satisfies_protocol has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeRelationChecker::check_target_union (cyclomatic 25) crates/ty_python_semantic/src/types/relation.rs:1500 — TypeRelationChecker::check_target_union has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeRelationChecker::check_protocol_member_read (cyclomatic 18) crates/ty_python_semantic/src/types/protocol_class.rs:2745 — TypeRelationChecker::check_protocol_member_read has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeRelationChecker::check_protocol_member_access_pair (cyclomatic 18) crates/ty_python_semantic/src/types/protocol_class.rs:3164 — TypeRelationChecker::check_protocol_member_access_pair has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • TypeRelationChecker::try_check_non_recursive_protocol_members (cyclomatic 16) crates/ty_python_semantic/src/types/instance.rs:1193 — TypeRelationChecker::try_check_non_recursive_protocol_members has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D2 · Cognitive Complexity · TypeRelationChecker · ×9
  • TypeRelationChecker::check_signature_pair_inner (cognitive 603) crates/ty_python_semantic/src/types/signatures.rs:3100 — TypeRelationChecker::check_signature_pair_inner has cognitive complexity 603 (threshold 15). Drivers by points: if/else 123 (416 pts), match/switch 27 (90 pts), loops 17 (53 pts), boolean chains 44 (nesting depth added 392). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeRelationChecker::check_typeddict_pair (cognitive 153) crates/ty_python_semantic/src/types/typed_dict.rs:717 — TypeRelationChecker::check_typeddict_pair has cognitive complexity 153 (threshold 15). Drivers by points: if/else 41 (121 pts), match/switch 4 (13 pts), loops 5 (10 pts), boolean chains 9 (nesting depth added 94). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • TypeRelationChecker::check_type_pair (cognitive 107) crates/ty_python_semantic/src/types/relation.rs:2058 — TypeRelationChecker::check_type_pair has cognitive complexity 107 (threshold 15). Drivers by points: if/else 33 (56 pts), boolean chains 30, match/switch 10 (21 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeRelationChecker::check_variable_length_vs_tuple_spec (cognitive 83) crates/ty_python_semantic/src/types/tuple.rs:460 — TypeRelationChecker::check_variable_length_vs_tuple_spec has cognitive complexity 83 (threshold 15). Drivers by points: if/else 18 (52 pts), match/switch 6 (14 pts), boolean chains 9, loops 4 (8 pts) (nesting depth added 46). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • TypeRelationChecker::check_type_satisfies_protocol (cognitive 36) crates/ty_python_semantic/src/types/instance.rs:822 — TypeRelationChecker::check_type_satisfies_protocol has cognitive complexity 36 (threshold 15). Drivers by points: if/else 14 (20 pts), boolean chains 15, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeRelationChecker::check_target_union (cognitive 31) crates/ty_python_semantic/src/types/relation.rs:1500 — TypeRelationChecker::check_target_union has cognitive complexity 31 (threshold 15). Drivers by points: if/else 15 (21 pts), boolean chains 7, match/switch 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeRelationChecker::check_protocol_member_read (cognitive 25) crates/ty_python_semantic/src/types/protocol_class.rs:2745 — TypeRelationChecker::check_protocol_member_read has cognitive complexity 25 (threshold 15). Drivers by points: if/else 15 (20 pts), boolean chains 5 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • TypeRelationChecker::check_fixed_length_tuple_vs_tuple_spec (cognitive 25) crates/ty_python_semantic/src/types/tuple.rs:355 — TypeRelationChecker::check_fixed_length_tuple_vs_tuple_spec has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 2 (4 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • TypeRelationChecker::check_protocol_member_access_pair (cognitive 24) crates/ty_python_semantic/src/types/protocol_class.rs:3164 — TypeRelationChecker::check_protocol_member_access_pair has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 5, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (6 corresponding lines) · ×9
  • Edited copy of a member (6 corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:2153 — crates/ty_python_semantic/src/types/infer/builder.rs:2153-2158 | crates/ty_python_semantic/src/types/infer/builder.rs:2194-2204 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ty_python_semantic/src/types/display.rs:2685 — crates/ty_python_semantic/src/types/display.rs:2685-2693 | crates/ty_python_semantic/src/types/signatures.rs:1141-1146 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ty_server/src/document/range.rs:105 — crates/ty_server/src/document/range.rs:105-110 | crates/ty_wasm/src/lib.rs:1139-1148 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ruff_server/src/session/index.rs:380 — crates/ruff_server/src/session/index.rs:380-385 | crates/ruff_server/src/session/index/ruff_settings.rs:391-398 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ty_python_semantic/src/types.rs:2048 — crates/ty_python_semantic/src/types.rs:2048-2053 | crates/ty_python_semantic/src/types/function.rs:245-250 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ruff_python_semantic/src/analyze/class.rs:493 — crates/ruff_python_semantic/src/analyze/class.rs:493-498 | crates/ruff_python_semantic/src/analyze/typing.rs:50-56 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ruff_linter/src/rules/airflow/helpers.rs:303 — crates/ruff_linter/src/rules/airflow/helpers.rs:303-308 | crates/ruff_linter/src/rules/airflow/rules/variable_get_outside_task.rs:138-146 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ruff_linter/src/rules/flake8_django/rules/locals_in_render_function.rs:68 — crates/ruff_linter/src/rules/flake8_django/rules/locals_in_render_function.rs:68-73 | crates/ruff_python_semantic/src/analyze/typing.rs:782-787 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (6 corresponding lines) crates/ruff_server/src/session/client.rs:175 — crates/ruff_server/src/session/client.rs:175-180 | crates/ty_server/src/session/client.rs:207-214 — These two members are one piece of code written twice and then edited apart: 6 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×9
  • Duplicated block (22 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1539 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1539-1560 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1570-1591 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1539` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:321 — crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:321-342 | crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:618-639 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:321` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:326 — crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:326-347 | crates/ruff_python_formatter/src/range.rs:709-730 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_python_formatter/src/range.rs:706` calls `FString`, `StringLiteral`, `TString` and `crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:325` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (22 lines × 2) crates/ruff_python_semantic/src/model.rs:558 — crates/ruff_python_semantic/src/model.rs:558-579 | crates/ruff_python_semantic/src/model.rs:710-731 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) crates/ruff_server/src/server/schedule/thread/pool.rs:88 — crates/ruff_server/src/server/schedule/thread/pool.rs:88-109 | crates/ty_server/src/server/schedule/thread/pool.rs:90-112 — before extracting anything, compare `crates/ruff_server/src/server/schedule/thread/pool.rs` and `crates/ty_server/src/server/schedule/thread/pool.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 71 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/schedule/thread/pool.rs:88` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) crates/ty_python_semantic/src/types/context_manager.rs:560 — crates/ty_python_semantic/src/types/context_manager.rs:560-581 | crates/ty_python_semantic/src/types/context_manager.rs:596-617 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (22 lines × 2) crates/ty_python_semantic/src/types/infer.rs:2101 — crates/ty_python_semantic/src/types/infer.rs:2101-2122 | crates/ty_python_semantic/src/types/infer.rs:2349-2370 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer.rs:2101` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2711 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2711-2732 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2737-2758 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2711` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (22 lines × 2) crates/ty_python_semantic/src/types/set_theoretic.rs:578 — crates/ty_python_semantic/src/types/set_theoretic.rs:578-599 | crates/ty_python_semantic/src/types/set_theoretic.rs:639-660 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic.rs:578` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D1 · Cyclomatic Complexity · StaticClassLiteral · ×8
  • StaticClassLiteral::own_generated_member (cyclomatic 70) crates/ty_python_semantic/src/types/class/static_literal.rs:1868 — StaticClassLiteral::own_generated_member has cyclomatic complexity 70 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • StaticClassLiteral::implicit_attribute_impl (cyclomatic 32) crates/ty_python_semantic/src/types/class/implicit_attributes.rs:114 — StaticClassLiteral::implicit_attribute_impl has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • StaticClassLiteral::own_fields_inner (cyclomatic 28) crates/ty_python_semantic/src/types/class/static_literal.rs:2823 — StaticClassLiteral::own_fields_inner has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • StaticClassLiteral::own_class_member (cyclomatic 26) crates/ty_python_semantic/src/types/class/static_literal.rs:1628 — StaticClassLiteral::own_class_member has cyclomatic complexity 26 (threshold 15). Of this number, 22 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • StaticClassLiteral::own_instance_member (cyclomatic 26) crates/ty_python_semantic/src/types/class/static_literal.rs:3145 — StaticClassLiteral::own_instance_member has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • StaticClassLiteral::try_metaclass::try_metaclass_inner (cyclomatic 20) crates/ty_python_semantic/src/types/class/static_literal.rs:1324 — StaticClassLiteral::try_metaclass::try_metaclass_inner has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • StaticClassLiteral::slot_definition (cyclomatic 17) crates/ty_python_semantic/src/types/class/slots.rs:290 — StaticClassLiteral::slot_definition has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • StaticClassLiteral::variance_equation (cyclomatic 16) crates/ty_python_semantic/src/types/class/static_literal.rs:3636 — StaticClassLiteral::variance_equation has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Parser · ×8
  • Parser::parse_parameters (cyclomatic 33) crates/ruff_python_parser/src/parser/statement.rs:3326 — Parser::parse_parameters has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Parser::parse_impl (cyclomatic 31) crates/mdtest/src/parser.rs:591 — Parser::parse_impl has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Parser::parse_simple_statement (cyclomatic 25) crates/ruff_python_parser/src/parser/statement.rs:269 — Parser::parse_simple_statement has cyclomatic complexity 25 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • Parser::handle_implicitly_concatenated_strings (cyclomatic 21) crates/ruff_python_parser/src/parser/expression.rs:1352 — Parser::handle_implicitly_concatenated_strings has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • Parser::process_code_block (cyclomatic 20) crates/mdtest/src/parser.rs:824 — Parser::process_code_block has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Parser::parse_interpolated_element (cyclomatic 18) crates/ruff_python_parser/src/parser/expression.rs:1698 — Parser::parse_interpolated_element has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Parser::parse_primary_expression (cyclomatic 19) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • Parser::parse_lhs_expression (cyclomatic 16) crates/ruff_python_parser/src/parser/expression.rs:332 — Parser::parse_lhs_expression has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Parser::parse_primary_expression (cyclomatic 19) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • Parser::parse_set_or_dict_like_expression (cyclomatic 16) crates/ruff_python_parser/src/parser/expression.rs:2096 — Parser::parse_set_or_dict_like_expression has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Parser::parse_primary_expression (cyclomatic 19) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D2 · Cognitive Complexity · Checker · ×8
  • Checker::visit_expr (cognitive 275) crates/ruff_linter/src/checkers/ast/mod.rs:1781 — Checker::visit_expr has cognitive complexity 275 (threshold 15). Drivers by points: if/else 50 (143 pts), loops 23 (82 pts), match/switch 15 (43 pts), boolean chains 7 (nesting depth added 180). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Checker::visit_stmt (cognitive 169) crates/ruff_linter/src/checkers/ast/mod.rs:1048 — Checker::visit_stmt has cognitive complexity 169 (threshold 15). Drivers by points: if/else 54 (117 pts), loops 13 (28 pts), match/switch 7 (13 pts), boolean chains 11 (nesting depth added 84). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Checker::visit_deferred_string_type_definitions (cognitive 37) crates/ruff_linter/src/checkers/ast/mod.rs:3181 — Checker::visit_deferred_string_type_definitions has cognitive complexity 37 (threshold 15). Drivers by points: if/else 6 (26 pts), match/switch 2 (7 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Checker::report_semantic_error (cognitive 30) crates/ruff_linter/src/checkers/ast/mod.rs:773 — Checker::report_semantic_error has cognitive complexity 30 (threshold 15). Drivers by points: if/else 15 (29 pts), match/switch 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Checker::visit_exports (cognitive 30) crates/ruff_linter/src/checkers/ast/mod.rs:3387 — Checker::visit_exports has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (25 pts), loops 2 (3 pts), boolean chains 1, match/switch 1 (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Checker::add_binding (cognitive 18) crates/ruff_linter/src/checkers/ast/mod.rs:2813 — Checker::add_binding has cognitive complexity 18 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Checker::handle_node_store (cognitive 18) crates/ruff_linter/src/checkers/ast/mod.rs:2905 — Checker::handle_node_store has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 4, match/switch 2 (3 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
  • Checker::visit_deferred_lambdas (cognitive 16) crates/ruff_linter/src/checkers/ast/mod.rs:3317 — Checker::visit_deferred_lambdas has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_annotate_snippets · ×8
  • ruff_annotate_snippets::renderer::render::render_source_line (cognitive 123) crates/ruff_annotate_snippets/src/renderer/render.rs:904 — ruff_annotate_snippets::renderer::render::render_source_line has cognitive complexity 123 (threshold 15). Drivers by points: if/else 35 (66 pts), loops 16 (27 pts), boolean chains 17, match/switch 6 (13 pts) (nesting depth added 49). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::render_snippet_annotations (cognitive 117) crates/ruff_annotate_snippets/src/renderer/render.rs:563 — ruff_annotate_snippets::renderer::render::render_snippet_annotations has cognitive complexity 117 (threshold 15). Drivers by points: if/else 30 (77 pts), loops 13 (33 pts), match/switch 2 (5 pts), boolean chains 2 (nesting depth added 70). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::render (cognitive 67) crates/ruff_annotate_snippets/src/renderer/render.rs:29 — ruff_annotate_snippets::renderer::render::render has cognitive complexity 67 (threshold 15). Drivers by points: if/else 16 (46 pts), match/switch 2 (10 pts), boolean chains 6, loops 2 (5 pts) (nesting depth added 41). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::emit_suggestion_default (cognitive 61) crates/ruff_annotate_snippets/src/renderer/render.rs:1516 — ruff_annotate_snippets::renderer::render::emit_suggestion_default has cognitive complexity 61 (threshold 15). Drivers by points: if/else 24 (43 pts), loops 5 (10 pts), boolean chains 4, match/switch 2 (4 pts) (nesting depth added 26). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::pre_process (cognitive 50) crates/ruff_annotate_snippets/src/renderer/render.rs:2727 — ruff_annotate_snippets::renderer::render::pre_process has cognitive complexity 50 (threshold 15). Drivers by points: if/else 10 (36 pts), match/switch 2 (10 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 35). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::render_title (cognitive 44) crates/ruff_annotate_snippets/src/renderer/render.rs:319 — ruff_annotate_snippets::renderer::render::render_title has cognitive complexity 44 (threshold 15). Drivers by points: if/else 18 (35 pts), boolean chains 5, loops 2 (3 pts), match/switch 1 (nesting depth added 18). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::render_short_message (cognitive 20) crates/ruff_annotate_snippets/src/renderer/render.rs:238 — ruff_annotate_snippets::renderer::render::render_short_message has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (18 pts), match/switch 1 (2 pts) (nesting depth added 10). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::draw_line (cognitive 16) crates/ruff_annotate_snippets/src/renderer/render.rs:2043 — ruff_annotate_snippets::renderer::render::draw_line has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (4 pts) (nesting depth added 6). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D2 · Cognitive Complexity · ruff_python_formatter · ×8
  • ruff_python_formatter::string::normalize::normalize_string (cognitive 62) crates/ruff_python_formatter/src/string/normalize.rs:664 — ruff_python_formatter::string::normalize::normalize_string has cognitive complexity 62 (threshold 15). Drivers by points: if/else 18 (53 pts), loops 2 (8 pts), boolean chains 1 (nesting depth added 41). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_python_formatter::verbatim::write_suppressed_statements (cognitive 55) crates/ruff_python_formatter/src/verbatim.rs:262 — ruff_python_formatter::verbatim::write_suppressed_statements has cognitive complexity 55 (threshold 15). Drivers by points: if/else 11 (25 pts), loops 8 (24 pts), match/switch 2 (6 pts) (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_formatter::comments::placement::handle_enclosed_comment (cognitive 26) crates/ruff_python_formatter/src/comments/placement.rs:192 — ruff_python_formatter::comments::placement::handle_enclosed_comment has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (21 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_python_formatter::comments::placement::handle_comprehension_comment (cognitive 21) crates/ruff_python_formatter/src/comments/placement.rs:2197 — ruff_python_formatter::comments::placement::handle_comprehension_comment has cognitive complexity 21 (threshold 15). Drivers by points: if/else 12 (18 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_formatter::comments::placement::handle_lambda_comment (cognitive 19) crates/ruff_python_formatter/src/comments/placement.rs:1825 — ruff_python_formatter::comments::placement::handle_lambda_comment has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_formatter::expression::expr_number_literal::normalize_floating_number (cognitive 19) crates/ruff_python_formatter/src/expression/expr_number_literal.rs:110 — ruff_python_formatter::expression::expr_number_literal::normalize_floating_number has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (16 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_formatter::expression::has_own_parentheses (cognitive 17) crates/ruff_python_formatter/src/expression/mod.rs:1187 — ruff_python_formatter::expression::has_own_parentheses has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 4, match/switch 1 (nesting depth added 4). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_python_formatter::statement::stmt_function_def::format_function_header (cognitive 17) crates/ruff_python_formatter/src/statement/stmt_function_def.rs:94 — ruff_python_formatter::statement::stmt_function_def::format_function_header has cognitive complexity 17 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (26 corresponding lines) · ×8
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:264 — crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:264-289 | crates/ruff_linter/src/rules/pylint/rules/redefined_slots_in_subclass.rs:170-214 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:163 — crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:163-188 | crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs:185-212 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs:50 — crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs:50-83 | crates/ruff_linter/src/rules/flake8_simplify/rules/open_file_with_context_handler.rs:87-112 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:134 — crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:134-159 | crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs:204-229 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1152 — crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1152-1177 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:125-150 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:564 — crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:564-589 | crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:597-622 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs:159 — crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs:159-184 | crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs:190-233 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (26 corresponding lines) crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:95 — crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:95-120 | crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:127-155 — These two members are one piece of code written twice and then edited apart: 26 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×8
  • Duplicated block (20 lines × 2) crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs:95 — crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs:95-114 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs:119-138 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs:95` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (20 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:451 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:451-470 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:497-516 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:451` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) crates/ty_python_semantic/src/types/class/implicit_attributes.rs:395 — crates/ty_python_semantic/src/types/class/implicit_attributes.rs:395-414 | crates/ty_python_semantic/src/types/class/implicit_attributes.rs:436-455 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (20 lines × 2) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2672 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2672-2691 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2771-2790 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2672` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) crates/ty_python_semantic/src/types/set_theoretic.rs:1387 — crates/ty_python_semantic/src/types/set_theoretic.rs:1387-1406 | crates/ty_python_semantic/src/types/set_theoretic.rs:1444-1463 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic.rs:1387` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) crates/ruff_server/src/lib.rs:61 — crates/ruff_server/src/lib.rs:61-80 | crates/ty_server/src/lib.rs:55-74 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/lib.rs:61` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:51 — crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:51-70 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs:66-88 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:51` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs:90 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs:90-109 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_replace.rs:93-112 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs:90` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×8
  • Duplicated block (9 lines × 3) crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:468 — crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:468-476 | crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:482-490 | crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:496-504 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:468` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/builtin_open.rs:139 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/builtin_open.rs:139-147 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_chmod.rs:114-122 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_stat.rs:160-168 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/builtin_open.rs:139` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_stat.rs:156` calls `Some` and `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/builtin_open.rs:137` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 3) crates/ty_python_core/src/use_def.rs:2496 — crates/ty_python_core/src/use_def.rs:2496-2504 | crates/ty_python_core/src/use_def.rs:2528-2536 | crates/ty_python_core/src/use_def.rs:2844-2852 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `super) fn record_narrowing_constraint_for_places( &mut` in one and `super) fn record_declaration( &mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 3) crates/ty_python_core/src/use_def.rs:2496 — crates/ty_python_core/src/use_def.rs:2496-2504 | crates/ty_python_core/src/use_def.rs:2528-2536 | crates/ty_python_core/src/use_def.rs:2888-2896 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `self` to `super) fn record_narrowing_constraint_for_places( &mut` in one and `super) fn delete_binding(&mut` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 3) crates/ty_python_semantic/src/types/class/implicit_attributes.rs:395 — crates/ty_python_semantic/src/types/class/implicit_attributes.rs:395-403 | crates/ty_python_semantic/src/types/class/implicit_attributes.rs:416-424 | crates/ty_python_semantic/src/types/class/implicit_attributes.rs:436-444 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/implicit_attributes.rs:395` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) crates/ty_python_semantic/src/types/constraints.rs:2042 — crates/ty_python_semantic/src/types/constraints.rs:2042-2050 | crates/ty_python_semantic/src/types/constraints/sequents.rs:2161-2169 | crates/ty_python_semantic/src/types/tuple/promotion.rs:38-46 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints.rs:2042` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) crates/ty_python_semantic/src/types/constraints/sequents.rs:1639 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1639-1647 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1865-1873 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1984-1992 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1639` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) crates/ruff_python_parser/src/lexer.rs:1547 — crates/ruff_python_parser/src/lexer.rs:1547-1555 | crates/ruff_python_stdlib/src/identifiers.rs:35-43 | crates/ruff_python_trivia/src/tokenizer.rs:139-147 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D17 · Explicit Debt · HackComment · ×7
  • HackComment crates/ty_python_semantic/src/types/infer/builder/subscript.rs:253 — // HACK ALERT: If we are subscripting a generic class, short-circuit the rest of the — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/ruff_text_size/src/range.rs:134 — // HACK for const fn: math on primitives only — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/ruff_text_size/src/range.rs:143 — // HACK for const fn: math on primitives only — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/ruff_linter/src/directives.rs:292 — /// The directive's kind: HACK, XXX, FIXME, or TODO. — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/ruff_linter/src/rules/flake8_todos/rules/todos.rs:274 — // flake8-todos doesn't support HACK directives. — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/ruff_linter/src/rules/flake8_fixme/rules/todos.rs:104 — /// def running_windows(): # HACK: Use platform module instead. — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
  • HackComment crates/ruff_dev/src/generate_docs.rs:187 — // HACK: This is an ugly regex hack that's necessary because mkdocs uses — a workaround marked in source: record what it is compensating for and what would allow its removal (the upstream fix, the API it is waiting on, the invariant it restores), so the next reader can judge whether it is still needed rather than rediscovering why it is there.
D2 · Cognitive Complexity · SemanticIndexBuilder · ×7
  • SemanticIndexBuilder::visit_stmt_impl (cognitive 376) crates/ty_python_core/src/builder.rs:3896 — SemanticIndexBuilder::visit_stmt_impl has cognitive complexity 376 (threshold 15). Drivers by points: if/else 113 (276 pts), loops 28 (67 pts), boolean chains 25, match/switch 4 (8 pts) (nesting depth added 206). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • SemanticIndexBuilder::visit_expr_with_context (cognitive 60) crates/ty_python_core/src/builder.rs:3487 — SemanticIndexBuilder::visit_expr_with_context has cognitive complexity 60 (threshold 15). Drivers by points: if/else 21 (47 pts), loops 2 (5 pts), boolean chains 4, match/switch 2 (4 pts) (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticIndexBuilder::pop_scope (cognitive 44) crates/ty_python_core/src/builder.rs:892 — SemanticIndexBuilder::pop_scope has cognitive complexity 44 (threshold 15). Drivers by points: if/else 16 (30 pts), loops 5 (10 pts), boolean chains 4 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticIndexBuilder::visit_bool_expression (cognitive 30) crates/ty_python_core/src/builder.rs:3779 — SemanticIndexBuilder::visit_bool_expression has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (21 pts), loops 3 (4 pts), match/switch 2 (4 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticIndexBuilder::add_dict_key_assignment_definitions_impl (cognitive 18) crates/ty_python_core/src/builder.rs:1759 — SemanticIndexBuilder::add_dict_key_assignment_definitions_impl has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts), match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticIndexBuilder::record_lazy_snapshots (cognitive 16) crates/ty_python_core/src/builder.rs:723 — SemanticIndexBuilder::record_lazy_snapshots has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (13 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticIndexBuilder::with_type_params (cognitive 16) crates/ty_python_core/src/builder.rs:3019 — SemanticIndexBuilder::with_type_params has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), match/switch 2 (6 pts), loops 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_python_ast · ×7
  • ruff_python_ast::visitor::transformer::walk_expr (cognitive 51) crates/ruff_python_ast/src/visitor/transformer.rs:349 — ruff_python_ast::visitor::transformer::walk_expr has cognitive complexity 51 (threshold 15). Drivers by points: loops 15 (32 pts), if/else 8 (15 pts), match/switch 2 (4 pts) (nesting depth added 26). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • ruff_python_ast::visitor::walk_expr (cognitive 47) crates/ruff_python_ast/src/visitor.rs:362 — ruff_python_ast::visitor::walk_expr has cognitive complexity 47 (threshold 15). Drivers by points: loops 15 (30 pts), if/else 7 (13 pts), match/switch 2 (4 pts) (nesting depth added 23). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • ruff_python_ast::visitor::walk_stmt (cognitive 41) crates/ruff_python_ast/src/visitor.rs:135 — ruff_python_ast::visitor::walk_stmt has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 10 (20 pts), match/switch 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_python_ast::visitor::transformer::walk_stmt (cognitive 41) crates/ruff_python_ast/src/visitor/transformer.rs:122 — ruff_python_ast::visitor::transformer::walk_stmt has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 10 (20 pts), match/switch 1 (nesting depth added 20). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_python_ast::helpers::any_over_stmt::inner (cognitive 21) crates/ruff_python_ast/src/helpers.rs:537 — ruff_python_ast::helpers::any_over_stmt::inner has cognitive complexity 21 (threshold 15). Drivers by points: boolean chains 20, match/switch 1. The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_python_ast::helpers::is_unpacking_assignment (cognitive 19) crates/ruff_python_ast/src/helpers.rs:1314 — ruff_python_ast::helpers::is_unpacking_assignment has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (13 pts), boolean chains 5, match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_ast::helpers::extract_handled_exceptions (cognitive 16) crates/ruff_python_ast/src/helpers.rs:867 — ruff_python_ast::helpers::extract_handled_exceptions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 2 (6 pts), match/switch 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ty_ide · ×7
  • ty_ide::docstring::markdown::general::render_with_indentation_mode (cognitive 50) crates/ty_ide/src/docstring/markdown/general.rs:75 — ty_ide::docstring::markdown::general::render_with_indentation_mode has cognitive complexity 50 (threshold 15). Drivers by points: if/else 16 (33 pts), boolean chains 9, match/switch 2 (7 pts), loops 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_ide::docstring::markdown::structured::render_sections_into (cognitive 23) crates/ty_ide/src/docstring/markdown/structured.rs:30 — ty_ide::docstring::markdown::structured::render_sections_into has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (19 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_ide::hover::hover (cognitive 23) crates/ty_ide/src/hover.rs:21 — ty_ide::hover::hover has cognitive complexity 23 (threshold 15). Drivers by points: if/else 13 (15 pts), match/switch 3 (6 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • ty_ide::completion::completion (cognitive 21) crates/ty_ide/src/completion.rs:36 — ty_ide::completion::completion has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (5 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_ide::references::references_for_search (cognitive 18) crates/ty_ide/src/references.rs:142 — ty_ide::references::references_for_search has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 4, match/switch 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_ide::completion::add_argument_completions (cognitive 16) crates/ty_ide/src/completion.rs:2082 — ty_ide::completion::add_argument_completions has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_ide::docstring::document::syntax::split_trailing_parenthetical (cognitive 16) crates/ty_ide/src/docstring/document/syntax.rs:572 — ty_ide::docstring::document::syntax::split_trailing_parenthetical has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D3 · God Classes · TooManyFields · ×7
  • TooManyFields: LinterSettings crates/ruff_linter/src/settings/mod.rs:213 — TooManyFields — 51 stored fields beside 7 methods. The bar is 30 stored fields; this is 21 over it, 1.70× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: LintOptionsWire crates/ruff_workspace/src/options.rs:4417 — TooManyFields — 51 stored fields. The bar is 30 stored fields; this is 21 over it, 1.70× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: CheckCommand crates/ruff/src/args.rs:220 — TooManyFields — 46 stored fields beside 1 method. The bar is 30 stored fields; this is 16 over it, 1.53× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: LintCommonOptions crates/ruff_workspace/src/options.rs:696 — TooManyFields — 45 stored fields. The bar is 30 stored fields; this is 15 over it, 1.50× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: LintConfiguration crates/ruff_workspace/src/configuration.rs:727 — TooManyFields — 44 stored fields beside 3 methods. The bar is 30 stored fields; this is 14 over it, 1.47× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: SemanticIndexBuilder crates/ty_python_core/src/builder.rs:237 — TooManyFields — 42 stored fields beside 127 methods. The bar is 30 stored fields; this is 12 over it, 1.40× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
  • TooManyFields: IsortOptions crates/ruff_workspace/src/options.rs:2575 — TooManyFields — 31 stored fields beside 1 method. The bar is 30 stored fields; this is 1 over it, 1.03× the bar. This is width in DATA, not behaviour: every reader that takes the whole type couples to all of its fields, so a change to any one of them is a change every reader has to be checked against. To reduce it, group the fields that are read together by the same callers into a smaller type of their own, and have this one hold that type as a single member — each reader then names only the group it uses.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×7
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:64 — crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:64-112 | crates/ruff_linter/src/rules/pylint/rules/type_bivariance.rs:78-137 | crates/ruff_linter/src/rules/pylint/rules/type_name_incorrect_variance.rs:71-142 | crates/ruff_linter/src/rules/pylint/rules/type_param_name_mismatch.rs:63-132 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs:71 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs:71-109 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:71-162 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_mkdir.rs:72-138 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_symlink.rs:69-149 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ruff_python_ast/src/nodes.rs:1327 — crates/ruff_python_ast/src/nodes.rs:1327-1334 | crates/ruff_python_ast/src/nodes.rs:1371-1378 | crates/ruff_python_ast/src/nodes.rs:1882-1889 | crates/ruff_python_ast/src/nodes.rs:2299-2306 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ruff_server/src/server/api/requests/code_action.rs:193 — crates/ruff_server/src/server/api/requests/code_action.rs:193-226 | crates/ruff_server/src/server/api/requests/code_action.rs:228-261 | crates/ruff_server/src/server/api/requests/code_action.rs:263-296 | crates/ruff_server/src/server/api/requests/code_action.rs:298-331 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_core/src/narrowing_constraints.rs:299 — crates/ty_python_core/src/narrowing_constraints.rs:299-312 | crates/ty_python_core/src/narrowing_constraints.rs:366-379 | crates/ty_python_core/src/reachability_constraints.rs:433-448 | crates/ty_python_core/src/reachability_constraints.rs:514-529 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_core/src/use_def.rs:2486 — crates/ty_python_core/src/use_def.rs:2486-2510 | crates/ty_python_core/src/use_def.rs:2518-2542 | crates/ty_python_core/src/use_def.rs:2835-2884 | crates/ty_python_core/src/use_def.rs:2886-2906 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) crates/ty_python_semantic/src/types/typevar.rs:1780 — crates/ty_python_semantic/src/types/typevar.rs:1780-1792 | crates/ty_python_semantic/src/types/typevar.rs:1802-1814 | crates/ty_python_semantic/src/types/typevar.rs:1823-1835 | crates/ty_python_semantic/src/types/typevar.rs:2208-2220 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Edited copy of a member (29 corresponding lines) · ×7
  • Edited copy of a member (29 corresponding lines) crates/ty_python_semantic/src/types/constraints/variables.rs:1170 — crates/ty_python_semantic/src/types/constraints/variables.rs:1170-1198 | crates/ty_python_semantic/src/types/constraints/variables.rs:1323-1356 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:124 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:124-152 | crates/ruff_linter/src/rules/refurb/rules/write_whole_file.rs:135-166 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:62 — crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:62-90 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:58-86 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) crates/ruff_python_formatter/src/comments/placement.rs:1321 — crates/ruff_python_formatter/src/comments/placement.rs:1321-1349 | crates/ruff_python_formatter/src/comments/placement.rs:1719-1751 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) crates/ruff_db/src/diagnostic/render/grouped.rs:103 — crates/ruff_db/src/diagnostic/render/grouped.rs:103-131 | crates/ruff_db/src/diagnostic/render/junit.rs:131-160 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs:266 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs:266-294 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/warns.rs:234-263 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (29 corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:2042 — crates/ty_python_semantic/src/types/infer/builder.rs:2042-2078 | crates/ty_python_semantic/src/types/infer/builder.rs:10591-10619 — These two members are one piece of code written twice and then edited apart: 29 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×7
  • Duplicated block (25 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:282 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:282-306 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:408-432 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (25 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/useless_class_metaclass_type.rs:63 — crates/ruff_linter/src/rules/pyupgrade/rules/useless_class_metaclass_type.rs:63-87 | crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs:66-90 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/useless_class_metaclass_type.rs:63` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `class_def` to `&StmtClassDef` in one and `&ast::StmtClassDef` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (25 lines × 2) crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:179 — crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:179-203 | crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs:240-264 — before extracting anything, compare `crates/ruff_linter/src/rules/ruff/rules/needless_else.rs` and `crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 51 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) crates/ruff_python_formatter/src/statement/stmt_assign.rs:874 — crates/ruff_python_formatter/src/statement/stmt_assign.rs:874-898 | crates/ruff_python_formatter/src/statement/stmt_assign.rs:1007-1031 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_assign.rs:874` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) crates/ruff_server/src/server/api/requests/code_action.rs:196 — crates/ruff_server/src/server/api/requests/code_action.rs:196-220 | crates/ruff_server/src/server/api/requests/code_action.rs:231-255 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/api/requests/code_action.rs:196` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) crates/ruff_server/src/server/api/requests/code_action.rs:266 — crates/ruff_server/src/server/api/requests/code_action.rs:266-290 | crates/ruff_server/src/server/api/requests/code_action.rs:301-325 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/api/requests/code_action.rs:266` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (25 lines × 2) crates/ty_python_semantic/src/types/iteration.rs:802 — crates/ty_python_semantic/src/types/iteration.rs:802-826 | crates/ty_python_semantic/src/types/iteration.rs:832-856 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/iteration.rs:802` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (23 lines × 2) · ×7
  • Duplicated block (23 lines × 2) crates/ruff_linter/src/rules/airflow/helpers.rs:104 — crates/ruff_linter/src/rules/airflow/helpers.rs:104-126 | crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:777-799 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/helpers.rs` and `crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 50 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (23 lines × 2) crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:68 — crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:68-90 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:64-86 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 93 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:68` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:108 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:108-130 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:558-580 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs` and `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:108` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:98 — crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:98-120 | crates/ruff_linter/src/rules/pylint/rules/too_many_positional_arguments.rs:102-124 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:98` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (23 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3825 — crates/ty_python_semantic/src/types/signatures.rs:3825-3847 | crates/ty_python_semantic/src/types/signatures.rs:4210-4232 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (23 lines × 2) crates/ruff_server/src/server/schedule/thread/pool.rs:64 — crates/ruff_server/src/server/schedule/thread/pool.rs:64-86 | crates/ty_server/src/server/schedule/thread/pool.rs:60-82 — before extracting anything, compare `crates/ruff_server/src/server/schedule/thread/pool.rs` and `crates/ty_server/src/server/schedule/thread/pool.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 71 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/schedule/thread/pool.rs:64` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (23 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs:237 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs:237-259 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/warns.rs:205-227 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs:237` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×7
  • Duplicated block (19 lines × 2) crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1656 — crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1656-1674 | crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1733-1751 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1656` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) crates/ruff_linter/src/rules/pylint/rules/type_bivariance.rs:109 — crates/ruff_linter/src/rules/pylint/rules/type_bivariance.rs:109-127 | crates/ruff_linter/src/rules/pylint/rules/type_name_incorrect_variance.rs:102-120 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/type_bivariance.rs:109` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs:145 — crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs:145-163 | crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs:167-185 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/unnecessary_lambda.rs:145` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) crates/ruff_linter/src/rules/refurb/rules/for_loop_set_mutations.rs:126 — crates/ruff_linter/src/rules/refurb/rules/for_loop_set_mutations.rs:126-144 | crates/ruff_linter/src/rules/refurb/rules/for_loop_writes.rs:203-221 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/for_loop_set_mutations.rs:126` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) crates/ruff_server/src/lint.rs:479 — crates/ruff_server/src/lint.rs:479-497 | crates/ty_server/src/server/api/diagnostics.rs:534-552 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/lint.rs:479` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (19 lines × 2) crates/ty_python_semantic/src/types/narrow.rs:5583 — crates/ty_python_semantic/src/types/narrow.rs:5583-5601 | crates/ty_python_semantic/src/types/typed_dict.rs:2090-2108 — before extracting anything, compare `crates/ty_python_semantic/src/types/narrow.rs` and `crates/ty_python_semantic/src/types/typed_dict.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (19 lines × 2) crates/ruff_python_parser/src/parser/statement.rs:799 — crates/ruff_python_parser/src/parser/statement.rs:799-817 | crates/ruff_python_parser/src/parser/statement.rs:1791-1814 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_parser/src/parser/statement.rs:799` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D1 · Cyclomatic Complexity · ruff_annotate_snippets · ×6
  • ruff_annotate_snippets::renderer::render::render_source_line (cyclomatic 73) crates/ruff_annotate_snippets/src/renderer/render.rs:904 — ruff_annotate_snippets::renderer::render::render_source_line has cyclomatic complexity 73 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::render_snippet_annotations (cyclomatic 41) crates/ruff_annotate_snippets/src/renderer/render.rs:563 — ruff_annotate_snippets::renderer::render::render_snippet_annotations has cyclomatic complexity 41 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::emit_suggestion_default (cyclomatic 29) crates/ruff_annotate_snippets/src/renderer/render.rs:1516 — ruff_annotate_snippets::renderer::render::emit_suggestion_default has cyclomatic complexity 29 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::render (cyclomatic 26) crates/ruff_annotate_snippets/src/renderer/render.rs:29 — ruff_annotate_snippets::renderer::render::render has cyclomatic complexity 26 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::render_title (cyclomatic 24) crates/ruff_annotate_snippets/src/renderer/render.rs:319 — ruff_annotate_snippets::renderer::render::render_title has cyclomatic complexity 24 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
  • ruff_annotate_snippets::renderer::render::pre_process (cyclomatic 19) crates/ruff_annotate_snippets/src/renderer/render.rs:2727 — ruff_annotate_snippets::renderer::render::pre_process has cyclomatic complexity 19 (threshold 15). This file's own header attributes it to another copyright holder, so it is code this repository carries rather than code it wrote: restructuring the body in place forks it from upstream and turns every future re-sync into a manual merge. The performable moves are to leave the body as close to its upstream form as possible and keep it behind a narrow interface of your own, and to re-sync it when upstream changes — or, if it has already diverged far enough that you maintain it here, adopt it deliberately and then split the body into named stages.
D1 · Cyclomatic Complexity · ruff_python_ast · ×6
  • ruff_python_ast::visitor::transformer::walk_expr (cyclomatic 54) crates/ruff_python_ast/src/visitor/transformer.rs:349 — ruff_python_ast::visitor::transformer::walk_expr has cyclomatic complexity 54 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • ruff_python_ast::visitor::walk_expr (cyclomatic 53) crates/ruff_python_ast/src/visitor.rs:362 — ruff_python_ast::visitor::walk_expr has cyclomatic complexity 53 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • ruff_python_ast::helpers::any_over_stmt::inner (cyclomatic 43) crates/ruff_python_ast/src/helpers.rs:537 — ruff_python_ast::helpers::any_over_stmt::inner has cyclomatic complexity 43 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_python_ast::visitor::walk_stmt (cyclomatic 42) crates/ruff_python_ast/src/visitor.rs:135 — ruff_python_ast::visitor::walk_stmt has cyclomatic complexity 42 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • ruff_python_ast::visitor::transformer::walk_stmt (cyclomatic 42) crates/ruff_python_ast/src/visitor/transformer.rs:122 — ruff_python_ast::visitor::transformer::walk_stmt has cyclomatic complexity 42 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • ruff_python_ast::helpers::any_over_expr::inner (cyclomatic 32) crates/ruff_python_ast/src/helpers.rs:261 — ruff_python_ast::helpers::any_over_expr::inner has cyclomatic complexity 32 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: ruff_python_ast::helpers::is_non_empty_f_string::inner (cyclomatic 34) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ruff · ×6
  • ruff::check (cyclomatic 40) crates/ruff/src/lib.rs:237 — ruff::check has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff::commands::format::warn_incompatible_formatter_settings (cyclomatic 29) crates/ruff/src/commands/format.rs:1084 — ruff::commands::format::warn_incompatible_formatter_settings has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff::commands::format::format (cyclomatic 26) crates/ruff/src/commands/format.rs:71 — ruff::commands::format::format has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff::diagnostics::lint_path (cyclomatic 24) crates/ruff/src/diagnostics.rs:182 — ruff::diagnostics::lint_path has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff::diagnostics::lint_stdin (cyclomatic 18) crates/ruff/src/diagnostics.rs:383 — ruff::diagnostics::lint_stdin has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff::commands::format::format_source (cyclomatic 16) crates/ruff/src/commands/format.rs:348 — ruff::commands::format::format_source has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D2 · Cognitive Complexity · NarrowingConstraintsBuilder · ×6
  • NarrowingConstraintsBuilder::evaluate_expr_compare (cognitive 138) crates/ty_python_semantic/src/types/narrow.rs:4047 — NarrowingConstraintsBuilder::evaluate_expr_compare has cognitive complexity 138 (threshold 15). Drivers by points: if/else 51 (99 pts), match/switch 8 (22 pts), boolean chains 13, loops 3 (4 pts) (nesting depth added 63). Of this number, 130 points are the body's own statements and 8 belong to 2 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • NarrowingConstraintsBuilder::narrow_type_by_len_comparison (cognitive 30) crates/ty_python_semantic/src/types/narrow.rs:3670 — NarrowingConstraintsBuilder::narrow_type_by_len_comparison has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (19 pts), match/switch 4 (9 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • NarrowingConstraintsBuilder::evaluate_expr_compare_op (cognitive 24) crates/ty_python_semantic/src/types/narrow.rs:3919 — NarrowingConstraintsBuilder::evaluate_expr_compare_op has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (16 pts), match/switch 3 (6 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • NarrowingConstraintsBuilder::evaluate_expr_call (cognitive 22) crates/ty_python_semantic/src/types/narrow.rs:4614 — NarrowingConstraintsBuilder::evaluate_expr_call has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 4, match/switch 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • NarrowingConstraintsBuilder::evaluate_type_guard_call (cognitive 22) crates/ty_python_semantic/src/types/narrow.rs:4767 — NarrowingConstraintsBuilder::evaluate_type_guard_call has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • NarrowingConstraintsBuilder::narrow_type_by_len (cognitive 17) crates/ty_python_semantic/src/types/narrow.rs:3601 — NarrowingConstraintsBuilder::narrow_type_by_len has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (16 pts), match/switch 1 (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · CallInference · ×6
  • CallInference::select_return_type (cognitive 29) crates/ty_python_semantic/src/types/call/bind.rs:6563 — CallInference::select_return_type has cognitive complexity 29 (threshold 15). Drivers by points: if/else 17 (22 pts), boolean chains 4, loops 2, match/switch 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • CallInference::infer_legacy (cognitive 29) crates/ty_python_semantic/src/types/call/bind.rs:6970 — CallInference::infer_legacy has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (20 pts), loops 4 (6 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • CallInference::intersect_specialized_returns (cognitive 22) crates/ty_python_semantic/src/types/call/bind.rs:6716 — CallInference::intersect_specialized_returns has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 3 (4 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • CallInference::infer_typevartuple_argument_constraints (cognitive 19) crates/ty_python_semantic/src/types/call/bind.rs:7415 — CallInference::infer_typevartuple_argument_constraints has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
  • CallInference::collect_typevartuple_arguments (cognitive 17) crates/ty_python_semantic/src/types/call/bind.rs:7583 — CallInference::collect_typevartuple_arguments has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • CallInference::has_invariant_return_difference (cognitive 16) crates/ty_python_semantic/src/types/call/bind.rs:6440 — CallInference::has_invariant_return_difference has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (8 pts), boolean chains 5, match/switch 2 (3 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ruff_python_semantic · ×6
  • ruff_python_semantic::analyze::class::has_metaclass_new_signature (cognitive 20) crates/ruff_python_semantic/src/analyze/class.rs:331 — ruff_python_semantic::analyze::class::has_metaclass_new_signature has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (19 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_semantic::analyze::typing::match_annotated_subscript (cognitive 18) crates/ruff_python_semantic/src/analyze/typing.rs:58 — ruff_python_semantic::analyze::typing::match_annotated_subscript has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 1, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_semantic::analyze::class::any_member_declaration::any_stmt_in_body (cognitive 17) crates/ruff_python_semantic/src/analyze/class.rs:171 — ruff_python_semantic::analyze::class::any_member_declaration::any_stmt_in_body has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_python_semantic::analyze::typing::is_immutable_annotation (cognitive 17) crates/ruff_python_semantic/src/analyze/typing.rs:293 — ruff_python_semantic::analyze::typing::is_immutable_annotation has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, match/switch 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_python_semantic::analyze::typing::check_type (cognitive 17) crates/ruff_python_semantic/src/analyze/typing.rs:643 — ruff_python_semantic::analyze::typing::check_type has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 6 (11 pts), if/else 2 (6 pts) (nesting depth added 9). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_python_semantic::analyze::terminal::sometimes_breaks (cognitive 16) crates/ruff_python_semantic/src/analyze/terminal.rs:290 — ruff_python_semantic::analyze::terminal::sometimes_breaks has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (12 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (48 corresponding lines) · ×6
  • Edited copy of a member (48 corresponding lines) crates/ty_python_core/src/definition.rs:1032 — crates/ty_python_core/src/definition.rs:1032-1079 | crates/ty_python_core/src/definition.rs:1082-1134 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (48 corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:1456 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1456-1503 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1732-1788 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (48 corresponding lines) crates/ruff_dev/src/generate_ty_cli_reference.rs:22 — crates/ruff_dev/src/generate_ty_cli_reference.rs:22-69 | crates/ruff_dev/src/generate_ty_env_vars_reference.rs:19-87 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (48 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:72 — crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:72-123 | crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs:62-109 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (48 corresponding lines) crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:14 — crates/ty_python_semantic/src/types/infer/builder/post_inference/final_variable.rs:14-61 | crates/ty_python_semantic/src/types/infer/builder/post_inference/static_class.rs:1560-1617 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (48 corresponding lines) crates/ruff_linter/src/linter.rs:366 — crates/ruff_linter/src/linter.rs:366-424 | crates/ruff_linter/src/linter.rs:435-482 — These two members are one piece of code written twice and then edited apart: 48 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (22 corresponding lines) · ×6
  • Edited copy of a member (22 corresponding lines) crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs:52 — crates/ruff_linter/src/rules/flake8_type_checking/rules/empty_type_checking_block.rs:52-76 | crates/ruff_linter/src/rules/pyupgrade/rules/useless_metaclass_type.rs:53-74 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs:57 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_dict.rs:57-78 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_dict.rs:54-76 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) crates/ruff_python_formatter/src/comments/placement.rs:1602 — crates/ruff_python_formatter/src/comments/placement.rs:1602-1627 | crates/ruff_python_formatter/src/comments/placement.rs:1773-1794 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) crates/ruff_db/src/diagnostic/render.rs:869 — crates/ruff_db/src/diagnostic/render.rs:869-890 | crates/ruff_db/src/diagnostic/render.rs:906-928 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) crates/ruff_linter/src/rules/airflow/helpers.rs:313 — crates/ruff_linter/src/rules/airflow/helpers.rs:313-334 | crates/ruff_linter/src/rules/airflow/rules/task_implicit_multiple_outputs.rs:125-160 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (22 corresponding lines) crates/ruff_server/src/session/client.rs:206 — crates/ruff_server/src/session/client.rs:206-227 | crates/ty_server/src/session/client.rs:260-285 — These two members are one piece of code written twice and then edited apart: 22 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×6
  • Duplicated block (21 lines × 2) crates/ruff_dev/src/generate_options.rs:113 — crates/ruff_dev/src/generate_options.rs:113-133 | crates/ruff_dev/src/generate_ty_options.rs:145-165 — before extracting anything, compare `crates/ruff_dev/src/generate_options.rs` and `crates/ruff_dev/src/generate_ty_options.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 63 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (21 lines × 2) crates/ruff_linter/src/fix/mod.rs:73 — crates/ruff_linter/src/fix/mod.rs:73-93 | crates/ty_python_semantic/src/fixes.rs:525-545 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (21 lines × 2) crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs:288 — crates/ruff_linter/src/rules/flake8_type_checking/rules/runtime_import_in_type_checking_block.rs:288-308 | crates/ruff_linter/src/rules/flake8_type_checking/rules/typing_only_runtime_import.rs:685-705 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (21 lines × 2) crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:136 — crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:136-156 | crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:125-145 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (21 lines × 2) crates/ty_python_core/src/re_exports.rs:346 — crates/ty_python_core/src/re_exports.rs:346-366 | crates/ty_python_core/src/re_exports.rs:413-433 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/re_exports.rs:346` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (21 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:1883 — crates/ty_python_semantic/src/types/call/bind.rs:1883-1903 | crates/ty_python_semantic/src/types/call/bind.rs:1926-1946 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:1883` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×6
  • Duplicated block (11–12 lines × 2) crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs:192 — crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs:192-202 | crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs:212-223 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/runtime_value_in_dag_or_task.rs:192` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:230 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:230-240 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:276-287 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/extraneous_whitespace.rs:230` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) crates/ruff_python_formatter/src/expression/expr_call.rs:38 — crates/ruff_python_formatter/src/expression/expr_call.rs:38-48 | crates/ruff_python_formatter/src/expression/expr_subscript.rs:43-54 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/expression/expr_call.rs:38` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) crates/ruff_server/src/server/schedule/thread/pool.rs:51 — crates/ruff_server/src/server/schedule/thread/pool.rs:51-62 | crates/ty_server/src/server/schedule/thread/pool.rs:48-58 — before extracting anything, compare `crates/ruff_server/src/server/schedule/thread/pool.rs` and `crates/ty_server/src/server/schedule/thread/pool.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 71 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/schedule/thread/pool.rs:51` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:3231 — crates/ty_python_semantic/src/types/call/bind.rs:3231-3241 | crates/ty_python_semantic/src/types/call/bind.rs:3320-3331 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:3231` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–12 lines × 2) crates/ty_python_semantic/src/types/infer/builder/annotation_expression.rs:191 — crates/ty_python_semantic/src/types/infer/builder/annotation_expression.rs:191-202 | crates/ty_python_semantic/src/types/infer/builder/annotation_expression.rs:210-220 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/annotation_expression.rs:191` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11 lines × 3) · ×6
  • Duplicated block (11 lines × 3) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:108 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:108-118 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_mkdir.rs:106-116 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_symlink.rs:110-120 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs` and `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_symlink.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 34 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) crates/ty_python_semantic/src/types/diagnostic.rs:5017 — crates/ty_python_semantic/src/types/diagnostic.rs:5017-5027 | crates/ty_python_semantic/src/types/diagnostic.rs:5063-5073 | crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs:643-653 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/diagnostic.rs:5017` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) crates/ty_python_semantic/src/types/infer/comparisons.rs:528 — crates/ty_python_semantic/src/types/infer/comparisons.rs:528-538 | crates/ty_python_semantic/src/types/narrow.rs:5590-5600 | crates/ty_python_semantic/src/types/typed_dict.rs:2097-2107 — before extracting anything, compare `crates/ty_python_semantic/src/types/narrow.rs` and `crates/ty_python_semantic/src/types/typed_dict.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (11 lines × 3) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2219 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2219-2230 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:3114-3124 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:3133-3143 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2219` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:89 — crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:89-100 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs:85-95 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs:84-94 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 3) crates/ruff_linter/src/rules/pyflakes/rules/raise_not_implemented.rs:79 — crates/ruff_linter/src/rules/pyflakes/rules/raise_not_implemented.rs:79-89 | crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:86-96 | crates/ruff_linter/src/rules/pyupgrade/rules/typing_text_str_alias.rs:73-83 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyflakes/rules/raise_not_implemented.rs:79` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×6
  • Duplicated block (10–11 lines × 2) crates/ruff_linter/src/rules/pep8_naming/helpers.rs:44 — crates/ruff_linter/src/rules/pep8_naming/helpers.rs:44-53 | crates/ruff_linter/src/rules/pep8_naming/helpers.rs:59-69 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (10–11 lines × 2) crates/ruff_linter/src/rules/ruff/rules/unnecessary_if.rs:193 — crates/ruff_linter/src/rules/ruff/rules/unnecessary_if.rs:193-203 | crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs:237-246 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/ruff/rules/unnecessary_if.rs:193` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) crates/ruff_python_ast/src/nodes.rs:2944 — crates/ruff_python_ast/src/nodes.rs:2944-2954 | crates/ruff_python_formatter/src/expression/expr_compare.rs:69-78 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/nodes.rs:2944` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_formatter/src/expression/expr_compare.rs:81` calls `token`, `fmt` and `crates/ruff_python_ast/src/nodes.rs:2954` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10–11 lines × 2) crates/ty_python_core/src/builder.rs:3181 — crates/ty_python_core/src/builder.rs:3181-3191 | crates/ty_python_core/src/builder.rs:3752-3761 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10–11 lines × 2) crates/ty_python_semantic/src/types/call/bind.rs:8569 — crates/ty_python_semantic/src/types/call/bind.rs:8569-8578 | crates/ty_python_semantic/src/types/typevar.rs:993-1003 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:8569` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) crates/ty_python_semantic/src/types/relation.rs:3049 — crates/ty_python_semantic/src/types/relation.rs:3049-3059 | crates/ty_python_semantic/src/types/relation.rs:3096-3105 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/relation.rs:3049` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–10 lines × 2) · ×6
  • Duplicated block (9–10 lines × 2) crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:362 — crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:362-370 | crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:376-385 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:362` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 2) crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:183 — crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:183-191 | crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:217-226 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:183` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) crates/ruff_python_ast/src/helpers.rs:344 — crates/ruff_python_ast/src/helpers.rs:344-353 | crates/ruff_python_ast/src/helpers.rs:364-372 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/helpers.rs:364` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) crates/ruff_python_semantic/src/analyze/type_inference.rs:288 — crates/ruff_python_semantic/src/analyze/type_inference.rs:288-296 | crates/ruff_python_semantic/src/analyze/type_inference.rs:316-325 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_semantic/src/analyze/type_inference.rs:288` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–10 lines × 2) crates/ty_python_semantic/src/types/diagnostic.rs:2057 — crates/ty_python_semantic/src/types/diagnostic.rs:2057-2065 | crates/ty_python_semantic/src/types/diagnostic.rs:2117-2126 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/diagnostic.rs:2117` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/diagnostic.rs:2116` calls `Parameter` and `crates/ty_python_semantic/src/types/diagnostic.rs:2056` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9–10 lines × 2) crates/ty_python_semantic/src/types/infer.rs:325 — crates/ty_python_semantic/src/types/infer.rs:325-334 | crates/ty_python_semantic/src/types/infer.rs:474-482 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer.rs:325` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D1 · Cyclomatic Complexity · SolutionWalker · ×5
  • SolutionWalker::validate_constrained (cyclomatic 30) crates/ty_python_semantic/src/types/constraints/solutions.rs:1142 — SolutionWalker::validate_constrained has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SolutionWalker::pending_candidate_solution (cyclomatic 24) crates/ty_python_semantic/src/types/constraints/solutions.rs:1533 — SolutionWalker::pending_candidate_solution has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SolutionWalker::binary_lower_bound_visits (cyclomatic 19) crates/ty_python_semantic/src/types/constraints/solutions.rs:229 — SolutionWalker::binary_lower_bound_visits has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SolutionWalker::attribute_typevar_failures (cyclomatic 19) crates/ty_python_semantic/src/types/constraints/solutions.rs:1719 — SolutionWalker::attribute_typevar_failures has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SolutionWalker::constraint_failure_evidence (cyclomatic 18) crates/ty_python_semantic/src/types/constraints/solutions.rs:940 — SolutionWalker::constraint_failure_evidence has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D2 · Cognitive Complexity · Bindings · ×5
  • Bindings::evaluate_known_cases (cognitive 741) crates/ty_python_semantic/src/types/call/bind.rs:1715 — Bindings::evaluate_known_cases has cognitive complexity 741 (threshold 15). Drivers by points: if/else 162 (601 pts), match/switch 23 (108 pts), loops 5 (18 pts), boolean chains 14 (nesting depth added 537). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Bindings::report_element_diagnostics (cognitive 25) crates/ty_python_semantic/src/types/call/bind.rs:1651 — Bindings::report_element_diagnostics has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (23 pts), loops 1 (2 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Bindings::evaluate_property_calls (cognitive 20) crates/ty_python_semantic/src/types/call/bind/property.rs:12 — Bindings::evaluate_property_calls has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Bindings::apply_generic_context_in_place (cognitive 18) crates/ty_python_semantic/src/types/call/bind.rs:756 — Bindings::apply_generic_context_in_place has cognitive complexity 18 (threshold 15). Drivers by points: loops 4 (11 pts), if/else 1 (4 pts), match/switch 1 (3 pts) (nesting depth added 12). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
  • Bindings::report_diagnostics_impl (cognitive 16) crates/ty_python_semantic/src/types/call/bind.rs:1597 — Bindings::report_diagnostics_impl has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), loops 2 (3 pts), match/switch 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_dev · ×5
  • ruff_dev::generate_ty_cli_reference::generate_command (cognitive 66) crates/ruff_dev/src/generate_ty_cli_reference.rs:94 — ruff_dev::generate_ty_cli_reference::generate_command has cognitive complexity 66 (threshold 15). Drivers by points: if/else 17 (42 pts), loops 7 (23 pts), boolean chains 1 (nesting depth added 41). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • ruff_dev::generate_rules_table::generate_table (cognitive 32) crates/ruff_dev/src/generate_rules_table.rs:31 — ruff_dev::generate_rules_table::generate_table has cognitive complexity 32 (threshold 15). Drivers by points: if/else 14 (25 pts), match/switch 2 (5 pts), boolean chains 1, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_dev::generate_docs::process_documentation (cognitive 26) crates/ruff_dev/src/generate_docs.rs:182 — ruff_dev::generate_docs::process_documentation has cognitive complexity 26 (threshold 15). Drivers by points: if/else 8 (20 pts), match/switch 1 (4 pts), loops 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_dev::generate_docs::main (cognitive 19) crates/ruff_dev/src/generate_docs.rs:47 — ruff_dev::generate_docs::main has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_dev::format_dev::format_dev_multi_project (cognitive 18) crates/ruff_dev/src/format_dev.rs:317 — ruff_dev::format_dev::format_dev_multi_project has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 4 (6 pts), match/switch 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SemanticModel · ×5
  • SemanticModel::resolve_load (cognitive 63) crates/ruff_python_semantic/src/model.rs:485 — SemanticModel::resolve_load has cognitive complexity 63 (threshold 15). Drivers by points: if/else 19 (56 pts), boolean chains 3, match/switch 1 (3 pts), loops 1 (nesting depth added 39). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • SemanticModel::simulate_runtime_load_at_location_in_scope (cognitive 55) crates/ruff_python_semantic/src/model.rs:975 — SemanticModel::simulate_runtime_load_at_location_in_scope has cognitive complexity 55 (threshold 15). Drivers by points: if/else 12 (37 pts), match/switch 2 (9 pts), loops 2 (5 pts), boolean chains 4 (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticModel::extract_dunder_all_names (cognitive 29) crates/ruff_python_semantic/src/model/all.rs:75 — SemanticModel::extract_dunder_all_names has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (24 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 16). Of this number, 25 points are the body's own statements and 4 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticModel::resolve_qualified_import_name (cognitive 28) crates/ruff_python_semantic/src/model.rs:1317 — SemanticModel::resolve_qualified_import_name has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (26 pts), boolean chains 1, match/switch 1 (nesting depth added 16). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • SemanticModel::lookup_symbol_in_scope (cognitive 25) crates/ruff_python_semantic/src/model.rs:858 — SemanticModel::lookup_symbol_in_scope has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (20 pts), match/switch 1 (3 pts), boolean chains 1, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SolutionWalker · ×5
  • SolutionWalker::validate_constrained (cognitive 55) crates/ty_python_semantic/src/types/constraints/solutions.rs:1142 — SolutionWalker::validate_constrained has cognitive complexity 55 (threshold 15). Drivers by points: if/else 16 (38 pts), boolean chains 8, loops 3 (6 pts), match/switch 1 (3 pts) (nesting depth added 27). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • SolutionWalker::attribute_typevar_failures (cognitive 34) crates/ty_python_semantic/src/types/constraints/solutions.rs:1719 — SolutionWalker::attribute_typevar_failures has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (27 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SolutionWalker::pending_candidate_solution (cognitive 32) crates/ty_python_semantic/src/types/constraints/solutions.rs:1533 — SolutionWalker::pending_candidate_solution has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (19 pts), boolean chains 6, match/switch 4 (6 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SolutionWalker::binary_lower_bound_visits (cognitive 22) crates/ty_python_semantic/src/types/constraints/solutions.rs:229 — SolutionWalker::binary_lower_bound_visits has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 6, loops 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SolutionWalker::constraint_failure_evidence (cognitive 21) crates/ty_python_semantic/src/types/constraints/solutions.rs:940 — SolutionWalker::constraint_failure_evidence has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (11 pts), boolean chains 6, loops 2, match/switch 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_macros · ×5
  • ruff_macros::config::derive_impl (cognitive 33) crates/ruff_macros/src/config.rs:12 — ruff_macros::config::derive_impl has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (25 pts), loops 2 (7 pts), match/switch 1 (nesting depth added 22). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_macros::rule_namespace::derive_impl (cognitive 29) crates/ruff_macros/src/rule_namespace.rs:8 — ruff_macros::rule_namespace::derive_impl has cognitive complexity 29 (threshold 15). Drivers by points: if/else 9 (17 pts), match/switch 3 (7 pts), loops 3 (4 pts), boolean chains 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_macros::map_codes::map_codes (cognitive 23) crates/ruff_macros/src/map_codes.rs:39 — ruff_macros::map_codes::map_codes has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (15 pts), loops 6 (8 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_macros::derive_message_formats::parse_expr (cognitive 19) crates/ruff_macros/src/derive_message_formats.rs:30 — ruff_macros::derive_message_formats::parse_expr has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (12 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ruff_macros::cache_key::derive_cache_key (cognitive 16) crates/ruff_macros/src/cache_key.rs:7 — ruff_macros::cache_key::derive_cache_key has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 2 (3 pts), loops 1 (2 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D4 · Code Duplication · Edited copy of a member (38 corresponding lines) · ×5
  • Edited copy of a member (38 corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:1571 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1571-1608 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1797-1834 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) crates/ruff/src/commands/rule.rs:60 — crates/ruff/src/commands/rule.rs:60-99 | crates/ruff_server/src/server/api/requests/hover.rs:113-150 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) crates/ruff_python_ast/src/helpers.rs:152 — crates/ruff_python_ast/src/helpers.rs:152-189 | crates/ruff_python_formatter/src/expression/mod.rs:1267-1305 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) crates/ruff_python_formatter/src/statement/stmt_global.rs:10 — crates/ruff_python_formatter/src/statement/stmt_global.rs:10-47 | crates/ruff_python_formatter/src/statement/stmt_nonlocal.rs:10-47 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (38 corresponding lines) crates/ruff_linter/src/rules/refurb/helpers.rs:260 — crates/ruff_linter/src/rules/refurb/helpers.rs:260-304 | crates/ruff_linter/src/rules/refurb/helpers.rs:312-349 — These two members are one piece of code written twice and then edited apart: 38 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (32 corresponding lines) · ×5
  • Edited copy of a member (32 corresponding lines) crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs:232 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/raises.rs:232-263 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/warns.rs:200-231 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) crates/mdtest/src/lib.rs:475 — crates/mdtest/src/lib.rs:475-506 | crates/ruff_linter/src/source_kind.rs:316-351 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs:119 — crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_default_value_positional_argument.rs:119-150 | crates/ruff_linter/src/rules/flake8_boolean_trap/rules/boolean_type_hint_positional_argument.rs:118-160 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/useless_import_alias.rs:72 — crates/ruff_linter/src/rules/pylint/rules/useless_import_alias.rs:72-103 | crates/ruff_linter/src/rules/pylint/rules/useless_import_alias.rs:111-145 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (32 corresponding lines) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs:301 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs:301-332 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/mod.rs:334-366 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×5
  • Duplicated block (14–15 lines × 2) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:125 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:125-138 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs:126-140 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs` and `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:125` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (14–15 lines × 2) crates/ruff_python_formatter/src/statement/stmt_for.rs:40 — crates/ruff_python_formatter/src/statement/stmt_for.rs:40-53 | crates/ruff_python_formatter/src/statement/stmt_while.rs:22-36 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_for.rs:40` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&StmtFor` in one and `&StmtWhile` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14–15 lines × 2) crates/ruff_python_parser/src/lexer.rs:776 — crates/ruff_python_parser/src/lexer.rs:776-789 | crates/ruff_python_parser/src/lexer.rs:795-809 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_parser/src/lexer.rs:776` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (14–15 lines × 2) crates/ruff_server/src/server/api.rs:123 — crates/ruff_server/src/server/api.rs:123-136 | crates/ty_server/src/server/api.rs:218-232 — before extracting anything, compare `crates/ruff_server/src/server/api.rs` and `crates/ty_server/src/server/api.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/api.rs:123` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14–15 lines × 2) crates/ty_server/src/server/api/requests/inlay_hints.rs:40 — crates/ty_server/src/server/api/requests/inlay_hints.rs:40-53 | crates/ty_server/src/server/api/requests/semantic_tokens_range.rs:35-49 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_server/src/server/api/requests/inlay_hints.rs:40` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `params` to `&InlayHintParams` in one and `&SemanticTokensRangeParams` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (13–14 lines × 2) · ×5
  • Duplicated block (13–14 lines × 2) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:109 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:109-122 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_symlink.rs:111-123 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs` and `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_symlink.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 34 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:109` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13–14 lines × 2) crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs:153 — crates/ruff_linter/src/rules/pyflakes/rules/invalid_literal_comparisons.rs:153-165 | crates/ruff_linter/src/rules/pyflakes/rules/unused_variable.rs:100-113 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (13–14 lines × 2) crates/ruff_server/src/edit/text_document.rs:91 — crates/ruff_server/src/edit/text_document.rs:91-104 | crates/ty_server/src/document/text_document.rs:101-113 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/edit/text_document.rs:91` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (13–14 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:2496 — crates/ty_python_semantic/src/types/infer/builder.rs:2496-2508 | crates/ty_python_semantic/src/types/infer/builder.rs:5494-5507 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:2496` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–14 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:9243 — crates/ty_python_semantic/src/types/infer/builder.rs:9243-9256 | crates/ty_python_semantic/src/types/infer/builder.rs:9261-9273 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:9243` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12–13 lines × 2) · ×5
  • Duplicated block (12–13 lines × 2) crates/ruff_annotate_snippets/src/renderer/render.rs:1926 — crates/ruff_annotate_snippets/src/renderer/render.rs:1926-1938 | crates/ruff_annotate_snippets/src/renderer/render.rs:1977-1988 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_annotate_snippets/src/renderer/render.rs:1926` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–13 lines × 2) crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:89 — crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:89-101 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs:85-96 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:89` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12–13 lines × 2) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:392 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:392-404 | crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:420-431 — before extracting anything, compare `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs` and `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:392` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:406` calls `slice` and `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:433` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (12–13 lines × 2) crates/ty_module_resolver/src/resolve.rs:1716 — crates/ty_module_resolver/src/resolve.rs:1716-1728 | crates/ty_module_resolver/src/resolve.rs:1794-1805 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (12–13 lines × 2) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2511 — crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2511-2522 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2557-2569 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2511` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–12 lines × 2) · ×5
  • Duplicated block (10–12 lines × 2) crates/ruff_python_formatter/src/expression/expr_slice.rs:93 — crates/ruff_python_formatter/src/expression/expr_slice.rs:93-104 | crates/ruff_python_formatter/src/expression/expr_slice.rs:127-136 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/expression/expr_slice.rs:93` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–12 lines × 2) crates/ty_ide/src/docstring/markdown/structured/google.rs:13 — crates/ty_ide/src/docstring/markdown/structured/google.rs:13-22 | crates/ty_ide/src/docstring/markdown/structured/numpy.rs:14-25 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note first that the copies are not typed on the same thing: the declarations holding them bind `parsed` to `google::Section` in one and `numpy::Section` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (10–12 lines × 2) crates/ty_python_core/src/narrowing_constraints.rs:303 — crates/ty_python_core/src/narrowing_constraints.rs:303-312 | crates/ty_python_core/src/reachability_constraints.rs:437-448 — before extracting anything, compare `crates/ty_python_core/src/narrowing_constraints.rs` and `crates/ty_python_core/src/reachability_constraints.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/narrowing_constraints.rs:303` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–12 lines × 2) crates/ty_python_core/src/narrowing_constraints.rs:370 — crates/ty_python_core/src/narrowing_constraints.rs:370-379 | crates/ty_python_core/src/reachability_constraints.rs:518-529 — before extracting anything, compare `crates/ty_python_core/src/narrowing_constraints.rs` and `crates/ty_python_core/src/reachability_constraints.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_core/src/narrowing_constraints.rs:370` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–12 lines × 2) crates/ty_python_semantic/src/types/class/typed_dict.rs:804 — crates/ty_python_semantic/src/types/class/typed_dict.rs:804-815 | crates/ty_python_semantic/src/types/class/typed_dict.rs:817-826 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/typed_dict.rs:804` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–9 lines × 2) · ×5
  • Duplicated block (8–9 lines × 2) crates/ruff_dev/src/print_ast.rs:19 — crates/ruff_dev/src/print_ast.rs:19-27 | crates/ruff_dev/src/print_tokens.rs:19-26 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 2) crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:52 — crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:52-59 | crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:93-101 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:52` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (8–9 lines × 2) crates/ruff_linter/src/rules/refurb/helpers.rs:27 — crates/ruff_linter/src/rules/refurb/helpers.rs:27-35 | crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:175-182 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/helpers.rs:27` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8–9 lines × 2) crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:341 — crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:341-349 | crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs:361-368 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:341` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–9 lines × 2) crates/ty_python_semantic/src/types/relation.rs:561 — crates/ty_python_semantic/src/types/relation.rs:561-568 | crates/ty_python_semantic/src/types/relation.rs:1158-1166 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/relation.rs:561` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (8 lines × 3) · ×5
  • Duplicated block (8 lines × 3) crates/ruff_linter/src/rules/refurb/helpers.rs:27 — crates/ruff_linter/src/rules/refurb/helpers.rs:27-34 | crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs:183-190 | crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs:355-362 — before extracting anything, compare `crates/ruff_linter/src/rules/refurb/helpers.rs` and `crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/helpers.rs:27` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (8 lines × 3) crates/ty_python_semantic/src/types/call/bind.rs:8569 — crates/ty_python_semantic/src/types/call/bind.rs:8569-8577 | crates/ty_python_semantic/src/types/instance.rs:1420-1428 | crates/ty_python_semantic/src/types/typevar.rs:993-1000 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:8569` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) crates/ty_python_semantic/src/types/ide_support.rs:2119 — crates/ty_python_semantic/src/types/ide_support.rs:2119-2126 | crates/ty_python_semantic/src/types/ide_support.rs:2131-2138 | crates/ty_python_semantic/src/types/ide_support.rs:2145-2152 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/ide_support.rs:2119` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) crates/ty_python_semantic/src/types/set_theoretic.rs:146 — crates/ty_python_semantic/src/types/set_theoretic.rs:146-153 | crates/ty_python_semantic/src/types/set_theoretic.rs:1166-1173 | crates/ty_python_semantic/src/types/set_theoretic.rs:1192-1199 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic.rs:146` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 3) crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:106 — crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:106-113 | crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:117-126 | crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:130-139 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:106` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:141` calls `annotate`, `secondary` and `crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs:114` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 4) · ×5
  • Duplicated block (7 lines × 4) crates/ruff_linter/src/linter.rs:372 — crates/ruff_linter/src/linter.rs:372-378 | crates/ruff_linter/src/linter.rs:441-447 | crates/ruff_linter/src/linter.rs:551-557 | crates/ruff_server/src/lint.rs:196-202 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (7 lines × 4) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:775 — crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:775-781 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:802-808 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:888-895 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:923-930 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:775` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:281 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:281-287 | crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:405-411 | crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs:192-198 | crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs:364-370 — before extracting anything, compare `crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs` and `crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 37 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:281` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 4) crates/ty_python_semantic/src/types/typevar.rs:1786 — crates/ty_python_semantic/src/types/typevar.rs:1786-1792 | crates/ty_python_semantic/src/types/typevar.rs:1808-1814 | crates/ty_python_semantic/src/types/typevar.rs:1829-1835 | crates/ty_python_semantic/src/types/typevar.rs:2214-2220 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/typevar.rs:1786` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/typevar.rs:2211` calls `typevar` and `crates/ty_python_semantic/src/types/typevar.rs:1783` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 4) crates/ruff_python_ast/src/nodes.rs:1328 — crates/ruff_python_ast/src/nodes.rs:1328-1334 | crates/ruff_python_ast/src/nodes.rs:1372-1378 | crates/ruff_python_ast/src/nodes.rs:1883-1889 | crates/ruff_python_ast/src/nodes.rs:2300-2306 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D1 · Cyclomatic Complexity · SemanticIndexBuilder · ×4
  • SemanticIndexBuilder::visit_stmt_impl (cyclomatic 172) crates/ty_python_core/src/builder.rs:3896 — SemanticIndexBuilder::visit_stmt_impl has cyclomatic complexity 172 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SemanticIndexBuilder::visit_expr_with_context (cyclomatic 46) crates/ty_python_core/src/builder.rs:3487 — SemanticIndexBuilder::visit_expr_with_context has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SemanticIndexBuilder::pop_scope (cyclomatic 23) crates/ty_python_core/src/builder.rs:892 — SemanticIndexBuilder::pop_scope has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SemanticIndexBuilder::visit_bool_expression (cyclomatic 16) crates/ty_python_core/src/builder.rs:3779 — SemanticIndexBuilder::visit_bool_expression has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Checker · ×4
  • Checker::visit_expr (cyclomatic 124) crates/ruff_linter/src/checkers/ast/mod.rs:1781 — Checker::visit_expr has cyclomatic complexity 124 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Checker::visit_stmt (cyclomatic 101) crates/ruff_linter/src/checkers/ast/mod.rs:1048 — Checker::visit_stmt has cyclomatic complexity 101 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Checker::report_semantic_error (cyclomatic 29) crates/ruff_linter/src/checkers/ast/mod.rs:773 — Checker::report_semantic_error has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Checker::handle_node_store (cyclomatic 18) crates/ruff_linter/src/checkers/ast/mod.rs:2905 — Checker::handle_node_store has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · SemanticTokenVisitor · ×4
  • SemanticTokenVisitor::visit_stmt (cyclomatic 43) crates/ty_ide/src/semantic_tokens.rs:830 — SemanticTokenVisitor::visit_stmt has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SemanticTokenVisitor::classify_from_definition (cyclomatic 21) crates/ty_ide/src/semantic_tokens.rs:404 — SemanticTokenVisitor::classify_from_definition has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SemanticTokenVisitor::visit_expr (cyclomatic 20) crates/ty_ide/src/semantic_tokens.rs:1079 — SemanticTokenVisitor::visit_expr has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • SemanticTokenVisitor::classify_from_type_for_attribute (cyclomatic 18) crates/ty_ide/src/semantic_tokens.rs:586 — SemanticTokenVisitor::classify_from_type_for_attribute has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · SemanticSyntaxChecker · ×4
  • SemanticSyntaxChecker::check_stmt (cyclomatic 42) crates/ruff_python_parser/src/semantic_errors.rs:79 — SemanticSyntaxChecker::check_stmt has cyclomatic complexity 42 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SemanticSyntaxChecker::visit_expr (cyclomatic 28) crates/ruff_python_parser/src/semantic_errors.rs:923 — SemanticSyntaxChecker::visit_expr has cyclomatic complexity 28 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • SemanticSyntaxChecker::check_annotation (cyclomatic 18) crates/ruff_python_parser/src/semantic_errors.rs:368 — SemanticSyntaxChecker::check_annotation has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SemanticSyntaxChecker::debug_shadowing (cyclomatic 16) crates/ruff_python_parser/src/semantic_errors.rs:595 — SemanticSyntaxChecker::debug_shadowing has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · CallInference · ×4
  • CallInference::select_return_type (cyclomatic 24) crates/ty_python_semantic/src/types/call/bind.rs:6563 — CallInference::select_return_type has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • CallInference::infer_legacy (cyclomatic 17) crates/ty_python_semantic/src/types/call/bind.rs:6970 — CallInference::infer_legacy has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • CallInference::has_invariant_return_difference (cyclomatic 16) crates/ty_python_semantic/src/types/call/bind.rs:6440 — CallInference::has_invariant_return_difference has cyclomatic complexity 16 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • CallInference::infer_typevartuple_argument_constraints (cyclomatic 16) crates/ty_python_semantic/src/types/call/bind.rs:7415 — CallInference::infer_typevartuple_argument_constraints has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · SpecializationBuilder · ×4
  • SpecializationBuilder::infer_map_inner (cognitive 202) crates/ty_python_semantic/src/types/generics.rs:4147 — SpecializationBuilder::infer_map_inner has cognitive complexity 202 (threshold 15). Drivers by points: if/else 58 (135 pts), loops 11 (31 pts), boolean chains 25, match/switch 5 (11 pts) (nesting depth added 103). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SpecializationBuilder::infer_from_callable_signature (cognitive 18) crates/ty_python_semantic/src/types/generics.rs:3905 — SpecializationBuilder::infer_from_callable_signature has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (7 pts), loops 3 (7 pts), match/switch 1 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SpecializationBuilder::insert_hash_map_type_mapping (cognitive 16) crates/ty_python_semantic/src/types/generics.rs:3445 — SpecializationBuilder::insert_hash_map_type_mapping has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SpecializationBuilder::common_typed_dict_protocol_constraints (cognitive 16) crates/ty_python_semantic/src/types/generics.rs:3705 — SpecializationBuilder::common_typed_dict_protocol_constraints has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (8 pts), boolean chains 7, match/switch 1 (nesting depth added 1). Most of this is not in the body itself: 6 of the 16 points are its own statements and the rest belongs to 2 function items inside it that branch (collect_typed_dicts, is_string_keyed_mapping). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · Printer · ×4
  • Printer::write_summary_text (cognitive 106) crates/ruff/src/printer.rs:90 — Printer::write_summary_text has cognitive complexity 106 (threshold 15). Drivers by points: if/else 40 (105 pts), boolean chains 1 (nesting depth added 65). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Printer::print_element (cognitive 59) crates/ruff_formatter/src/printer/mod.rs:94 — Printer::print_element has cognitive complexity 59 (threshold 15). Drivers by points: if/else 21 (41 pts), match/switch 9 (17 pts), boolean chains 1 (nesting depth added 28). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Printer::print_fill_entries (cognitive 41) crates/ruff_formatter/src/printer/mod.rs:640 — Printer::print_fill_entries has cognitive complexity 41 (threshold 15). Drivers by points: if/else 13 (29 pts), loops 3 (6 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Printer::write_once (cognitive 18) crates/ruff/src/printer.rs:214 — Printer::write_once has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (17 pts), boolean chains 1 (nesting depth added 9). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Lexer · ×4
  • Lexer::consume_ascii_character (cognitive 90) crates/ruff_python_parser/src/lexer.rs:398 — Lexer::consume_ascii_character has cognitive complexity 90 (threshold 15). Drivers by points: if/else 53 (85 pts), boolean chains 4, match/switch 1 (nesting depth added 32). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Lexer::lex_interpolated_string_middle_or_end (cognitive 47) crates/ruff_python_parser/src/lexer.rs:745 — Lexer::lex_interpolated_string_middle_or_end has cognitive complexity 47 (threshold 15). Drivers by points: if/else 21 (42 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Lexer::lex_string (cognitive 30) crates/ruff_python_parser/src/lexer.rs:873 — Lexer::lex_string has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (23 pts), loops 2 (4 pts), match/switch 1 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Lexer::lex_token (cognitive 28) crates/ruff_python_parser/src/lexer.rs:155 — Lexer::lex_token has cognitive complexity 28 (threshold 15). Drivers by points: if/else 15 (26 pts), match/switch 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SemanticSyntaxChecker · ×4
  • SemanticSyntaxChecker::check_stmt (cognitive 60) crates/ruff_python_parser/src/semantic_errors.rs:79 — SemanticSyntaxChecker::check_stmt has cognitive complexity 60 (threshold 15). Drivers by points: if/else 21 (46 pts), loops 5 (12 pts), boolean chains 1, match/switch 1 (nesting depth added 32). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • SemanticSyntaxChecker::visit_expr (cognitive 30) crates/ruff_python_parser/src/semantic_errors.rs:923 — SemanticSyntaxChecker::visit_expr has cognitive complexity 30 (threshold 15). Drivers by points: if/else 7 (17 pts), loops 3 (6 pts), match/switch 3 (6 pts), boolean chains 1 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • SemanticSyntaxChecker::check_annotation (cognitive 28) crates/ruff_python_parser/src/semantic_errors.rs:368 — SemanticSyntaxChecker::check_annotation has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • SemanticSyntaxChecker::debug_shadowing (cognitive 25) crates/ruff_python_parser/src/semantic_errors.rs:595 — SemanticSyntaxChecker::debug_shadowing has cognitive complexity 25 (threshold 15). Drivers by points: loops 6 (14 pts), if/else 3 (7 pts), match/switch 2 (4 pts) (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · AssignmentAttributeWriteEvaluator · ×4
  • AssignmentAttributeWriteEvaluator::evaluate (cognitive 56) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:275 — AssignmentAttributeWriteEvaluator::evaluate has cognitive complexity 56 (threshold 15). Drivers by points: if/else 19 (41 pts), match/switch 4 (8 pts), boolean chains 4, loops 1 (3 pts) (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AssignmentAttributeWriteEvaluator::evaluate_instance (cognitive 36) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:545 — AssignmentAttributeWriteEvaluator::evaluate_instance has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (23 pts), match/switch 4 (8 pts), boolean chains 5 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • AssignmentAttributeWriteEvaluator::evaluate_class (cognitive 27) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:707 — AssignmentAttributeWriteEvaluator::evaluate_class has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (21 pts), match/switch 3 (5 pts), boolean chains 1 (nesting depth added 14). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • AssignmentAttributeWriteEvaluator::report (cognitive 27) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:1011 — AssignmentAttributeWriteEvaluator::report has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (25 pts), boolean chains 1, match/switch 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ruff_workspace · ×4
  • ruff_workspace::configuration::warn_about_deprecated_top_level_lint_options (cognitive 46) crates/ruff_workspace/src/configuration.rs:1476 — ruff_workspace::configuration::warn_about_deprecated_top_level_lint_options has cognitive complexity 46 (threshold 15). Drivers by points: if/else 46. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • ruff_workspace::resolver::match_any_exclusion (cognitive 25) crates/ruff_workspace/src/resolver.rs:924 — ruff_workspace::resolver::match_any_exclusion has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_workspace::resolver::project_files_in_path (cognitive 22) crates/ruff_workspace/src/resolver.rs:478 — ruff_workspace::resolver::project_files_in_path has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 3 (6 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_workspace::pyproject::load_options (cognitive 17) crates/ruff_workspace/src/pyproject.rs:182 — ruff_workspace::pyproject::load_options has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (17 pts) (nesting depth added 9). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ty_module_resolver · ×4
  • ty_module_resolver::module_glob::glob_to_regex (cognitive 40) crates/ty_module_resolver/src/module_glob.rs:267 — ty_module_resolver::module_glob::glob_to_regex has cognitive complexity 40 (threshold 15). Drivers by points: if/else 17 (33 pts), loops 2 (5 pts), boolean chains 2 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_module_resolver::resolve::site_packages_editables (cognitive 23) crates/ty_module_resolver/src/resolve.rs:989 — ty_module_resolver::resolve::site_packages_editables has cognitive complexity 23 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 3 (6 pts), match/switch 2 (6 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_module_resolver::resolve::is_pkgutil_extend_path (cognitive 19) crates/ty_module_resolver/src/resolve.rs:1681 — ty_module_resolver::resolve::is_pkgutil_extend_path has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (17 pts), boolean chains 1, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_module_resolver::resolve::dynamic_resolution_paths (cognitive 16) crates/ty_module_resolver/src/resolve.rs:1089 — ty_module_resolver::resolve::dynamic_resolution_paths has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ClassType · ×4
  • ClassType::own_class_member (cognitive 40) crates/ty_python_semantic/src/types/class.rs:1916 — ClassType::own_class_member has cognitive complexity 40 (threshold 15). Drivers by points: if/else 7 (26 pts), loops 3 (9 pts), match/switch 3 (4 pts), boolean chains 1 (nesting depth added 26). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • ClassType::into_callable_with_receiver (cognitive 26) crates/ty_python_semantic/src/types/class.rs:2350 — ClassType::into_callable_with_receiver has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (22 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ClassType::abstract_methods (cognitive 25) crates/ty_python_semantic/src/types/abstract_methods.rs:256 — ClassType::abstract_methods has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (3 pts), boolean chains 2, match/switch 1 (nesting depth added 12). Of this number, 24 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ClassType::could_coexist_in_mro_with_impl (cognitive 18) crates/ty_python_semantic/src/types/class.rs:1782 — ClassType::could_coexist_in_mro_with_impl has cognitive complexity 18 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D4 · Code Duplication · Edited copy of a member (42 corresponding lines) · ×4
  • Edited copy of a member (42 corresponding lines) crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:628 — crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:628-669 | crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:681-732 — These two members are one piece of code written twice and then edited apart: 42 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (42 corresponding lines) crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:60 — crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:60-103 | crates/ruff_linter/src/rules/flake8_use_pathlib/helpers.rs:155-196 — These two members are one piece of code written twice and then edited apart: 42 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (42 corresponding lines) crates/ruff_python_parser/src/parser/statement.rs:924 — crates/ruff_python_parser/src/parser/statement.rs:924-965 | crates/ruff_python_parser/src/parser/statement.rs:2802-2863 — These two members are one piece of code written twice and then edited apart: 42 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (42 corresponding lines) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs:72 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rename.rs:72-113 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_replace.rs:75-116 — These two members are one piece of code written twice and then edited apart: 42 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (34 corresponding lines) · ×4
  • Edited copy of a member (34 corresponding lines) crates/ty_python_semantic/src/types/class/typed_dict.rs:232 — crates/ty_python_semantic/src/types/class/typed_dict.rs:232-265 | crates/ty_python_semantic/src/types/class/typed_dict.rs:672-714 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (34 corresponding lines) crates/ty_server/src/server/api/requests/call_hierarchy_incoming_calls.rs:29 — crates/ty_server/src/server/api/requests/call_hierarchy_incoming_calls.rs:29-66 | crates/ty_server/src/server/api/requests/call_hierarchy_outgoing_calls.rs:29-62 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (34 corresponding lines) crates/ruff_server/src/server.rs:384 — crates/ruff_server/src/server.rs:384-419 | crates/ty_server/src/server.rs:212-245 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (34 corresponding lines) crates/ruff_python_semantic/src/analyze/function_type.rs:85 — crates/ruff_python_semantic/src/analyze/function_type.rs:85-118 | crates/ruff_python_semantic/src/analyze/function_type.rs:126-159 — These two members are one piece of code written twice and then edited apart: 34 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (28 corresponding lines) · ×4
  • Edited copy of a member (28 corresponding lines) crates/ty_python_core/src/definition.rs:121 — crates/ty_python_core/src/definition.rs:121-152 | crates/ty_python_core/src/definition.rs:157-184 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (28 corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:7739 — crates/ty_python_semantic/src/types/infer/builder.rs:7739-7766 | crates/ty_python_semantic/src/types/infer/builder.rs:7768-7797 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (28 corresponding lines) crates/ty_python_semantic/src/types/signatures.rs:2362 — crates/ty_python_semantic/src/types/signatures.rs:2362-2391 | crates/ty_python_semantic/src/types/signatures.rs:2400-2427 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (28 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:307 — crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:307-334 | crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:347-377 — These two members are one piece of code written twice and then edited apart: 28 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (37 corresponding lines) · ×4
  • Edited copy of a member (37 corresponding lines) crates/ruff_linter/src/suppression.rs:1313 — crates/ruff_linter/src/suppression.rs:1313-1352 | crates/ty_python_semantic/src/suppression/parser.rs:90-126 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (37 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/useless_class_metaclass_type.rs:53 — crates/ruff_linter/src/rules/pyupgrade/rules/useless_class_metaclass_type.rs:53-89 | crates/ruff_linter/src/rules/pyupgrade/rules/useless_object_inheritance.rs:54-90 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (37 corresponding lines) crates/ruff_linter/src/rules/pandas_vet/rules/call.rs:170 — crates/ruff_linter/src/rules/pandas_vet/rules/call.rs:170-207 | crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs:149-185 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (37 corresponding lines) crates/ruff_linter/src/rules/flake8_async/rules/blocking_open_call.rs:74 — crates/ruff_linter/src/rules/flake8_async/rules/blocking_open_call.rs:74-113 | crates/ruff_linter/src/rules/ruff/rules/non_octal_permissions.rs:212-248 — These two members are one piece of code written twice and then edited apart: 37 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (30 corresponding lines) · ×4
  • Edited copy of a member (30 corresponding lines) crates/ruff_server/src/server/api/requests/code_action.rs:130 — crates/ruff_server/src/server/api/requests/code_action.rs:130-160 | crates/ruff_server/src/server/api/requests/code_action.rs:162-191 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:174 — crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:174-203 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_if.rs:192-221 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs:288 — crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs:288-317 | crates/ruff_linter/src/rules/flake8_pyi/rules/unused_private_type_definition.rs:340-372 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (30 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:3805 — crates/ty_python_semantic/src/types/diagnostic.rs:3805-3834 | crates/ty_python_semantic/src/types/diagnostic.rs:3840-3870 — These two members are one piece of code written twice and then edited apart: 30 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (24 corresponding lines) · ×4
  • Edited copy of a member (24 corresponding lines) crates/ruff_python_parser/src/parser/expression.rs:2372 — crates/ruff_python_parser/src/parser/expression.rs:2372-2399 | crates/ruff_python_parser/src/parser/expression.rs:2404-2427 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) crates/ruff_linter/src/rules/pyupgrade/rules/datetime_utc_alias.rs:59 — crates/ruff_linter/src/rules/pyupgrade/rules/datetime_utc_alias.rs:59-86 | crates/ruff_linter/src/rules/pyupgrade/rules/open_alias.rs:55-78 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:294 — crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:294-317 | crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs:320-344 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (24 corresponding lines) crates/ruff_python_trivia/src/tokenizer.rs:41 — crates/ruff_python_trivia/src/tokenizer.rs:41-64 | crates/ruff_python_trivia/src/tokenizer.rs:67-90 — These two members are one piece of code written twice and then edited apart: 24 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 13+ corresponding lines) · ×4
  • Edited copies of one member (3 members, 13+ corresponding lines) crates/ty_python_semantic/src/types/definition.rs:25 — crates/ty_python_semantic/src/types/definition.rs:25-40 | crates/ty_python_semantic/src/types/definition.rs:63-75 | crates/ty_python_semantic/src/types/definition.rs:79-91 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) crates/ruff_python_index/src/multiline_ranges.rs:12 — crates/ruff_python_index/src/multiline_ranges.rs:12-24 | crates/ruff_python_index/src/multiline_ranges.rs:27-39 | crates/ruff_python_trivia/src/comment_ranges.rs:79-91 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) crates/ty_python_semantic/src/types/call.rs:386 — crates/ty_python_semantic/src/types/call.rs:386-398 | crates/ty_python_semantic/src/types/call.rs:404-416 | crates/ty_python_semantic/src/types/call.rs:422-434 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 13+ corresponding lines) crates/ruff_server/src/server/api/requests/format.rs:29 — crates/ruff_server/src/server/api/requests/format.rs:29-41 | crates/ruff_server/src/server/api/requests/format_range.rs:24-36 | crates/ruff_server/src/server/api/requests/hover.rs:31-43 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (5 corresponding lines) · ×4
  • Edited copy of a member (5 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs:367 — crates/ruff_linter/src/rules/ruff/rules/sort_dunder_slots.rs:367-371 | crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs:209-213 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) crates/ruff_server/src/edit/text_document.rs:152 — crates/ruff_server/src/edit/text_document.rs:152-156 | crates/ty_server/src/document/text_document.rs:150-154 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) crates/mdtest/src/matcher.rs:77 — crates/mdtest/src/matcher.rs:77-81 | crates/ruff_db/src/system/command.rs:74-79 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (5 corresponding lines) crates/ty_python_semantic/src/types/class.rs:1349 — crates/ty_python_semantic/src/types/class.rs:1349-1353 | crates/ty_python_semantic/src/types/ide_support.rs:539-544 — These two members are one piece of code written twice and then edited apart: 5 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (28 lines × 2) · ×4
  • Duplicated block (28 lines × 2) crates/ruff_annotate_snippets/src/renderer/render.rs:2220 — crates/ruff_annotate_snippets/src/renderer/render.rs:2220-2247 | crates/ruff_annotate_snippets/src/renderer/render.rs:2250-2277 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (28 lines × 2) crates/ruff_server/src/server/main_loop.rs:58 — crates/ruff_server/src/server/main_loop.rs:58-85 | crates/ty_server/src/server/main_loop.rs:60-87 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/main_loop.rs:58` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (28 lines × 2) crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:1155 — crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:1155-1182 | crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:1183-1210 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (28 lines × 2) crates/ruff_formatter/shared_traits.rs:69 — crates/ruff_formatter/shared_traits.rs:69-96 | crates/ruff_python_formatter/src/shared_traits.rs:74-101 — before extracting anything, compare `crates/ruff_formatter/shared_traits.rs` and `crates/ruff_python_formatter/src/shared_traits.rs` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_formatter/shared_traits.rs:69` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×4
  • Duplicated block (26 lines × 2) crates/ruff_linter/src/rules/isort/normalize.rs:115 — crates/ruff_linter/src/rules/isort/normalize.rs:115-140 | crates/ruff_linter/src/rules/isort/normalize.rs:168-193 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/isort/normalize.rs:115` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (26 lines × 2) crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs:74 — crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs:74-99 | crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs:68-93 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs:74` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (26 lines × 2) crates/ruff_python_literal/src/escape.rs:185 — crates/ruff_python_literal/src/escape.rs:185-210 | crates/ruff_python_literal/src/escape.rs:533-558 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_literal/src/escape.rs:185` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (26 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:12206 — crates/ty_python_semantic/src/types/infer/builder.rs:12206-12231 | crates/ty_python_semantic/src/types/infer/builder.rs:12834-12859 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (24 lines × 2) · ×4
  • Duplicated block (24 lines × 2) crates/ruff/src/commands/rule.rs:61 — crates/ruff/src/commands/rule.rs:61-84 | crates/ruff_server/src/server/api/requests/hover.rs:114-137 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff/src/commands/rule.rs:61` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs:174 — crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs:174-197 | crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs:341-364 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (24 lines × 2) crates/ruff_python_semantic/src/analyze/function_type.rs:95 — crates/ruff_python_semantic/src/analyze/function_type.rs:95-118 | crates/ruff_python_semantic/src/analyze/function_type.rs:136-159 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_semantic/src/analyze/function_type.rs:95` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (24 lines × 2) crates/ruff_server/src/server/schedule.rs:50 — crates/ruff_server/src/server/schedule.rs:50-73 | crates/ty_server/src/server/schedule.rs:50-73 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `task` to `Task` in one and `task::Task` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (18–19 lines × 2) · ×4
  • Duplicated block (18–19 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/collapsible_if.rs:339 — crates/ruff_linter/src/rules/flake8_simplify/rules/collapsible_if.rs:339-357 | crates/ruff_linter/src/rules/flake8_simplify/rules/fix_with.rs:36-53 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/collapsible_if.rs:339` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_chmod.rs:110 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_chmod.rs:110-128 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_stat.rs:157-174 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_chmod.rs:110` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:1217 — crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:1217-1234 | crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:1284-1302 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/suspicious_conditions/diagnostic.rs:1217` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18–19 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3642 — crates/ty_python_semantic/src/types/signatures.rs:3642-3660 | crates/ty_python_semantic/src/types/signatures.rs:3671-3688 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3642` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–15 lines × 2) · ×4
  • Duplicated block (12–15 lines × 2) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:309 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:309-323 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:436-447 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/checkers/ast/analyze/expression.rs:309` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–15 lines × 2) crates/ruff_linter/src/checkers/ast/mod.rs:1178 — crates/ruff_linter/src/checkers/ast/mod.rs:1178-1189 | crates/ruff_linter/src/checkers/ast/mod.rs:1245-1259 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12–15 lines × 2) crates/ruff_linter/src/rules/flake8_bugbear/rules/cached_instance_method.rs:92 — crates/ruff_linter/src/rules/flake8_bugbear/rules/cached_instance_method.rs:92-103 | crates/ruff_linter/src/rules/pylint/rules/super_without_brackets.rs:100-114 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_bugbear/rules/cached_instance_method.rs:92` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–15 lines × 2) crates/ruff_linter/src/rules/isort/annotate.rs:30 — crates/ruff_linter/src/rules/isort/annotate.rs:30-41 | crates/ruff_linter/src/rules/isort/annotate.rs:69-83 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/isort/annotate.rs:30` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×4
  • Duplicated block (14 lines × 3) crates/ruff_python_formatter/src/expression/expr_bytes_literal.rs:17 — crates/ruff_python_formatter/src/expression/expr_bytes_literal.rs:17-30 | crates/ruff_python_formatter/src/expression/expr_f_string.rs:19-32 | crates/ruff_python_formatter/src/expression/expr_t_string.rs:19-32 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/expression/expr_bytes_literal.rs:17` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&ExprBytesLiteral` in one and `&ExprFString` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (14 lines × 3) crates/ty_python_semantic/src/types/constraints/paths.rs:1079 — crates/ty_python_semantic/src/types/constraints/paths.rs:1079-1092 | crates/ty_python_semantic/src/types/constraints/paths.rs:1108-1121 | crates/ty_python_semantic/src/types/constraints/paths.rs:1142-1155 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/paths.rs:1079` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/constraints/paths.rs:1107` calls `into_inner`, `display` and `crates/ty_python_semantic/src/types/constraints/paths.rs:1078` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 3) crates/ty_python_semantic/src/types/signatures.rs:3655 — crates/ty_python_semantic/src/types/signatures.rs:3655-3669 | crates/ty_python_semantic/src/types/signatures.rs:3722-3735 | crates/ty_python_semantic/src/types/signatures.rs:3868-3881 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3655` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (14 lines × 3) crates/ty_python_semantic/src/types/signatures.rs:3683 — crates/ty_python_semantic/src/types/signatures.rs:3683-3697 | crates/ty_python_semantic/src/types/signatures.rs:3895-3908 | crates/ty_python_semantic/src/types/signatures.rs:4011-4024 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3683` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
X2 · Cancellation propagation · Async function without AbortSignal · ×4
  • Async function without AbortSignal: fetchPlayground playground/ty/src/Editor/api.ts:14 — `fetchPlayground` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: savePlayground playground/ty/src/Editor/api.ts:27 — `savePlayground` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: fetchPlayground playground/ruff/src/Editor/api.ts:13 — `fetchPlayground` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
  • Async function without AbortSignal: savePlayground playground/ruff/src/Editor/api.ts:24 — `savePlayground` awaits `fetch(…)` but neither accepts an AbortSignal nor passes one on, so its caller cannot stop the request once it has started. Accept `{ signal }` and pass it through: `fetch(url, { signal })`.
D1 · Cyclomatic Complexity · Generator · ×3
  • Generator::unparse_stmt (cyclomatic 80) crates/ruff_python_codegen/src/generator.rs:248 — Generator::unparse_stmt has cyclomatic complexity 80 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Generator::unparse_expr (cyclomatic 71) crates/ruff_python_codegen/src/generator.rs:942 — Generator::unparse_expr has cyclomatic complexity 71 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • Generator::unparse_pattern (cyclomatic 17) crates/ruff_python_codegen/src/generator.rs:769 — Generator::unparse_pattern has cyclomatic complexity 17 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · NarrowingConstraintsBuilder · ×3
  • NarrowingConstraintsBuilder::evaluate_expr_compare (cyclomatic 78) crates/ty_python_semantic/src/types/narrow.rs:4047 — NarrowingConstraintsBuilder::evaluate_expr_compare has cyclomatic complexity 78 (threshold 15). Of this number, 68 points are the body's own statements and 10 belong to 2 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • NarrowingConstraintsBuilder::evaluate_expr_compare_op (cyclomatic 21) crates/ty_python_semantic/src/types/narrow.rs:3919 — NarrowingConstraintsBuilder::evaluate_expr_compare_op has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • NarrowingConstraintsBuilder::evaluate_expr_call (cyclomatic 16) crates/ty_python_semantic/src/types/narrow.rs:4614 — NarrowingConstraintsBuilder::evaluate_expr_call has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ruff_python_formatter · ×3
  • ruff_python_formatter::comments::placement::handle_enclosed_comment (cyclomatic 56) crates/ruff_python_formatter/src/comments/placement.rs:192 — ruff_python_formatter::comments::placement::handle_enclosed_comment has cyclomatic complexity 56 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • ruff_python_formatter::verbatim::write_suppressed_statements (cyclomatic 21) crates/ruff_python_formatter/src/verbatim.rs:262 — ruff_python_formatter::verbatim::write_suppressed_statements has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • ruff_python_formatter::string::normalize::normalize_string (cyclomatic 19) crates/ruff_python_formatter/src/string/normalize.rs:664 — ruff_python_formatter::string::normalize::normalize_string has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Printer · ×3
  • Printer::print_element (cyclomatic 50) crates/ruff_formatter/src/printer/mod.rs:94 — Printer::print_element has cyclomatic complexity 50 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Printer::write_summary_text (cyclomatic 26) crates/ruff/src/printer.rs:90 — Printer::write_summary_text has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Printer::print_fill_entries (cyclomatic 17) crates/ruff_formatter/src/printer/mod.rs:640 — Printer::print_fill_entries has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CallableBinding · ×3
  • CallableBinding::check_types (cyclomatic 35) crates/ty_python_semantic/src/types/call/bind.rs:3931 — CallableBinding::check_types has cyclomatic complexity 35 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • CallableBinding::report_diagnostics (cyclomatic 25) crates/ty_python_semantic/src/types/call/bind.rs:4813 — CallableBinding::report_diagnostics has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • CallableBinding::filter_overloads_using_any_or_unknown (cyclomatic 19) crates/ty_python_semantic/src/types/call/bind.rs:4400 — CallableBinding::filter_overloads_using_any_or_unknown has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AssignmentAttributeWriteEvaluator · ×3
  • AssignmentAttributeWriteEvaluator::evaluate (cyclomatic 34) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:275 — AssignmentAttributeWriteEvaluator::evaluate has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AssignmentAttributeWriteEvaluator::evaluate_instance (cyclomatic 24) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:545 — AssignmentAttributeWriteEvaluator::evaluate_instance has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • AssignmentAttributeWriteEvaluator::report (cyclomatic 23) crates/ty_python_semantic/src/types/infer/builder/attribute_assignment.rs:1011 — AssignmentAttributeWriteEvaluator::report has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RecoveryContextKind · ×3
  • RecoveryContextKind::list_terminator_kind (cyclomatic 30) crates/ruff_python_parser/src/parser/mod.rs:1293 — RecoveryContextKind::list_terminator_kind has cyclomatic complexity 30 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: RecoveryContext::to_kind (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • RecoveryContextKind::is_list_element (cyclomatic 26) crates/ruff_python_parser/src/parser/mod.rs:1472 — RecoveryContextKind::is_list_element has cyclomatic complexity 26 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: RecoveryContext::to_kind (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • RecoveryContextKind::create_error (cyclomatic 26) crates/ruff_python_parser/src/parser/mod.rs:1516 — RecoveryContextKind::create_error has cyclomatic complexity 26 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: RecoveryContext::to_kind (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ty_ide · ×3
  • ty_ide::docstring::markdown::general::render_with_indentation_mode (cyclomatic 28) crates/ty_ide/src/docstring/markdown/general.rs:75 — ty_ide::docstring::markdown::general::render_with_indentation_mode has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_ide::hover::hover (cyclomatic 20) crates/ty_ide/src/hover.rs:21 — ty_ide::hover::hover has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • ty_ide::semantic_tokens::script_metadata_tokens (cyclomatic 16) crates/ty_ide/src/semantic_tokens.rs:221 — ty_ide::semantic_tokens::script_metadata_tokens has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: SemanticTokenType::as_lsp_concept (cyclomatic 17) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ClassType · ×3
  • ClassType::own_class_member (cyclomatic 21) crates/ty_python_semantic/src/types/class.rs:1916 — ClassType::own_class_member has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ClassType::into_callable_with_receiver (cyclomatic 17) crates/ty_python_semantic/src/types/class.rs:2350 — ClassType::into_callable_with_receiver has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ClassType::could_coexist_in_mro_with_impl (cyclomatic 16) crates/ty_python_semantic/src/types/class.rs:1782 — ClassType::could_coexist_in_mro_with_impl has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · Generator · ×3
  • Generator::unparse_stmt (cognitive 101) crates/ruff_python_codegen/src/generator.rs:248 — Generator::unparse_stmt has cognitive complexity 101 (threshold 15). Drivers by points: if/else 32 (63 pts), loops 14 (30 pts), match/switch 3 (7 pts), boolean chains 1 (nesting depth added 51). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Generator::unparse_expr (cognitive 84) crates/ruff_python_codegen/src/generator.rs:942 — Generator::unparse_expr has cognitive complexity 84 (threshold 15). Drivers by points: if/else 27 (50 pts), loops 8 (19 pts), match/switch 6 (14 pts), boolean chains 1 (nesting depth added 42). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Generator::unparse_pattern (cognitive 22) crates/ruff_python_codegen/src/generator.rs:769 — Generator::unparse_pattern has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (10 pts), loops 4 (8 pts), match/switch 2 (4 pts) (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SemanticTokenVisitor · ×3
  • SemanticTokenVisitor::visit_stmt (cognitive 76) crates/ty_ide/src/semantic_tokens.rs:830 — SemanticTokenVisitor::visit_stmt has cognitive complexity 76 (threshold 15). Drivers by points: if/else 18 (44 pts), loops 12 (27 pts), match/switch 2 (4 pts), boolean chains 1 (nesting depth added 43). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • SemanticTokenVisitor::classify_from_definition (cognitive 32) crates/ty_ide/src/semantic_tokens.rs:404 — SemanticTokenVisitor::classify_from_definition has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 3 (6 pts), boolean chains 2 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SemanticTokenVisitor::visit_expr (cognitive 23) crates/ty_ide/src/semantic_tokens.rs:1079 — SemanticTokenVisitor::visit_expr has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 3 (8 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 12). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · InnerIntersectionBuilder · ×3
  • InnerIntersectionBuilder::add_positive (cognitive 76) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2151 — InnerIntersectionBuilder::add_positive has cognitive complexity 76 (threshold 15). Drivers by points: if/else 15 (31 pts), match/switch 9 (26 pts), loops 6 (13 pts), boolean chains 6 (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • InnerIntersectionBuilder::add_negative (cognitive 50) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2407 — InnerIntersectionBuilder::add_negative has cognitive complexity 50 (threshold 15). Drivers by points: if/else 9 (26 pts), loops 6 (12 pts), match/switch 3 (7 pts), boolean chains 5 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • InnerIntersectionBuilder::has_empty_enum_complement (cognitive 22) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2105 — InnerIntersectionBuilder::has_empty_enum_complement has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 2 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DisjointnessChecker · ×3
  • DisjointnessChecker::check_type_pair_impl (cognitive 61) crates/ty_python_semantic/src/types/relation.rs:3763 — DisjointnessChecker::check_type_pair_impl has cognitive complexity 61 (threshold 15). Drivers by points: if/else 22 (37 pts), match/switch 8 (14 pts), boolean chains 10 (nesting depth added 21). Of this number, 59 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DisjointnessChecker::check_typeddict_pair (cognitive 38) crates/ty_python_semantic/src/types/typed_dict.rs:1154 — DisjointnessChecker::check_typeddict_pair has cognitive complexity 38 (threshold 15). Drivers by points: if/else 18 (24 pts), boolean chains 11, match/switch 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • DisjointnessChecker::protocol_member_has_disjoint_type_from_ty (cognitive 18) crates/ty_python_semantic/src/types/protocol_class.rs:3374 — DisjointnessChecker::protocol_member_has_disjoint_type_from_ty has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CallableBinding · ×3
  • CallableBinding::check_types (cognitive 58) crates/ty_python_semantic/src/types/call/bind.rs:3931 — CallableBinding::check_types has cognitive complexity 58 (threshold 15). Drivers by points: if/else 16 (27 pts), loops 7 (15 pts), match/switch 6 (13 pts), boolean chains 3 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • CallableBinding::report_diagnostics (cognitive 53) crates/ty_python_semantic/src/types/call/bind.rs:4813 — CallableBinding::report_diagnostics has cognitive complexity 53 (threshold 15). Drivers by points: if/else 21 (47 pts), loops 1 (3 pts), match/switch 2 (3 pts) (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • CallableBinding::filter_overloads_using_any_or_unknown (cognitive 38) crates/ty_python_semantic/src/types/call/bind.rs:4400 — CallableBinding::filter_overloads_using_any_or_unknown has cognitive complexity 38 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 7 (14 pts), match/switch 1 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MroLookup · ×3
  • MroLookup::instance_member (cognitive 55) crates/ty_python_semantic/src/types/class.rs:3131 — MroLookup::instance_member has cognitive complexity 55 (threshold 15). Drivers by points: if/else 17 (50 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 34). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • MroLookup::class_member (cognitive 24) crates/ty_python_semantic/src/types/class.rs:3021 — MroLookup::class_member has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (17 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • MroLookup::class_body_declaration (cognitive 22) crates/ty_python_semantic/src/types/class.rs:2873 — MroLookup::class_body_declaration has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 4, match/switch 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PlaceLoadResolutionProcedure · ×3
  • PlaceLoadResolutionProcedure::resolve_enclosing_scopes (cognitive 42) crates/ty_python_semantic/src/place_load.rs:636 — PlaceLoadResolutionProcedure::resolve_enclosing_scopes has cognitive complexity 42 (threshold 15). Drivers by points: if/else 13 (33 pts), boolean chains 5, match/switch 1 (3 pts), loops 1 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • PlaceLoadResolutionProcedure::next (cognitive 27) crates/ty_python_semantic/src/place_load.rs:389 — PlaceLoadResolutionProcedure::next has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (22 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • PlaceLoadResolutionProcedure::decide_resolution_path (cognitive 17) crates/ty_python_semantic/src/place_load.rs:594 — PlaceLoadResolutionProcedure::decide_resolution_path has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Server · ×3
  • Server::main_loop (cognitive 42) crates/ty_server/src/server/main_loop.rs:16 — Server::main_loop has cognitive complexity 42 (threshold 15). Drivers by points: if/else 11 (33 pts), match/switch 3 (8 pts), loops 1 (nesting depth added 27). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Server::main_loop (cognitive 30) crates/ruff_server/src/server/main_loop.rs:19 — Server::main_loop has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (24 pts), match/switch 2 (5 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Server::initialize (cognitive 16) crates/ruff_server/src/server/main_loop.rs:138 — Server::initialize has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · mdtest · ×3
  • mdtest::run (cognitive 31) crates/mdtest/src/lib.rs:48 — mdtest::run has cognitive complexity 31 (threshold 15). Drivers by points: loops 4 (13 pts), if/else 4 (7 pts), match/switch 2 (7 pts), boolean chains 4 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mdtest::validate_inline_snapshot (cognitive 24) crates/mdtest/src/lib.rs:357 — mdtest::validate_inline_snapshot has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • mdtest::matcher::match_reveal_type_diagnostic (cognitive 16) crates/mdtest/src/matcher.rs:458 — mdtest::matcher::match_reveal_type_diagnostic has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 5, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ArgumentTypeChecker · ×3
  • ArgumentTypeChecker::evaluate_paramspec_sub_call (cognitive 30) crates/ty_python_semantic/src/types/call/bind.rs:8085 — ArgumentTypeChecker::evaluate_paramspec_sub_call has cognitive complexity 30 (threshold 15). Drivers by points: if/else 11 (21 pts), match/switch 2 (4 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ArgumentTypeChecker::check_argument_type (cognitive 18) crates/ty_python_semantic/src/types/call/bind.rs:7733 — ArgumentTypeChecker::check_argument_type has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 7 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • ArgumentTypeChecker::check_argument_types (cognitive 18) crates/ty_python_semantic/src/types/call/bind.rs:7971 — ArgumentTypeChecker::check_argument_types has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (9 pts), loops 2 (4 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PathAssignments · ×3
  • PathAssignments::discover_constraint (cognitive 22) crates/ty_python_semantic/src/types/constraints/paths.rs:740 — PathAssignments::discover_constraint has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • PathAssignments::visit (cognitive 16) crates/ty_python_semantic/src/types/constraints/paths.rs:302 — PathAssignments::visit has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (11 pts), match/switch 4 (5 pts) (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • PathAssignments::add_assignment (cognitive 16) crates/ty_python_semantic/src/types/constraints/paths.rs:880 — PathAssignments::add_assignment has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 2 (4 pts), loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Parameters · ×3
  • Parameters::with_transformed_parameters (cognitive 22) crates/ty_python_semantic/src/types/signatures.rs:5282 — Parameters::with_transformed_parameters has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (16 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • Parameters::from_normalized (cognitive 21) crates/ty_python_semantic/src/types/signatures.rs:5135 — Parameters::from_normalized has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
  • Parameters::expand_starred_variadic_annotations (cognitive 16) crates/ty_python_semantic/src/types/signatures.rs:5864 — Parameters::expand_starred_variadic_annotations has cognitive complexity 16 (threshold 15). Drivers by points: match/switch 2 (7 pts), if/else 5 (6 pts), boolean chains 2, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ty_site_packages · ×3
  • ty_site_packages::site_packages_directories_from_sys_prefix (cognitive 22) crates/ty_site_packages/src/lib.rs:1669 — ty_site_packages::site_packages_directories_from_sys_prefix has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11 (15 pts), loops 3 (7 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_site_packages::discover_package_dirs (cognitive 18) crates/ty_site_packages/src/lib.rs:1615 — ty_site_packages::discover_package_dirs has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 2 (4 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_site_packages::real_stdlib_directory_from_sys_prefix (cognitive 17) crates/ty_site_packages/src/lib.rs:1818 — ty_site_packages::real_stdlib_directory_from_sys_prefix has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Importer · ×3
  • Importer::import_for_diagnostic (cognitive 21) crates/ty_python_semantic/src/importer.rs:323 — Importer::import_for_diagnostic has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 4, match/switch 2 (4 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Importer::import_symbol (cognitive 18) crates/ruff_linter/src/importer/mod.rs:394 — Importer::import_symbol has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Importer::find (cognitive 16) crates/ty_python_semantic/src/importer.rs:406 — Importer::find has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 1, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D4 · Code Duplication · Edited copy of a member (25 corresponding lines) · ×3
  • Edited copy of a member (25 corresponding lines) crates/ruff_linter/src/rules/flake8_django/rules/all_with_model_form.rs:53 — crates/ruff_linter/src/rules/flake8_django/rules/all_with_model_form.rs:53-98 | crates/ruff_linter/src/rules/flake8_django/rules/exclude_with_model_form.rs:51-82 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (25 corresponding lines) crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_bind_all_interfaces.rs:42 — crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_bind_all_interfaces.rs:42-73 | crates/ruff_linter/src/rules/flake8_bandit/rules/hardcoded_tmp_directory.rs:61-85 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (25 corresponding lines) crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs:67 — crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs:67-94 | crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs:77-101 — These two members are one piece of code written twice and then edited apart: 25 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (85 corresponding lines) · ×3
  • Edited copy of a member (85 corresponding lines) crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:72 — crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:72-156 | crates/ruff_linter/src/rules/flake8_async/rules/long_sleep_not_forever.rs:65-150 — These two members are one piece of code written twice and then edited apart: 85 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (85 corresponding lines) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/builtin_open.rs:71 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/builtin_open.rs:71-193 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_chmod.rs:72-156 — These two members are one piece of code written twice and then edited apart: 85 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (85 corresponding lines) crates/ruff_linter/src/rules/refurb/rules/for_loop_set_mutations.rs:66 — crates/ruff_linter/src/rules/refurb/rules/for_loop_set_mutations.rs:66-152 | crates/ruff_linter/src/rules/refurb/rules/for_loop_writes.rs:144-228 — These two members are one piece of code written twice and then edited apart: 85 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (56 corresponding lines) · ×3
  • Edited copy of a member (56 corresponding lines) crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:35 — crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:35-90 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:97-153 — These two members are one piece of code written twice and then edited apart: 56 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (56 corresponding lines) crates/ruff_python_formatter/src/statement/stmt_for.rs:31 — crates/ruff_python_formatter/src/statement/stmt_for.rs:31-94 | crates/ruff_python_formatter/src/statement/stmt_while.rs:15-70 — These two members are one piece of code written twice and then edited apart: 56 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (56 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:595 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:595-650 | crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:653-708 — These two members are one piece of code written twice and then edited apart: 56 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (41 corresponding lines) · ×3
  • Edited copy of a member (41 corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:151 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:151-191 | crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:199-239 — These two members are one piece of code written twice and then edited apart: 41 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (41 corresponding lines) crates/ruff_server/src/server/api.rs:248 — crates/ruff_server/src/server/api.rs:248-288 | crates/ty_server/src/server/api.rs:445-486 — These two members are one piece of code written twice and then edited apart: 41 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (41 corresponding lines) crates/ruff_python_parser/src/parser/expression.rs:2759 — crates/ruff_python_parser/src/parser/expression.rs:2759-2799 | crates/ruff_python_parser/src/parser/statement.rs:454-494 — These two members are one piece of code written twice and then edited apart: 41 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (36 corresponding lines) · ×3
  • Edited copy of a member (36 corresponding lines) crates/ty_ide/src/docstring/document/google.rs:249 — crates/ty_ide/src/docstring/document/google.rs:249-289 | crates/ty_ide/src/docstring/document/numpy.rs:159-194 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) crates/ty_python_semantic/src/types.rs:8544 — crates/ty_python_semantic/src/types.rs:8544-8579 | crates/ty_python_semantic/src/types/infer/builder.rs:5967-6006 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (36 corresponding lines) crates/ty_server/src/server/api/requests/semantic_tokens.rs:30 — crates/ty_server/src/server/api/requests/semantic_tokens.rs:30-72 | crates/ty_server/src/server/api/requests/semantic_tokens_range.rs:30-65 — These two members are one piece of code written twice and then edited apart: 36 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (23 corresponding lines) · ×3
  • Edited copy of a member (23 corresponding lines) crates/ruff_python_ast/src/nodes.rs:3445 — crates/ruff_python_ast/src/nodes.rs:3445-3467 | crates/ruff_python_ast/src/nodes.rs:3505-3527 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) crates/ty_python_core/src/use_def.rs:1837 — crates/ty_python_core/src/use_def.rs:1837-1861 | crates/ty_python_core/src/use_def.rs:1868-1890 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (23 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:514 — crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:514-536 | crates/ruff_linter/src/rules/flake8_pyi/rules/simple_defaults.rs:539-561 — These two members are one piece of code written twice and then edited apart: 23 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 14+ corresponding lines) · ×3
  • Edited copies of one member (3 members, 14+ corresponding lines) crates/ty_ide/src/goto_declaration.rs:18 — crates/ty_ide/src/goto_declaration.rs:18-32 | crates/ty_ide/src/goto_definition.rs:19-32 | crates/ty_ide/src/goto_type_definition.rs:13-29 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 14+ corresponding lines) crates/ruff_python_ast/src/comparable.rs:293 — crates/ruff_python_ast/src/comparable.rs:293-306 | crates/ruff_python_ast/src/comparable.rs:1551-1564 | crates/ruff_python_ast/src/comparable.rs:1787-1802 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 14+ corresponding lines) crates/ruff_python_ast/src/node.rs:100 — crates/ruff_python_ast/src/node.rs:100-113 | crates/ruff_python_ast/src/visitor.rs:819-833 | crates/ruff_python_ast/src/visitor/transformer.rs:833-847 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×3
  • Duplicated block (17–18 lines × 2) crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs:113 — crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs:113-130 | crates/ruff_linter/src/rules/flake8_pyi/rules/redundant_numeric_union.rs:171-187 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_union_member.rs:113` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (17–18 lines × 2) crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:73 — crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:73-89 | crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:76-93 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:73` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17–18 lines × 2) crates/ty_python_semantic/src/types.rs:12970 — crates/ty_python_semantic/src/types.rs:12970-12987 | crates/ty_python_semantic/src/types/generics.rs:1458-1474 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (16–17 lines × 3) · ×3
  • Duplicated block (16–17 lines × 3) crates/ruff/src/commands/rule.rs:74 — crates/ruff/src/commands/rule.rs:74-90 | crates/ruff_dev/src/generate_docs.rs:141-157 | crates/ruff_server/src/server/api/requests/hover.rs:127-142 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff/src/commands/rule.rs:74` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (16–17 lines × 3) crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:229 — crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:229-244 | crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1061-1077 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:354-370 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs` and `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:229` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:352` calls `to_string` and `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1059` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16–17 lines × 3) crates/ty_python_semantic/src/types/signatures.rs:3616 — crates/ty_python_semantic/src/types/signatures.rs:3616-3631 | crates/ty_python_semantic/src/types/signatures.rs:3803-3818 | crates/ty_python_semantic/src/types/signatures.rs:3976-3992 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3616` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×3
  • Duplicated block (15 lines × 3) crates/ruff_linter/src/fix/codemods.rs:122 — crates/ruff_linter/src/fix/codemods.rs:122-136 | crates/ruff_linter/src/fix/codemods.rs:189-203 | crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_mock_import.rs:112-126 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (15 lines × 3) crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:52 — crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:52-66 | crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:64-78 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:60-74 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs` and `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:52` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 3) crates/ruff_linter/src/rules/refurb/helpers.rs:36 — crates/ruff_linter/src/rules/refurb/helpers.rs:36-50 | crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs:192-206 | crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs:364-378 — before extracting anything, compare `crates/ruff_linter/src/rules/refurb/helpers.rs` and `crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/helpers.rs:36` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–15 lines × 2) · ×3
  • Duplicated block (13–15 lines × 2) crates/ruff_linter/src/noqa.rs:47 — crates/ruff_linter/src/noqa.rs:47-59 | crates/ruff_linter/src/noqa.rs:832-846 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13–15 lines × 2) crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:97 — crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:97-109 | crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:133-147 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:97` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13–15 lines × 2) crates/ty_python_core/src/narrowing_constraints.rs:179 — crates/ty_python_core/src/narrowing_constraints.rs:179-191 | crates/ty_python_core/src/reachability_constraints.rs:331-345 — before extracting anything, compare `crates/ty_python_core/src/narrowing_constraints.rs` and `crates/ty_python_core/src/reachability_constraints.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `a` to `ScopedNarrowingConstraint` in one and `ScopedReachabilityConstraintId` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (11–14 lines × 2) · ×3
  • Duplicated block (11–14 lines × 2) crates/ty_python_semantic/src/types/display.rs:1440 — crates/ty_python_semantic/src/types/display.rs:1440-1453 | crates/ty_python_semantic/src/types/display.rs:2559-2569 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/display.rs:1440` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–14 lines × 2) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:888 — crates/ty_python_semantic/src/types/infer/builder/subscript.rs:888-898 | crates/ty_python_semantic/src/types/infer/builder/subscript.rs:1026-1039 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (11–14 lines × 2) crates/ty_python_semantic/src/types/overrides/attributes.rs:642 — crates/ty_python_semantic/src/types/overrides/attributes.rs:642-655 | crates/ty_python_semantic/src/types/overrides/attributes.rs:1105-1115 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/overrides/attributes.rs:642` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–13 lines × 2) · ×3
  • Duplicated block (11–13 lines × 2) crates/ruff/src/commands/add_noqa.rs:69 — crates/ruff/src/commands/add_noqa.rs:69-79 | crates/ruff/src/commands/check.rs:87-99 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff/src/commands/add_noqa.rs:69` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff/src/commands/add_noqa.rs:68` calls `path` and `crates/ruff/src/commands/check.rs:86` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (11–13 lines × 2) crates/ruff_linter/src/rules/isort/format.rs:17 — crates/ruff_linter/src/rules/isort/format.rs:17-27 | crates/ruff_linter/src/rules/isort/format.rs:205-217 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11–13 lines × 2) crates/ruff_linter/src/rules/pandas_vet/rules/call.rs:171 — crates/ruff_linter/src/rules/pandas_vet/rules/call.rs:171-181 | crates/ruff_linter/src/rules/pandas_vet/rules/subscript.rs:150-162 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pandas_vet/rules/call.rs:171` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×3
  • Duplicated block (12 lines × 3) crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:207 — crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:207-218 | crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:223-234 | crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:239-250 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:207` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 3) crates/ty_python_semantic/src/types/call/bind.rs:3173 — crates/ty_python_semantic/src/types/call/bind.rs:3173-3184 | crates/ty_python_semantic/src/types/call/bind.rs:3206-3217 | crates/ty_python_semantic/src/types/call/bind.rs:3298-3309 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:3173` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (12 lines × 3) crates/ty_python_semantic/src/types/infer.rs:1090 — crates/ty_python_semantic/src/types/infer.rs:1090-1101 | crates/ty_python_semantic/src/types/infer.rs:2101-2112 | crates/ty_python_semantic/src/types/infer.rs:2349-2360 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer.rs:1090` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 3) · ×3
  • Duplicated block (10 lines × 3) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:127 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:127-136 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs:128-137 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_list_comprehension_set.rs:73-82 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs` and `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:127` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 3) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:245 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:245-254 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:280-289 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs:172-181 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:245` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
  • Duplicated block (10 lines × 3) crates/ty_python_semantic/src/types/attribute_write.rs:461 — crates/ty_python_semantic/src/types/attribute_write.rs:461-470 | crates/ty_python_semantic/src/types/attribute_write.rs:1237-1246 | crates/ty_python_semantic/src/types/infer/builder.rs:3253-3262 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ty_python_semantic/src/types/attribute_write.rs:1247` calls `EnumComplement`, `TypeVar` and `crates/ty_python_semantic/src/types/attribute_write.rs:471` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–8 lines × 3) · ×3
  • Duplicated block (7–8 lines × 3) crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:404 — crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:404-410 | crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:344-351 | crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs:363-369 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:404` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–8 lines × 3) crates/ty_python_semantic/src/types/dedicated/django.rs:54 — crates/ty_python_semantic/src/types/dedicated/django.rs:54-60 | crates/ty_python_semantic/src/types/dedicated/pydantic.rs:266-273 | crates/ty_python_semantic/src/types/dedicated/pydantic.rs:841-848 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/dedicated/django.rs:54` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `db` to `&'db dyn Db` in one and `&dyn Db` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (7–8 lines × 3) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2664 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2664-2670 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2710-2717 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2736-2743 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2664` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (6 lines × 4) · ×3
  • Duplicated block (6 lines × 4) crates/ty_python_semantic/src/types/class/typed_dict.rs:237 — crates/ty_python_semantic/src/types/class/typed_dict.rs:237-242 | crates/ty_python_semantic/src/types/class/typed_dict.rs:296-301 | crates/ty_python_semantic/src/types/class/typed_dict.rs:406-412 | crates/ty_python_semantic/src/types/class/typed_dict.rs:678-683 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/typed_dict.rs:237` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) crates/ty_python_semantic/src/types/constraints/sequents.rs:978 — crates/ty_python_semantic/src/types/constraints/sequents.rs:978-983 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1016-1021 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1085-1090 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1111-1116 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:978` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (6 lines × 4) crates/ty_python_semantic/src/types/infer/builder.rs:709 — crates/ty_python_semantic/src/types/infer/builder.rs:709-714 | crates/ty_python_semantic/src/types/infer/builder.rs:766-771 | crates/ty_python_semantic/src/types/infer/builder.rs:824-829 | crates/ty_python_semantic/src/types/infer/builder.rs:905-910 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ty_python_semantic/src/types/infer/builder.rs:715` calls `extend`, `iter`, `copied` and `crates/ty_python_semantic/src/types/infer/builder.rs:911` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×3
  • Duplicated block (6 lines × 3) crates/ty_python_semantic/src/types/display.rs:1230 — crates/ty_python_semantic/src/types/display.rs:1230-1235 | crates/ty_python_semantic/src/types/display.rs:1249-1254 | crates/ty_python_semantic/src/types/display.rs:1792-1797 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
  • Duplicated block (6 lines × 3) crates/ruff_linter/src/settings/types.rs:117 — crates/ruff_linter/src/settings/types.rs:117-122 | crates/ruff_python_formatter/src/options.rs:368-373 | crates/ruff_python_formatter/src/options.rs:419-424 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Note first that the copies are not typed on the same thing: the declarations holding them bind `f` to `&mut Formatter<'_>` in one and `&mut fmt::Formatter<'_>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (6 lines × 3) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2240 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2240-2245 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2252-2257 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2285-2290 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2240` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D1 · Cyclomatic Complexity · DisjointnessChecker · ×2
  • DisjointnessChecker::check_type_pair_impl (cyclomatic 124) crates/ty_python_semantic/src/types/relation.rs:3763 — DisjointnessChecker::check_type_pair_impl has cyclomatic complexity 124 (threshold 15). Of this number, 123 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
  • DisjointnessChecker::check_typeddict_pair (cyclomatic 34) crates/ty_python_semantic/src/types/typed_dict.rs:1154 — DisjointnessChecker::check_typeddict_pair has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SpecializationBuilder · ×2
  • SpecializationBuilder::infer_map_inner (cyclomatic 122) crates/ty_python_semantic/src/types/generics.rs:4147 — SpecializationBuilder::infer_map_inner has cyclomatic complexity 122 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SpecializationBuilder::common_typed_dict_protocol_constraints (cyclomatic 20) crates/ty_python_semantic/src/types/generics.rs:3705 — SpecializationBuilder::common_typed_dict_protocol_constraints has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 7 of the 20 points are its own statements and the rest belongs to 2 function items inside it that branch (collect_typed_dicts, is_string_keyed_mapping). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · UnionBuilder · ×2
  • UnionBuilder::add_in_place_impl (cyclomatic 74) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:812 — UnionBuilder::add_in_place_impl has cyclomatic complexity 74 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • UnionBuilder::push_type (cyclomatic 46) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:1198 — UnionBuilder::push_type has cyclomatic complexity 46 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · GotoTarget · ×2
  • GotoTarget::from_covering_node (cyclomatic 72) crates/ty_ide/src/goto.rs:976 — GotoTarget::from_covering_node has cyclomatic complexity 72 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • GotoTarget::definitions (cyclomatic 27) crates/ty_ide/src/goto.rs:649 — GotoTarget::definitions has cyclomatic complexity 27 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · Lexer · ×2
  • Lexer::consume_ascii_character (cyclomatic 70) crates/ruff_python_parser/src/lexer.rs:398 — Lexer::consume_ascii_character has cyclomatic complexity 70 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • Lexer::lex_interpolated_string_middle_or_end (cyclomatic 25) crates/ruff_python_parser/src/lexer.rs:745 — Lexer::lex_interpolated_string_middle_or_end has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · InnerIntersectionBuilder · ×2
  • InnerIntersectionBuilder::add_positive (cyclomatic 51) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2151 — InnerIntersectionBuilder::add_positive has cyclomatic complexity 51 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
  • InnerIntersectionBuilder::add_negative (cyclomatic 37) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:2407 — InnerIntersectionBuilder::add_negative has cyclomatic complexity 37 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · SourceMap · ×2
  • SourceMap::annotated_lines (cyclomatic 29) crates/ruff_annotate_snippets/src/renderer/source_map.rs:171 — SourceMap::annotated_lines has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • SourceMap::splice_lines (cyclomatic 28) crates/ruff_annotate_snippets/src/renderer/source_map.rs:406 — SourceMap::splice_lines has cyclomatic complexity 28 (threshold 15). Of this number, 23 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BlankLinesChecker · ×2
  • BlankLinesChecker::check_line (cyclomatic 28) crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs:834 — BlankLinesChecker::check_line has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • BlankLinesChecker::check_lines (cyclomatic 20) crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs:732 — BlankLinesChecker::check_lines has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SemanticModel · ×2
  • SemanticModel::resolve_load (cyclomatic 28) crates/ruff_python_semantic/src/model.rs:485 — SemanticModel::resolve_load has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: SemanticModel::add_module (cyclomatic 31) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
  • SemanticModel::simulate_runtime_load_at_location_in_scope (cyclomatic 24) crates/ruff_python_semantic/src/model.rs:975 — SemanticModel::simulate_runtime_load_at_location_in_scope has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: SemanticModel::add_module (cyclomatic 31) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ruff_dev · ×2
  • ruff_dev::generate_ty_cli_reference::generate_command (cyclomatic 25) crates/ruff_dev/src/generate_ty_cli_reference.rs:94 — ruff_dev::generate_ty_cli_reference::generate_command has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_dev::generate_rules_table::generate_table (cyclomatic 16) crates/ruff_dev/src/generate_rules_table.rs:31 — ruff_dev::generate_rules_table::generate_table has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PlaceLoadResolutionProcedure · ×2
  • PlaceLoadResolutionProcedure::resolve_enclosing_scopes (cyclomatic 23) crates/ty_python_semantic/src/place_load.rs:636 — PlaceLoadResolutionProcedure::resolve_enclosing_scopes has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • PlaceLoadResolutionProcedure::next (cyclomatic 21) crates/ty_python_semantic/src/place_load.rs:389 — PlaceLoadResolutionProcedure::next has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ArgumentMatcher · ×2
  • ArgumentMatcher::match_variadic (cyclomatic 23) crates/ty_python_semantic/src/types/call/bind.rs:5343 — ArgumentMatcher::match_variadic has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ArgumentMatcher::match_unpacked_variadic (cyclomatic 19) crates/ty_python_semantic/src/types/call/bind.rs:5620 — ArgumentMatcher::match_unpacked_variadic has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CandidateSolutions · ×2
  • CandidateSolutions::compute_simple_bound_conjunction (cyclomatic 23) crates/ty_python_semantic/src/types/constraints.rs:3887 — CandidateSolutions::compute_simple_bound_conjunction has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • CandidateSolutions::promote_for_argument_context (cyclomatic 16) crates/ty_python_semantic/src/types/constraints.rs:4063 — CandidateSolutions::promote_for_argument_context has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MroLookup · ×2
  • MroLookup::instance_member (cyclomatic 21) crates/ty_python_semantic/src/types/class.rs:3131 — MroLookup::instance_member has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • MroLookup::class_member (cyclomatic 18) crates/ty_python_semantic/src/types/class.rs:3021 — MroLookup::class_member has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ClauseHeader · ×2
  • ClauseHeader::visit (cyclomatic 19) crates/ruff_python_formatter/src/statement/clause.rs:108 — ClauseHeader::visit has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ClauseHeader::first_keyword_range (cyclomatic 18) crates/ruff_python_formatter/src/statement/clause.rs:247 — ClauseHeader::first_keyword_range has cyclomatic complexity 18 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · UnicodeEscape · ×2
  • UnicodeEscape::normalize (cyclomatic 19) crates/ruff_python_formatter/src/string/normalize.rs:822 — UnicodeEscape::normalize has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • UnicodeEscape::display_escapes (cyclomatic 17) crates/ruff_python_literal/src/escape.rs:243 — UnicodeEscape::display_escapes has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ruff_python_semantic · ×2
  • ruff_python_semantic::analyze::class::any_member_declaration::any_stmt_in_body (cyclomatic 19) crates/ruff_python_semantic/src/analyze/class.rs:171 — ruff_python_semantic::analyze::class::any_member_declaration::any_stmt_in_body has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ruff_python_semantic::analyze::terminal::sometimes_breaks (cyclomatic 16) crates/ruff_python_semantic/src/analyze/terminal.rs:290 — ruff_python_semantic::analyze::terminal::sometimes_breaks has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Terminal::branch (cyclomatic 24) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ty_module_resolver · ×2
  • ty_module_resolver::module_glob::glob_to_regex (cyclomatic 17) crates/ty_module_resolver/src/module_glob.rs:267 — ty_module_resolver::module_glob::glob_to_regex has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ty_module_resolver::resolve::is_pkgutil_extend_path (cyclomatic 16) crates/ty_module_resolver/src/resolve.rs:1681 — ty_module_resolver::resolve::is_pkgutil_extend_path has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ArgumentTypeChecker · ×2
  • ArgumentTypeChecker::evaluate_paramspec_sub_call (cyclomatic 17) crates/ty_python_semantic/src/types/call/bind.rs:8085 — ArgumentTypeChecker::evaluate_paramspec_sub_call has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
  • ArgumentTypeChecker::check_argument_type (cyclomatic 16) crates/ty_python_semantic/src/types/call/bind.rs:7733 — ArgumentTypeChecker::check_argument_type has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D17 · Explicit Debt · XxxComment · ×2
  • XxxComment crates/ty_python_core/src/symbol.rs:107 — /// XXX: There's a fourth case that we don't (can't) handle here. A variable that's bound or — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • XxxComment crates/ruff_linter/src/rules/flake8_fixme/rules/todos.rs:75 — /// return distance / time # XXX: Raises ZeroDivisionError for time = 0. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `// REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D2 · Cognitive Complexity · UnionBuilder · ×2
  • UnionBuilder::add_in_place_impl (cognitive 182) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:812 — UnionBuilder::add_in_place_impl has cognitive complexity 182 (threshold 15). Drivers by points: if/else 37 (131 pts), match/switch 8 (26 pts), loops 5 (14 pts), boolean chains 11 (nesting depth added 121). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • UnionBuilder::push_type (cognitive 86) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:1198 — UnionBuilder::push_type has cognitive complexity 86 (threshold 15). Drivers by points: if/else 25 (53 pts), loops 6 (18 pts), boolean chains 13, match/switch 1 (2 pts) (nesting depth added 41). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Mro · ×2
  • Mro::ancestors_of_static_class (cognitive 64) crates/ty_python_semantic/src/types/mro.rs:55 — Mro::ancestors_of_static_class has cognitive complexity 64 (threshold 15). Drivers by points: if/else 22 (44 pts), match/switch 4 (10 pts), loops 4 (8 pts), boolean chains 2 (nesting depth added 32). Of this number, 62 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Mro::of_dynamic_class (cognitive 20) crates/ty_python_semantic/src/types/mro.rs:360 — Mro::of_dynamic_class has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 3, match/switch 1 (2 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FitsMeasurer · ×2
  • FitsMeasurer::fits_element (cognitive 61) crates/ruff_formatter/src/printer/mod.rs:1166 — FitsMeasurer::fits_element has cognitive complexity 61 (threshold 15). Drivers by points: if/else 15 (33 pts), match/switch 12 (27 pts), boolean chains 1 (nesting depth added 33). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • FitsMeasurer::fits_text (cognitive 30) crates/ruff_formatter/src/printer/mod.rs:1485 — FitsMeasurer::fits_text has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (16 pts), match/switch 3 (10 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 19). Of this number, 29 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SourceMap · ×2
  • SourceMap::splice_lines (cognitive 59) crates/ruff_annotate_snippets/src/renderer/source_map.rs:406 — SourceMap::splice_lines has cognitive complexity 59 (threshold 15). Drivers by points: if/else 22 (36 pts), loops 7 (13 pts), match/switch 4 (10 pts) (nesting depth added 26). Of this number, 51 points are the body's own statements and 8 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • SourceMap::annotated_lines (cognitive 49) crates/ruff_annotate_snippets/src/renderer/source_map.rs:171 — SourceMap::annotated_lines has cognitive complexity 49 (threshold 15). Drivers by points: if/else 16 (28 pts), loops 8 (13 pts), boolean chains 8 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ImportReplacer · ×2
  • ImportReplacer::without_renames (cognitive 56) crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs:491 — ImportReplacer::without_renames has cognitive complexity 56 (threshold 15). Drivers by points: if/else 34 (55 pts), match/switch 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ImportReplacer::with_renames (cognitive 19) crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs:459 — ImportReplacer::with_renames has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 1 (3 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BlankLinesChecker · ×2
  • BlankLinesChecker::check_line (cognitive 55) crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs:834 — BlankLinesChecker::check_line has cognitive complexity 55 (threshold 15). Drivers by points: if/else 31 (50 pts), boolean chains 5 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • BlankLinesChecker::check_lines (cognitive 36) crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs:732 — BlankLinesChecker::check_lines has cognitive complexity 36 (threshold 15). Drivers by points: if/else 13 (33 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UnicodeEscape · ×2
  • UnicodeEscape::normalize (cognitive 52) crates/ruff_python_formatter/src/string/normalize.rs:822 — UnicodeEscape::normalize has cognitive complexity 52 (threshold 15). Drivers by points: if/else 14 (40 pts), match/switch 3 (8 pts), loops 2 (4 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • UnicodeEscape::display_escapes (cognitive 30) crates/ruff_python_literal/src/escape.rs:243 — UnicodeEscape::display_escapes has cognitive complexity 30 (threshold 15). Drivers by points: if/else 6 (17 pts), boolean chains 7, loops 3 (6 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatImplicitConcatenatedStringFlat · ×2
  • FormatImplicitConcatenatedStringFlat::new::merge_flags (cognitive 51) crates/ruff_python_formatter/src/string/implicit.rs:138 — FormatImplicitConcatenatedStringFlat::new::merge_flags has cognitive complexity 51 (threshold 15). Drivers by points: if/else 17 (42 pts), loops 2 (4 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • FormatImplicitConcatenatedStringFlat::fmt (cognitive 22) crates/ruff_python_formatter/src/string/implicit.rs:289 — FormatImplicitConcatenatedStringFlat::fmt has cognitive complexity 22 (threshold 15). Drivers by points: if/else 4 (8 pts), loops 3 (6 pts), match/switch 2 (6 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Suppressions · ×2
  • Suppressions::check_suppressions (cognitive 39) crates/ruff_linter/src/suppression.rs:472 — Suppressions::check_suppressions has cognitive complexity 39 (threshold 15). Drivers by points: if/else 18 (32 pts), loops 3 (5 pts), boolean chains 2 (nesting depth added 16). Of this number, 30 points are the body's own statements and 9 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Suppressions::check_rule_codes (cognitive 28) crates/ruff_linter/src/suppression.rs:402 — Suppressions::check_rule_codes has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (22 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ArgumentMatcher · ×2
  • ArgumentMatcher::match_variadic (cognitive 37) crates/ty_python_semantic/src/types/call/bind.rs:5343 — ArgumentMatcher::match_variadic has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (23 pts), loops 5 (9 pts), boolean chains 5 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ArgumentMatcher::match_unpacked_variadic (cognitive 30) crates/ty_python_semantic/src/types/call/bind.rs:5620 — ArgumentMatcher::match_unpacked_variadic has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (22 pts), boolean chains 4, loops 3 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CandidateSolutions · ×2
  • CandidateSolutions::compute_simple_bound_conjunction (cognitive 35) crates/ty_python_semantic/src/types/constraints.rs:3887 — CandidateSolutions::compute_simple_bound_conjunction has cognitive complexity 35 (threshold 15). Drivers by points: if/else 7 (19 pts), match/switch 4 (9 pts), loops 4, boolean chains 3 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • CandidateSolutions::promote_for_argument_context (cognitive 24) crates/ty_python_semantic/src/types/constraints.rs:4063 — CandidateSolutions::promote_for_argument_context has cognitive complexity 24 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 4 (6 pts), boolean chains 3, match/switch 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_markdown · ×2
  • ruff_markdown::format_code_blocks (cognitive 34) crates/ruff_markdown/src/lib.rs:64 — ruff_markdown::format_code_blocks has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (21 pts), match/switch 2 (7 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_markdown::format_pycon_block (cognitive 31) crates/ruff_markdown/src/lib.rs:150 — ruff_markdown::format_pycon_block has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 3 (8 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ProtocolClass · ×2
  • ProtocolClass::for_each_member_candidate (cognitive 33) crates/ty_python_semantic/src/types/protocol_class.rs:147 — ProtocolClass::for_each_member_candidate has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (22 pts), loops 4 (7 pts), boolean chains 4 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ProtocolClass::validate_type_parameter_variance (cognitive 20) crates/ty_python_semantic/src/types/protocol_class.rs:340 — ProtocolClass::validate_type_parameter_variance has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · GroupNameFinder · ×2
  • GroupNameFinder::visit_stmt (cognitive 28) crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs:120 — GroupNameFinder::visit_stmt has cognitive complexity 28 (threshold 15). Drivers by points: if/else 12 (23 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • GroupNameFinder::visit_expr (cognitive 23) crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs:253 — GroupNameFinder::visit_expr has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (17 pts), loops 2 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_server · ×2
  • ruff_server::lint::to_lsp_diagnostic (cognitive 27) crates/ruff_server/src/lint.rs:371 — ruff_server::lint::to_lsp_diagnostic has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (20 pts), loops 2 (3 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ruff_server::lint::check (cognitive 18) crates/ruff_server/src/lint.rs:76 — ruff_server::lint::check has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (12 pts), loops 2 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LocalReferencesFinder · ×2
  • LocalReferencesFinder::enter_node (cognitive 23) crates/ty_ide/src/references.rs:606 — LocalReferencesFinder::enter_node has cognitive complexity 23 (threshold 15). Drivers by points: if/else 9 (18 pts), loops 2 (4 pts), match/switch 1 (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • LocalReferencesFinder::check_covering_node (cognitive 16) crates/ty_ide/src/references.rs:782 — LocalReferencesFinder::check_covering_node has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (9 pts), boolean chains 3, loops 1 (2 pts), match/switch 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Binding · ×2
  • Binding::argument_type_context (cognitive 23) crates/ty_python_semantic/src/types/call/bind.rs:8996 — Binding::argument_type_context has cognitive complexity 23 (threshold 15). Drivers by points: if/else 11 (16 pts), boolean chains 7 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • Binding::partial_application (cognitive 23) crates/ty_python_semantic/src/types/call/bind.rs:9662 — Binding::partial_application has cognitive complexity 23 (threshold 15). Drivers by points: if/else 3 (12 pts), loops 3 (7 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ty_server · ×2
  • ty_server::server::api::semantic_tokens::generate_semantic_tokens (cognitive 23) crates/ty_server/src/server/api/semantic_tokens.rs:12 — ty_server::server::api::semantic_tokens::generate_semantic_tokens has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 3 (7 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • ty_server::server::api::diagnostics::to_lsp_diagnostic (cognitive 18) crates/ty_server/src/server/api/diagnostics.rs:449 — ty_server::server::api::diagnostics::to_lsp_diagnostic has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (12 pts), loops 2 (3 pts), match/switch 3 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RecoveryContextKind · ×2
  • RecoveryContextKind::list_terminator_kind (cognitive 22) crates/ruff_python_parser/src/parser/mod.rs:1293 — RecoveryContextKind::list_terminator_kind has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (13 pts), match/switch 4 (8 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • RecoveryContextKind::create_error (cognitive 17) crates/ruff_python_parser/src/parser/mod.rs:1516 — RecoveryContextKind::create_error has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 3 (5 pts) (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FoldingRangeVisitor · ×2
  • FoldingRangeVisitor::add_import_ranges (cognitive 22) crates/ty_ide/src/folding_range.rs:265 — FoldingRangeVisitor::add_import_ranges has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (21 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • FoldingRangeVisitor::add_comment_ranges (cognitive 22) crates/ty_ide/src/folding_range.rs:347 — FoldingRangeVisitor::add_comment_ranges has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConstructorBinding · ×2
  • ConstructorBinding::instance_return_specialization (cognitive 22) crates/ty_python_semantic/src/types/call/bind/constructor.rs:382 — ConstructorBinding::instance_return_specialization has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (12 pts), loops 3 (6 pts), match/switch 1 (3 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
  • ConstructorBinding::analyze_overload_returns (cognitive 16) crates/ty_python_semantic/src/types/call/bind/constructor.rs:575 — ConstructorBinding::analyze_overload_returns has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), match/switch 1 (3 pts), loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IntersectionBuilder · ×2
  • IntersectionBuilder::add_positive_impl (cognitive 19) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:1707 — IntersectionBuilder::add_positive_impl has cognitive complexity 19 (threshold 15). Drivers by points: loops 5 (11 pts), if/else 3 (5 pts), match/switch 2, boolean chains 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
  • IntersectionBuilder::add_negative_impl (cognitive 19) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:1799 — IntersectionBuilder::add_negative_impl has cognitive complexity 19 (threshold 15). Drivers by points: loops 5 (11 pts), boolean chains 4, if/else 1 (2 pts), match/switch 2 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · UnionTypeInstance · ×2
  • UnionTypeInstance::value_expression_types (cognitive 18) crates/ty_python_semantic/src/types/union_type_instance.rs:381 — UnionTypeInstance::value_expression_types has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 1 (3 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
  • UnionTypeInstance::recursive_type_normalized_impl (cognitive 18) crates/ty_python_semantic/src/types/union_type_instance.rs:435 — UnionTypeInstance::recursive_type_normalized_impl has cognitive complexity 18 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 4 (5 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 8). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · PatternSuccessAnalyzer · ×2
  • PatternSuccessAnalyzer::class_pattern_arguments_for_arm (cognitive 17) crates/ty_python_semantic/src/types/narrow.rs:2560 — PatternSuccessAnalyzer::class_pattern_arguments_for_arm has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (11 pts), boolean chains 5, match/switch 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
  • PatternSuccessAnalyzer::analyze_pattern_subject_arms (cognitive 16) crates/ty_python_semantic/src/types/narrow.rs:3345 — PatternSuccessAnalyzer::analyze_pattern_subject_arms has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (11 pts), loops 3 (5 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D3 · God Classes · TooManyFunctions · ×2
  • TooManyFunctions: ruff_linter::preview crates/ruff_linter/src/preview.rs:13 — TooManyFunctions — 68 free functions. The bar is 30 free functions; this is 38 over it, 2.27× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyFunctions: ruff_python_ast::visitor::source_order crates/ruff_python_ast/src/visitor/source_order.rs:188 — TooManyFunctions — 34 free functions. The bar is 30 free functions; this is 4 over it, 1.13× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D30 · Dependency Vulnerabilities · Medium advisory (unmaintained) · ×2
  • REDACTED
  • REDACTED
D31 · IaC & Container Security · Medium IaC · ×2
  • REDACTED
  • REDACTED
D35 · Change Coupling · Change-coupling hub · ×2
  • Change-coupling hub: re_exports.rs → dunder_all.rs, class.rs, infer.rs crates/ty_python_core/src/re_exports.rs — `crates/ty_python_core/src/re_exports.rs` changes together with 3 other files — `crates/ty_python_semantic/src/dunder_all.rs`, `crates/ty_python_semantic/src/types/class.rs`, `crates/ty_python_semantic/src/types/infer.rs` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
  • Change-coupling hub: requests.rs → lib.rs, capabilities.rs, server.rs crates/ty_server/src/server/api/requests.rs — `crates/ty_server/src/server/api/requests.rs` changes together with 3 other files — `crates/ty_ide/src/lib.rs`, `crates/ty_server/src/capabilities.rs`, `crates/ty_server/src/server.rs` — none of which declares a dependency on it: one file is the hub of 3 separate couplings, not 3 unrelated pairs. Read the hub first: if the others each duplicate a part of what it does, the shared concern belongs in ONE unit and extracting it clears every edge at once; if the hub is a registry, dispatcher or barrel that must name each of them, the coupling is structural and the question is whether that list can be discovered instead of enumerated. Fixing the hub is one change; breaking the couplings one pair at a time is 3.
D4 · Code Duplication · Near-duplicate member pair (58 shared lines) · ×2
  • Near-duplicate member pair (58 shared lines) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:71 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:71-161 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs:72-166 — These two members are variants of one another: 58 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
  • Near-duplicate member pair (58 shared lines) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:522 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:522-638 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:806-893 — These two members are variants of one another: 58 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (5 members, 50+ identical tokens) crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:110 — crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:110-273 | crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:112-1210 | crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:655-1106 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs:128-336 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:190-396 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) crates/ty_python_semantic/src/types/infer/builder.rs:654 — crates/ty_python_semantic/src/types/infer/builder.rs:654-733 | crates/ty_python_semantic/src/types/infer/builder.rs:735-776 | crates/ty_python_semantic/src/types/infer/builder.rs:812-844 | crates/ty_python_semantic/src/types/infer/builder.rs:846-895 | crates/ty_python_semantic/src/types/infer/builder.rs:897-925 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Edited copy of a member (46 corresponding lines) · ×2
  • Edited copy of a member (46 corresponding lines) crates/ty_python_semantic/src/types/class/typed_dict.rs:273 — crates/ty_python_semantic/src/types/class/typed_dict.rs:273-324 | crates/ty_python_semantic/src/types/class/typed_dict.rs:332-377 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (46 corresponding lines) crates/ruff_server/src/logging.rs:17 — crates/ruff_server/src/logging.rs:17-69 | crates/ty_server/src/logging.rs:19-64 — These two members are one piece of code written twice and then edited apart: 46 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (51 corresponding lines) · ×2
  • Edited copy of a member (51 corresponding lines) crates/ty_python_core/src/reachability_constraints.rs:456 — crates/ty_python_core/src/reachability_constraints.rs:456-506 | crates/ty_python_core/src/reachability_constraints.rs:537-587 — These two members are one piece of code written twice and then edited apart: 51 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (51 corresponding lines) crates/ruff_dev/src/generate_options.rs:23 — crates/ruff_dev/src/generate_options.rs:23-73 | crates/ruff_dev/src/generate_ty_options.rs:66-116 — These two members are one piece of code written twice and then edited apart: 51 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (45 corresponding lines) · ×2
  • Edited copy of a member (45 corresponding lines) crates/ruff_server/src/server/api.rs:100 — crates/ruff_server/src/server/api.rs:100-144 | crates/ty_server/src/server/api.rs:189-242 — These two members are one piece of code written twice and then edited apart: 45 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (45 corresponding lines) crates/ruff_python_literal/src/escape.rs:169 — crates/ruff_python_literal/src/escape.rs:169-213 | crates/ruff_python_literal/src/escape.rs:517-561 — These two members are one piece of code written twice and then edited apart: 45 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (44 corresponding lines) · ×2
  • Edited copy of a member (44 corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:2512 — crates/ty_python_semantic/src/types/diagnostic.rs:2512-2561 | crates/ty_python_semantic/src/types/diagnostic.rs:2651-2694 — These two members are one piece of code written twice and then edited apart: 44 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (44 corresponding lines) crates/ruff_server/src/edit/text_document.rs:89 — crates/ruff_server/src/edit/text_document.rs:89-132 | crates/ty_server/src/document/text_document.rs:98-141 — These two members are one piece of code written twice and then edited apart: 44 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (31 corresponding lines) · ×2
  • Edited copy of a member (31 corresponding lines) crates/ruff_server/src/lib.rs:50 — crates/ruff_server/src/lib.rs:50-80 | crates/ty_server/src/lib.rs:29-74 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (31 corresponding lines) crates/ruff_python_formatter/src/expression/expr_generator.rs:37 — crates/ruff_python_formatter/src/expression/expr_generator.rs:37-78 | crates/ruff_python_formatter/src/expression/expr_set_comp.rs:12-42 — These two members are one piece of code written twice and then edited apart: 31 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 31+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 31+ corresponding lines) crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:380 — crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:380-418 | crates/ruff_linter/src/rules/refurb/helpers.rs:15-50 | crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs:176-206 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 31 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 31+ corresponding lines) crates/ruff_dev/src/generate_json_schema.rs:18 — crates/ruff_dev/src/generate_json_schema.rs:18-51 | crates/ruff_dev/src/generate_ty_rules.rs:28-58 | crates/ruff_dev/src/generate_ty_schema.rs:18-51 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 31 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 23+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 23+ corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:1637 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1637-1661 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1863-1885 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1982-2008 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 23 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 23+ corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:8862 — crates/ty_python_semantic/src/types/infer/builder.rs:8862-8884 | crates/ty_python_semantic/src/types/infer/builder.rs:8890-8912 | crates/ty_python_semantic/src/types/infer/builder.rs:8918-8948 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 23 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (33 corresponding lines) · ×2
  • Edited copy of a member (33 corresponding lines) crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:77 — crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:77-109 | crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:112-147 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (33 corresponding lines) crates/ty_ide/src/symbols.rs:1055 — crates/ty_ide/src/symbols.rs:1055-1087 | crates/ty_python_semantic/src/dunder_all.rs:123-158 — These two members are one piece of code written twice and then edited apart: 33 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (27 corresponding lines) · ×2
  • Edited copy of a member (27 corresponding lines) crates/ty_python_semantic/src/types/class.rs:2200 — crates/ty_python_semantic/src/types/class.rs:2200-2231 | crates/ty_python_semantic/src/types/class.rs:2270-2296 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
  • Edited copy of a member (27 corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:1029 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1029-1055 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1125-1152 — These two members are one piece of code written twice and then edited apart: 27 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 19+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 19+ corresponding lines) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:172 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:172-191 | crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:313-331 | crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:334-352 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 19 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 19+ corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:3458 — crates/ty_python_semantic/src/types/diagnostic.rs:3458-3490 | crates/ty_python_semantic/src/types/diagnostic.rs:3496-3514 | crates/ty_python_semantic/src/types/diagnostic.rs:3516-3539 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 19 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 16+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 16+ corresponding lines) crates/ruff_python_formatter/src/expression/expr_bytes_literal.rs:15 — crates/ruff_python_formatter/src/expression/expr_bytes_literal.rs:15-30 | crates/ruff_python_formatter/src/expression/expr_f_string.rs:17-32 | crates/ruff_python_formatter/src/expression/expr_t_string.rs:17-32 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 16 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 16+ corresponding lines) crates/ruff_linter/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs:68 — crates/ruff_linter/src/rules/flake8_gettext/rules/f_string_in_gettext_func_call.rs:68-83 | crates/ruff_linter/src/rules/flake8_gettext/rules/format_in_gettext_func_call.rs:69-84 | crates/ruff_linter/src/rules/flake8_gettext/rules/printf_in_gettext_func_call.rs:67-82 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 16 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 25+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 25+ corresponding lines) crates/ruff_python_parser/src/parser/statement.rs:974 — crates/ruff_python_parser/src/parser/statement.rs:974-1004 | crates/ruff_python_parser/src/parser/statement.rs:1013-1050 | crates/ruff_python_parser/src/parser/statement.rs:3636-3660 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 25 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 25+ corresponding lines) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_remove.rs:67 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_remove.rs:67-91 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_rmdir.rs:67-91 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_unlink.rs:67-91 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 25 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 8+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 8+ corresponding lines) crates/ty_python_semantic/src/types/narrow.rs:139 — crates/ty_python_semantic/src/types/narrow.rs:139-146 | crates/ty_python_semantic/src/types/narrow.rs:185-192 | crates/ty_python_semantic/src/types/narrow.rs:203-216 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 8+ corresponding lines) crates/ruff_linter/src/rules/ruff/rules/test_rules.rs:120 — crates/ruff_linter/src/rules/ruff/rules/test_rules.rs:120-127 | crates/ruff_linter/src/rules/ruff/rules/test_rules.rs:159-169 | crates/ruff_linter/src/rules/ruff/rules/test_rules.rs:201-214 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 8 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 9+ corresponding lines) · ×2
  • Edited copies of one member (4 members, 9+ corresponding lines) crates/ruff_diagnostics/src/fix.rs:68 — crates/ruff_diagnostics/src/fix.rs:68-76 | crates/ruff_diagnostics/src/fix.rs:88-96 | crates/ruff_diagnostics/src/fix.rs:109-117 | crates/ruff_diagnostics/src/fix.rs:133-141 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 9 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
  • Edited copies of one member (4 members, 9+ corresponding lines) crates/ty_python_core/src/use_def.rs:512 — crates/ty_python_core/src/use_def.rs:512-520 | crates/ty_python_core/src/use_def.rs:541-549 | crates/ty_python_core/src/use_def.rs:580-588 | crates/ty_python_core/src/use_def.rs:607-615 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 9 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 15+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 15+ corresponding lines) crates/ty_python_semantic/src/types/constraints/variables.rs:824 — crates/ty_python_semantic/src/types/constraints/variables.rs:824-838 | crates/ty_python_semantic/src/types/constraints/variables.rs:943-957 | crates/ty_python_semantic/src/types/constraints/variables.rs:1200-1214 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 15+ corresponding lines) crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs:73 — crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_today.rs:73-87 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcfromtimestamp.rs:70-87 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_utcnow.rs:69-86 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 6+ corresponding lines) · ×2
  • Edited copies of one member (3 members, 6+ corresponding lines) crates/ty_python_semantic/src/types/constraints.rs:481 — crates/ty_python_semantic/src/types/constraints.rs:481-486 | crates/ty_python_semantic/src/types/constraints.rs:496-501 | crates/ty_python_semantic/src/types/constraints.rs:511-521 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
  • Edited copies of one member (3 members, 6+ corresponding lines) crates/ty_python_semantic/src/types/dedicated/django.rs:20 — crates/ty_python_semantic/src/types/dedicated/django.rs:20-26 | crates/ty_python_semantic/src/types/dedicated/pydantic.rs:619-624 | crates/ty_python_semantic/src/types/dedicated/pytest/collection.rs:436-441 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 6 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (45 lines × 2) · ×2
  • Duplicated block (45 lines × 2) crates/ruff_server/src/server/schedule/thread/priority.rs:179 — crates/ruff_server/src/server/schedule/thread/priority.rs:179-223 | crates/ty_server/src/server/schedule/thread/priority.rs:179-223 — before extracting anything, compare `crates/ruff_server/src/server/schedule/thread/priority.rs` and `crates/ty_server/src/server/schedule/thread/priority.rs` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
  • Duplicated block (45 lines × 2) crates/ruff_server/src/server/schedule/thread/priority.rs:226 — crates/ruff_server/src/server/schedule/thread/priority.rs:226-270 | crates/ty_server/src/server/schedule/thread/priority.rs:226-270 — before extracting anything, compare `crates/ruff_server/src/server/schedule/thread/priority.rs` and `crates/ty_server/src/server/schedule/thread/priority.rs` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (36 lines × 2) · ×2
  • Duplicated block (36 lines × 2) crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:290 — crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:290-325 | crates/ruff_python_formatter/src/range.rs:670-705 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_formatter/src/range.rs:706` calls `FString`, `StringLiteral`, `TString` and `crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:326` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (36 lines × 2) crates/ruff_dev/src/generate_options.rs:38 — crates/ruff_dev/src/generate_options.rs:38-73 | crates/ruff_dev/src/generate_ty_options.rs:81-116 — before extracting anything, compare `crates/ruff_dev/src/generate_options.rs` and `crates/ruff_dev/src/generate_ty_options.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 63 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_dev/src/generate_options.rs:38` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (30 lines × 2) · ×2
  • Duplicated block (30 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:179 — crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:179-208 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:281-310 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:179` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (30 lines × 2) crates/ruff_python_formatter/src/other/f_string.rs:18 — crates/ruff_python_formatter/src/other/f_string.rs:18-47 | crates/ruff_python_formatter/src/other/t_string.rs:18-47 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&FString` in one and `&TString` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (29 lines × 2) · ×2
  • Duplicated block (29 lines × 2) crates/ruff_workspace/src/configuration.rs:1499 — crates/ruff_workspace/src/configuration.rs:1499-1527 | crates/ruff_workspace/src/options.rs:4499-4527 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_workspace/src/configuration.rs:1499` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (29 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3591 — crates/ty_python_semantic/src/types/signatures.rs:3591-3619 | crates/ty_python_semantic/src/types/signatures.rs:4481-4509 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3591` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (27 lines × 2) · ×2
  • Duplicated block (27 lines × 2) crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:139 — crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:139-165 | crates/ruff_linter/src/rules/perflint/rules/manual_list_copy.rs:66-92 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:139` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (27 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3807 — crates/ty_python_semantic/src/types/signatures.rs:3807-3833 | crates/ty_python_semantic/src/types/signatures.rs:4516-4542 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3807` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (23–24 lines × 2) · ×2
  • Duplicated block (23–24 lines × 2) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:323 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:323-346 | crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:378-400 — before extracting anything, compare `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs` and `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (23–24 lines × 2) crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:46 — crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:46-68 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:108-131 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:46` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:132` calls `default`, `space` and `crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:69` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (20–23 lines × 2) · ×2
  • Duplicated block (20–23 lines × 2) crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:372 — crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:372-394 | crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:400-419 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:372` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20–23 lines × 2) crates/ruff_python_formatter/src/other/arguments.rs:118 — crates/ruff_python_formatter/src/other/arguments.rs:118-140 | crates/ruff_python_formatter/src/pattern/pattern_arguments.rs:82-101 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (22–23 lines × 2) · ×2
  • Duplicated block (22–23 lines × 2) crates/ruff_server/src/server.rs:385 — crates/ruff_server/src/server.rs:385-407 | crates/ty_server/src/server.rs:213-234 — before extracting anything, compare `crates/ruff_server/src/server.rs` and `crates/ty_server/src/server.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server.rs:385` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (22–23 lines × 2) crates/ty_python_semantic/src/types/infer/comparisons.rs:1215 — crates/ty_python_semantic/src/types/infer/comparisons.rs:1215-1237 | crates/ty_python_semantic/src/types/infer/comparisons.rs:1248-1269 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/comparisons.rs:1215` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–20 lines × 2) · ×2
  • Duplicated block (15–20 lines × 2) crates/ty_ide/src/docstring/document/google.rs:262 — crates/ty_ide/src/docstring/document/google.rs:262-281 | crates/ty_ide/src/docstring/document/numpy.rs:169-183 — before extracting anything, compare `crates/ty_ide/src/docstring/document/google.rs` and `crates/ty_ide/src/docstring/document/numpy.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_ide/src/docstring/document/google.rs:262` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (15–20 lines × 2) crates/ty_python_semantic/src/types/visitor.rs:615 — crates/ty_python_semantic/src/types/visitor.rs:615-634 | crates/ty_python_semantic/src/types/visitor.rs:921-935 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/visitor.rs:615` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19 lines × 3) · ×2
  • Duplicated block (19 lines × 3) crates/ty_python_semantic/src/types/constraints/sequents.rs:957 — crates/ty_python_semantic/src/types/constraints/sequents.rs:957-975 | crates/ty_python_semantic/src/types/constraints/sequents.rs:995-1013 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1033-1051 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 3) crates/ty_python_semantic/src/types/signatures.rs:4469 — crates/ty_python_semantic/src/types/signatures.rs:4469-4487 | crates/ty_python_semantic/src/types/signatures.rs:4509-4527 | crates/ty_python_semantic/src/types/signatures.rs:4852-4870 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:4509` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–19 lines × 2) · ×2
  • Duplicated block (16–19 lines × 2) crates/ruff_annotate_snippets/src/renderer/render.rs:819 — crates/ruff_annotate_snippets/src/renderer/render.rs:819-837 | crates/ruff_annotate_snippets/src/renderer/render.rs:873-888 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_annotate_snippets/src/renderer/render.rs:819` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–19 lines × 2) crates/ruff_server/src/logging.rs:42 — crates/ruff_server/src/logging.rs:42-60 | crates/ty_server/src/logging.rs:43-58 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/logging.rs:42` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `log_file` to `Option<&std::path::Path>` in one and `Option<&SystemPath>` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_server/src/logging.rs:61` calls `with_span_events` and `crates/ty_server/src/logging.rs:59` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×2
  • Duplicated block (17–19 lines × 2) crates/ruff_linter/src/noqa.rs:452 — crates/ruff_linter/src/noqa.rs:452-468 | crates/ruff_linter/src/noqa.rs:510-528 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/noqa.rs:452` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17–19 lines × 2) crates/ruff_python_parser/src/lexer.rs:893 — crates/ruff_python_parser/src/lexer.rs:893-909 | crates/ruff_python_parser/src/lexer.rs:930-948 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_parser/src/lexer.rs:893` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (16–17 lines × 2) · ×2
  • Duplicated block (16–17 lines × 2) crates/ruff_linter/src/message/mod.rs:52 — crates/ruff_linter/src/message/mod.rs:52-68 | crates/ty_project/src/lib.rs:1152-1167 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/message/mod.rs:52` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16–17 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:267 — crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:267-282 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_key_check.rs:78-94 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:267` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15–17 lines × 2) · ×2
  • Duplicated block (15–17 lines × 2) crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1181 — crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1181-1197 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs:309-323 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 74 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1181` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15–17 lines × 2) crates/ty_python_semantic/src/types/set_theoretic.rs:601 — crates/ty_python_semantic/src/types/set_theoretic.rs:601-617 | crates/ty_python_semantic/src/types/set_theoretic.rs:663-677 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic.rs:663` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (15–16 lines × 2) · ×2
  • Duplicated block (15–16 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs:72 — crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs:72-87 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs:120-134 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs:116` calls `as_ref` and `crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs:71` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15–16 lines × 2) crates/ruff_linter/src/rules/isort/annotate.rs:33 — crates/ruff_linter/src/rules/isort/annotate.rs:33-48 | crates/ruff_linter/src/rules/isort/annotate.rs:103-117 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (14 lines × 4) · ×2
  • Duplicated block (14 lines × 4) crates/ty_python_semantic/src/types/call/bind.rs:10854 — crates/ty_python_semantic/src/types/call/bind.rs:10854-10867 | crates/ty_python_semantic/src/types/call/bind.rs:10924-10937 | crates/ty_python_semantic/src/types/call/bind.rs:10946-10959 | crates/ty_python_semantic/src/types/call/bind.rs:10973-10986 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:10854` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (14 lines × 4) crates/ty_python_semantic/src/types/constraints/sequents.rs:963 — crates/ty_python_semantic/src/types/constraints/sequents.rs:963-976 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1001-1014 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1039-1052 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1136-1149 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:963` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (12–14 lines × 3) · ×2
  • Duplicated block (12–14 lines × 3) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1539 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1539-1550 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1570-1581 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1602-1615 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1539` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (12–14 lines × 3) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:119 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:119-132 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:569-582 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:878-889 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs` and `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:119` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–13 lines × 3) · ×2
  • Duplicated block (11–13 lines × 3) crates/ruff_python_ast/src/name.rs:565 — crates/ruff_python_ast/src/name.rs:565-575 | crates/ruff_python_ast/src/name.rs:580-591 | crates/ruff_python_ast/src/name.rs:596-608 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/name.rs:565` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11–13 lines × 3) crates/ruff_python_semantic/src/model.rs:660 — crates/ruff_python_semantic/src/model.rs:660-670 | crates/ruff_python_semantic/src/model.rs:740-752 | crates/ruff_python_semantic/src/model.rs:787-797 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_semantic/src/model.rs:787` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_semantic/src/model.rs:756` calls `insert`, `into`, `Resolved` and `crates/ruff_python_semantic/src/model.rs:671` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (12 lines × 4) · ×2
  • Duplicated block (12 lines × 4) crates/ruff_linter/src/rules/isort/order.rs:71 — crates/ruff_linter/src/rules/isort/order.rs:71-82 | crates/ruff_linter/src/rules/isort/order.rs:96-107 | crates/ruff_linter/src/rules/isort/order.rs:194-205 | crates/ruff_linter/src/rules/isort/order.rs:219-230 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/isort/order.rs:71` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 4) crates/ty_server/src/server/api/requests/goto_declaration.rs:59 — crates/ty_server/src/server/api/requests/goto_declaration.rs:59-70 | crates/ty_server/src/server/api/requests/goto_definition.rs:60-71 | crates/ty_server/src/server/api/requests/goto_implementation.rs:59-70 | crates/ty_server/src/server/api/requests/goto_type_definition.rs:60-71 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 4 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_server/src/server/api/requests/goto_declaration.rs:59` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (9–12 lines × 2) · ×2
  • Duplicated block (9–12 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:619 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:619-630 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:840-848 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:619` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–12 lines × 2) crates/ruff_linter/src/rules/tryceratops/rules/error_instead_of_exception.rs:78 — crates/ruff_linter/src/rules/tryceratops/rules/error_instead_of_exception.rs:78-86 | crates/ruff_linter/src/rules/tryceratops/rules/verbose_log_message.rs:54-65 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/tryceratops/rules/error_instead_of_exception.rs:78` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10–11 lines × 3) · ×2
  • Duplicated block (10–11 lines × 3) crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:262 — crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:262-272 | crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1095-1105 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:386-395 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs` and `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:262` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:259` calls `split`, `next`, `unwrap_or` and `crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:383` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10–11 lines × 3) crates/ruff_python_formatter/src/expression/expr_generator.rs:44 — crates/ruff_python_formatter/src/expression/expr_generator.rs:44-53 | crates/ruff_python_formatter/src/expression/expr_list_comp.rs:17-27 | crates/ruff_python_formatter/src/expression/expr_set_comp.rs:17-27 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/expression/expr_generator.rs:44` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `item` to `&ExprGenerator` in one and `&ExprListComp` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (8–11 lines × 2) · ×2
  • Duplicated block (8–11 lines × 2) crates/ruff/src/diagnostics.rs:264 — crates/ruff/src/diagnostics.rs:264-271 | crates/ruff/src/diagnostics.rs:446-456 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff/src/diagnostics.rs:264` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8–11 lines × 2) crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs:107 — crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs:107-117 | crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs:165-172 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–11 lines × 2) · ×2
  • Duplicated block (9–11 lines × 2) crates/ty_ide/src/docstring/document.rs:225 — crates/ty_ide/src/docstring/document.rs:225-233 | crates/ty_ide/src/docstring/document/rst.rs:374-384 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_ide/src/docstring/document.rs:225` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9–11 lines × 2) crates/ty_python_semantic/src/types/infer/builder.rs:4527 — crates/ty_python_semantic/src/types/infer/builder.rs:4527-4537 | crates/ty_python_semantic/src/types/infer/builder.rs:4805-4813 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:4527` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×2
  • Duplicated block (10 lines × 4) crates/ty_python_semantic/src/types/infer/builder.rs:719 — crates/ty_python_semantic/src/types/infer/builder.rs:719-729 | crates/ty_python_semantic/src/types/infer/builder.rs:833-842 | crates/ty_python_semantic/src/types/infer/builder.rs:874-885 | crates/ty_python_semantic/src/types/infer/builder.rs:914-923 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:719` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/infer/builder.rs:715` calls `extend`, `iter`, `copied` and `crates/ty_python_semantic/src/types/infer/builder.rs:829` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 4) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:571 — crates/ty_python_semantic/src/types/set_theoretic/builder.rs:571-580 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:583-592 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:595-604 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:613-622 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic/builder.rs:571` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–10 lines × 3) · ×2
  • Duplicated block (9–10 lines × 3) crates/ty_python_semantic/src/types/constraints/variables.rs:798 — crates/ty_python_semantic/src/types/constraints/variables.rs:798-807 | crates/ty_python_semantic/src/types/constraints/variables.rs:917-926 | crates/ty_python_semantic/src/types/constraints/variables.rs:1033-1041 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/variables.rs:798` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9–10 lines × 3) crates/ty_python_semantic/src/types/infer/builder.rs:2498 — crates/ty_python_semantic/src/types/infer/builder.rs:2498-2506 | crates/ty_python_semantic/src/types/infer/builder.rs:5496-5505 | crates/ty_python_semantic/src/types/infer/builder.rs:9045-9054 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:2498` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7–9 lines × 2) · ×2
  • Duplicated block (7–9 lines × 2) crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:222 — crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:222-228 | crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:244-252 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/read_whole_file.rs:244` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–9 lines × 2) crates/ruff_python_ast/src/helpers.rs:554 — crates/ruff_python_ast/src/helpers.rs:554-560 | crates/ruff_python_ast/src/helpers.rs:582-590 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/helpers.rs:554` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 4) · ×2
  • Duplicated block (8 lines × 4) crates/ruff_linter/src/linter.rs:375 — crates/ruff_linter/src/linter.rs:375-382 | crates/ruff_linter/src/linter.rs:444-451 | crates/ruff_linter/src/linter.rs:554-561 | crates/ruff_wasm/src/lib.rs:365-372 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/linter.rs:375` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 4) crates/ty_python_semantic/src/types/call/bind.rs:2964 — crates/ty_python_semantic/src/types/call/bind.rs:2964-2971 | crates/ty_python_semantic/src/types/call/bind.rs:2993-3000 | crates/ty_python_semantic/src/types/call/bind.rs:3022-3029 | crates/ty_python_semantic/src/types/call/bind.rs:3051-3059 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:2964` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×2
  • Duplicated block (7–8 lines × 2) crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:369 — crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:369-376 | crates/ruff_linter/src/rules/refurb/rules/slice_to_remove_prefix_or_suffix.rs:416-422 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (7–8 lines × 2) crates/ty_python_semantic/src/types/generics.rs:952 — crates/ty_python_semantic/src/types/generics.rs:952-958 | crates/ty_python_semantic/src/types/generics.rs:1123-1130 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/generics.rs:1123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (7 lines × 6) · ×2
  • Duplicated block (7 lines × 6) crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:202 — crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:202-208 | crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:304-310 | crates/ruff_linter/src/rules/flake8_simplify/rules/reimplemented_builtin.rs:405-411 | crates/ruff_linter/src/rules/refurb/helpers.rs:36-42 | crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs:192-198 | crates/ruff_linter/src/rules/refurb/rules/repeated_append.rs:364-370 — before extracting anything, compare `crates/ruff_linter/src/rules/refurb/helpers.rs` and `crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 30 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_get.rs:202` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (7 lines × 6) crates/ruff_python_ast/src/name.rs:523 — crates/ruff_python_ast/src/name.rs:523-529 | crates/ruff_python_ast/src/name.rs:532-540 | crates/ruff_python_ast/src/name.rs:545-553 | crates/ruff_python_ast/src/name.rs:559-567 | crates/ruff_python_ast/src/name.rs:574-582 | crates/ruff_python_ast/src/name.rs:590-598 — all 6 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/name.rs:523` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_ast/src/name.rs:556` calls `as_str` and `crates/ruff_python_ast/src/name.rs:543` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–7 lines × 2) · ×2
  • Duplicated block (6–7 lines × 2) crates/ty_python_core/src/re_exports.rs:324 — crates/ty_python_core/src/re_exports.rs:324-329 | crates/ty_python_core/src/re_exports.rs:378-384 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6–7 lines × 2) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:447 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:447-452 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:459-465 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:447` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (5 lines × 4) · ×2
  • Duplicated block (5 lines × 4) crates/ty_python_semantic/src/types/class/typed_dict.rs:428 — crates/ty_python_semantic/src/types/class/typed_dict.rs:428-435 | crates/ty_python_semantic/src/types/class/typed_dict.rs:606-610 | crates/ty_python_semantic/src/types/class/typed_dict.rs:623-628 | crates/ty_python_semantic/src/types/class/typed_dict.rs:679-684 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/typed_dict.rs:428` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (5 lines × 4) crates/ty_python_semantic/src/types/infer/builder.rs:709 — crates/ty_python_semantic/src/types/infer/builder.rs:709-713 | crates/ty_python_semantic/src/types/infer/builder.rs:766-770 | crates/ty_python_semantic/src/types/infer/builder.rs:824-828 | crates/ty_python_semantic/src/types/infer/builder.rs:863-867 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/infer/builder.rs:706` calls `extend_cycle_recovery`, `extend`, `iter` and `crates/ty_python_semantic/src/types/infer/builder.rs:862` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D1 · Cyclomatic Complexity · Bindings · ×1
  • Bindings::evaluate_known_cases (cyclomatic 254) crates/ty_python_semantic/src/types/call/bind.rs:1715 — Bindings::evaluate_known_cases has cyclomatic complexity 254 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DisplayRepresentation · ×1
  • DisplayRepresentation::fmt_detailed (cyclomatic 111) crates/ty_python_semantic/src/types/display.rs:1183 — DisplayRepresentation::fmt_detailed has cyclomatic complexity 111 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · BindingError · ×1
  • BindingError::report_diagnostic (cyclomatic 80) crates/ty_python_semantic/src/types/call/bind.rs:10621 — BindingError::report_diagnostic has cyclomatic complexity 80 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KnownFunction · ×1
  • KnownFunction::check_call (cyclomatic 80) crates/ty_python_semantic/src/types/infer/builder/function.rs:1627 — KnownFunction::check_call has cyclomatic complexity 80 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ImportStatement · ×1
  • ImportStatement::detect (cyclomatic 78) crates/ty_ide/src/completion.rs:2698 — ImportStatement::detect has cyclomatic complexity 78 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · BoundSuperType · ×1
  • BoundSuperType::build (cyclomatic 65) crates/ty_python_semantic/src/types/bound_super.rs:527 — BoundSuperType::build has cyclomatic complexity 65 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ComparableExpr · ×1
  • ComparableExpr::eq (cyclomatic 64) crates/ruff_python_ast/src/comparable.rs:45 — ComparableExpr::eq has cyclomatic complexity 64 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ResolvedPythonType · ×1
  • ResolvedPythonType::from (cyclomatic 61) crates/ruff_python_semantic/src/analyze/type_inference.rs:71 — ResolvedPythonType::from has cyclomatic complexity 61 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ErrorContext · ×1
  • ErrorContext::render (cyclomatic 59) crates/ty_python_semantic/src/types/relation_error.rs:251 — ErrorContext::render has cyclomatic complexity 59 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · SimpleTokenizer · ×1
  • SimpleTokenizer::next_token_inner (cyclomatic 57) crates/ruff_python_trivia/src/tokenizer.rs:567 — SimpleTokenizer::next_token_inner has cyclomatic complexity 57 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ProjectDatabase · ×1
  • ProjectDatabase::apply_changes (cyclomatic 55) crates/ty_project/src/db/changes.rs:94 — ProjectDatabase::apply_changes has cyclomatic complexity 55 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · rule-filters.document$.subscribe() (cyclomatic 52) · ×1
  • rule-filters.document$.subscribe() (cyclomatic 52) docs/js/rule-filters.js:4 — rule-filters.document$.subscribe() has cyclomatic complexity 52 (threshold 15). Most of this is not in the body itself: 9 of the 52 points are its own statements and the rest belongs to 11 function items inside it that branch (a function literal at line 89, filter, a function literal at line 234, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · LintConfiguration · ×1
  • LintConfiguration::as_rule_table (cyclomatic 51) crates/ruff_workspace/src/configuration.rs:904 — LintConfiguration::as_rule_table has cyclomatic complexity 51 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · FormatSuite · ×1
  • FormatSuite::fmt (cyclomatic 50) crates/ruff_python_formatter/src/statement/suite.rs:96 — FormatSuite::fmt has cyclomatic complexity 50 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FitsMeasurer · ×1
  • FitsMeasurer::fits_element (cyclomatic 49) crates/ruff_formatter/src/printer/mod.rs:1166 — FitsMeasurer::fits_element has cyclomatic complexity 49 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · SemanticSyntaxError · ×1
  • SemanticSyntaxError::fmt (cyclomatic 48) crates/ruff_python_parser/src/semantic_errors.rs:1384 — SemanticSyntaxError::fmt has cyclomatic complexity 48 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ComparableStmt · ×1
  • ComparableStmt::eq (cyclomatic 47) crates/ruff_python_ast/src/comparable.rs:45 — ComparableStmt::eq has cyclomatic complexity 47 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ruff_workspace · ×1
  • ruff_workspace::configuration::warn_about_deprecated_top_level_lint_options (cyclomatic 47) crates/ruff_workspace/src/configuration.rs:1476 — ruff_workspace::configuration::warn_about_deprecated_top_level_lint_options has cyclomatic complexity 47 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ImportReplacer · ×1
  • ImportReplacer::without_renames (cyclomatic 43) crates/ruff_linter/src/rules/pyupgrade/rules/deprecated_import.rs:491 — ImportReplacer::without_renames has cyclomatic complexity 43 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SymbolVisitor · ×1
  • SymbolVisitor::visit_stmt_impl (cyclomatic 41) crates/ty_ide/src/symbols.rs:1299 — SymbolVisitor::visit_stmt_impl has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ContextManagerError · ×1
  • ContextManagerError::report_diagnostic (cyclomatic 40) crates/ty_python_semantic/src/types/context_manager.rs:384 — ContextManagerError::report_diagnostic has cyclomatic complexity 40 (threshold 15). Of this number, 39 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · AllMembers · ×1
  • AllMembers::extend_with_type (cyclomatic 40) crates/ty_python_semantic/src/types/list_members.rs:176 — AllMembers::extend_with_type has cyclomatic complexity 40 (threshold 15). Of this number, 38 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · FormatExpr · ×1
  • FormatExpr::fmt (cyclomatic 39) crates/ruff_python_formatter/src/expression/mod.rs:76 — FormatExpr::fmt has cyclomatic complexity 39 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · ClassBase · ×1
  • ClassBase::try_from_type (cyclomatic 39) crates/ty_python_semantic/src/types/class_base.rs:145 — ClassBase::try_from_type has cyclomatic complexity 39 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · DunderAllNamesCollector · ×1
  • DunderAllNamesCollector::visit_stmt (cyclomatic 38) crates/ty_python_semantic/src/dunder_all.rs:233 — DunderAllNamesCollector::visit_stmt has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · IterationError · ×1
  • IterationError::report_diagnostic (cyclomatic 37) crates/ty_python_semantic/src/types/iteration.rs:774 — IterationError::report_diagnostic has cyclomatic complexity 37 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Truthiness · ×1
  • Truthiness::from_expr (cyclomatic 35) crates/ruff_python_ast/src/helpers.rs:1391 — Truthiness::from_expr has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FormatStatementsLastExpression · ×1
  • FormatStatementsLastExpression::fmt (cyclomatic 34) crates/ruff_python_formatter/src/statement/stmt_assign.rs:277 — FormatStatementsLastExpression::fmt has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · KnownClass · ×1
  • KnownClass::canonical_module (cyclomatic 34) crates/ty_python_semantic/src/types/class/known.rs:1525 — KnownClass::canonical_module has cyclomatic complexity 34 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: KnownClass::name (cyclomatic 118) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ClassInfoConstraint · ×1
  • ClassInfoConstraint::generate_impl (cyclomatic 34) crates/ty_python_semantic/src/types/narrow.rs:568 — ClassInfoConstraint::generate_impl has cyclomatic complexity 34 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · MainLoop · ×1
  • MainLoop::main_loop (cyclomatic 33) crates/ty/src/lib.rs:364 — MainLoop::main_loop has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DisplayKnownInstanceRepr · ×1
  • DisplayKnownInstanceRepr::fmt_detailed (cyclomatic 33) crates/ty_python_semantic/src/types/display.rs:3892 — DisplayKnownInstanceRepr::fmt_detailed has cyclomatic complexity 33 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · RecoveryContext · ×1
  • RecoveryContext::from_kind (cyclomatic 32) crates/ruff_python_parser/src/parser/mod.rs:1655 — RecoveryContext::from_kind has cyclomatic complexity 32 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: RecoveryContext::to_kind (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · SpecialFormType · ×1
  • SpecialFormType::in_type_expression (cyclomatic 32) crates/ty_python_semantic/src/types/special_form.rs:814 — SpecialFormType::in_type_expression has cyclomatic complexity 32 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: SpecialFormType::candidates_from_name (cyclomatic 98) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ty_test · ×1
  • ty_test::run_test (cyclomatic 32) crates/ty_test/src/lib.rs:90 — ty_test::run_test has cyclomatic complexity 32 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Mro · ×1
  • Mro::ancestors_of_static_class (cyclomatic 31) crates/ty_python_semantic/src/types/mro.rs:55 — Mro::ancestors_of_static_class has cyclomatic complexity 31 (threshold 15). Of this number, 29 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BlockBuilder · ×1
  • BlockBuilder::visit_stmt (cyclomatic 30) crates/ruff_linter/src/rules/isort/block.rs:124 — BlockBuilder::visit_stmt has cyclomatic complexity 30 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · LocalReferencesFinder · ×1
  • LocalReferencesFinder::enter_node (cyclomatic 29) crates/ty_ide/src/references.rs:606 — LocalReferencesFinder::enter_node has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UvMetadata · ×1
  • UvMetadata::dependency_metadata (cyclomatic 29) crates/ty_project/src/uv/metadata/dependencies.rs:17 — UvMetadata::dependency_metadata has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Playground.Playground (cyclomatic 29) · ×1
  • Playground.Playground (cyclomatic 29) playground/ty/src/Playground.tsx:37 — Playground.Playground has cyclomatic complexity 29 (threshold 15). Most of this is not in the body itself: 4 of the 29 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 145, 98, 221, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D1 · Cyclomatic Complexity · FStringConversion · ×1
  • FStringConversion::try_convert (cyclomatic 28) crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs:248 — FStringConversion::try_convert has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ResolvedClientCapabilities · ×1
  • ResolvedClientCapabilities::new (cyclomatic 27) crates/ty_server/src/capabilities.rs:216 — ResolvedClientCapabilities::new has cyclomatic complexity 27 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Debouncer · ×1
  • Debouncer::add_event (cyclomatic 27) crates/ty_project/src/watch/watcher.rs:214 — Debouncer::add_event has cyclomatic complexity 27 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · TruthinessAnalyzer · ×1
  • TruthinessAnalyzer::evaluate (cyclomatic 27) crates/ty_python_semantic/src/types/infer/expression_truthiness.rs:87 — TruthinessAnalyzer::evaluate has cyclomatic complexity 27 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · LoopMutationsVisitor · ×1
  • LoopMutationsVisitor::visit_stmt (cyclomatic 26) crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:339 — LoopMutationsVisitor::visit_stmt has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FoldingRangeVisitor · ×1
  • FoldingRangeVisitor::enter_node (cyclomatic 26) crates/ty_ide/src/folding_range.rs:588 — FoldingRangeVisitor::enter_node has cyclomatic complexity 26 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · LoopBindingsVisitor · ×1
  • LoopBindingsVisitor::visit_stmt (cyclomatic 26) crates/ty_python_core/src/builder/loop_bindings_visitor.rs:66 — LoopBindingsVisitor::visit_stmt has cyclomatic complexity 26 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · SubscriptErrorKind · ×1
  • SubscriptErrorKind::report_diagnostic (cyclomatic 26) crates/ty_python_semantic/src/types/subscript.rs:294 — SubscriptErrorKind::report_diagnostic has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ProjectFilesWalker · ×1
  • ProjectFilesWalker::collect_vec (cyclomatic 25) crates/ty_project/src/walk.rs:154 — ProjectFilesWalker::collect_vec has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NarrowingProjector · ×1
  • NarrowingProjector::project (cyclomatic 25) crates/ty_python_semantic/src/reachability.rs:1473 — NarrowingProjector::project has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DisplayParameters · ×1
  • DisplayParameters::fmt_detailed (cyclomatic 25) crates/ty_python_semantic/src/types/display.rs:2816 — DisplayParameters::fmt_detailed has cyclomatic complexity 25 (threshold 15). Of this number, 13 points are the body's own statements and 12 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FormatInterpolatedElement · ×1
  • FormatInterpolatedElement::fmt (cyclomatic 24) crates/ruff_python_formatter/src/other/interpolated_string_element.rs:95 — FormatInterpolatedElement::fmt has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FormatImplicitConcatenatedStringFlat · ×1
  • FormatImplicitConcatenatedStringFlat::new::merge_flags (cyclomatic 24) crates/ruff_python_formatter/src/string/implicit.rs:138 — FormatImplicitConcatenatedStringFlat::new::merge_flags has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MatchPatternVisitor · ×1
  • MatchPatternVisitor::visit_pattern (cyclomatic 24) crates/ruff_python_parser/src/semantic_errors.rs:2278 — MatchPatternVisitor::visit_pattern has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ty · ×1
  • ty::run_check (cyclomatic 24) crates/ty/src/lib.rs:95 — ty::run_check has cyclomatic complexity 24 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · DisplayUnionType · ×1
  • DisplayUnionType::fmt_detailed (cyclomatic 24) crates/ty_python_semantic/src/types/display.rs:3231 — DisplayUnionType::fmt_detailed has cyclomatic complexity 24 (threshold 15). Of this number, 19 points are the body's own statements and 5 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LinePreprocessor · ×1
  • LinePreprocessor::next (cyclomatic 23) crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs:430 — LinePreprocessor::next has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BackwardsTokenizer · ×1
  • BackwardsTokenizer::next_token_inner (cyclomatic 23) crates/ruff_python_trivia/src/tokenizer.rs:918 — BackwardsTokenizer::next_token_inner has cyclomatic complexity 23 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: ruff_python_trivia::tokenizer::to_keyword_or_other (cyclomatic 37) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · PortableGlobPattern · ×1
  • PortableGlobPattern::parse (cyclomatic 23) crates/ty_project/src/glob/portable.rs:40 — PortableGlobPattern::parse has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UnionElement · ×1
  • UnionElement::try_reduce (cyclomatic 23) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:484 — UnionElement::try_reduce has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Suppressions · ×1
  • Suppressions::check_suppressions (cyclomatic 22) crates/ruff_linter/src/suppression.rs:472 — Suppressions::check_suppressions has cyclomatic complexity 22 (threshold 15). Of this number, 16 points are the body's own statements and 6 belong to one function item inside it that branches. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · IsortOptions · ×1
  • IsortOptions::try_into_settings (cyclomatic 22) crates/ruff_workspace/src/options.rs:3059 — IsortOptions::try_into_settings has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SecondaryPanel.SecondaryPanel (cyclomatic 22) · ×1
  • SecondaryPanel.SecondaryPanel (cyclomatic 22) playground/ruff/src/Editor/SecondaryPanel.tsx:26 — SecondaryPanel.SecondaryPanel has cyclomatic complexity 22 (threshold 15). Of this number, 14 points are the body's own statements and 8 belong to 5 function literals inside it that branch. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ExplicitConfigOverrides · ×1
  • ExplicitConfigOverrides::transform (cyclomatic 21) crates/ruff/src/args.rs:1412 — ExplicitConfigOverrides::transform has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Diff · ×1
  • Diff::write (cyclomatic 21) crates/ruff_db/src/diagnostic/render/full.rs:117 — Diff::write has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: ruff_db::diagnostic::render::full::show_nonprinting (cyclomatic 38) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · Document · ×1
  • Document::propagate_expand::propagate_expands (cyclomatic 21) crates/ruff_formatter/src/format_element/document.rs:57 — Document::propagate_expand::propagate_expands has cyclomatic complexity 21 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · GroupNameFinder · ×1
  • GroupNameFinder::visit_stmt (cyclomatic 21) crates/ruff_linter/src/rules/flake8_bugbear/rules/reuse_of_groupby_generator.rs:120 — GroupNameFinder::visit_stmt has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FormatExprAttribute · ×1
  • FormatExprAttribute::fmt_fields (cyclomatic 21) crates/ruff_python_formatter/src/expression/expr_attribute.rs:28 — FormatExprAttribute::fmt_fields has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ContextCursor · ×1
  • ContextCursor::incomplete_keywords (cyclomatic 21) crates/ty_ide/src/completion.rs:1282 — ContextCursor::incomplete_keywords has cyclomatic complexity 21 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions. This is NOT this file's highest cyclomatic complexity: ContextCursor::is_expecting_expression (cyclomatic 30) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · AbstractMethods · ×1
  • AbstractMethods::annotate_diagnostic (cyclomatic 21) crates/ty_python_semantic/src/types/abstract_methods.rs:42 — AbstractMethods::annotate_diagnostic has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AddBinding · ×1
  • AddBinding::insert (cyclomatic 21) crates/ty_python_semantic/src/types/infer/builder.rs:13606 — AddBinding::insert has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: TypeInferenceBuilder::infer_value_expression_impl (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · UnittestAssert · ×1
  • UnittestAssert::generate_assert (cyclomatic 20) crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:280 — UnittestAssert::generate_assert has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: UnittestAssert::try_from (cyclomatic 42) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · TypingTarget · ×1
  • TypingTarget::try_from_expr (cyclomatic 20) crates/ruff_linter/src/rules/ruff/typing.rs:73 — TypingTarget::try_from_expr has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · UnqualifiedName · ×1
  • UnqualifiedName::from_expr (cyclomatic 20) crates/ruff_python_ast/src/name.rs:516 — UnqualifiedName::from_expr has cyclomatic complexity 20 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · Terminal · ×1
  • Terminal::from_body (cyclomatic 20) crates/ruff_python_semantic/src/analyze/terminal.rs:49 — Terminal::from_body has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Terminal::branch (cyclomatic 24) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · BoundTypeVarInstance · ×1
  • BoundTypeVarInstance::apply_type_mapping_impl (cyclomatic 20) crates/ty_python_semantic/src/types/typevar.rs:1378 — BoundTypeVarInstance::apply_type_mapping_impl has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Editor.Editor (cyclomatic 20) · ×1
  • Editor.Editor (cyclomatic 20) playground/ruff/src/Editor/Editor.tsx:53 — Editor.Editor has cyclomatic complexity 20 (threshold 15). Most of this is not in the body itself: 5 of the 20 points are its own statements and the rest belongs to 6 function items inside it that branch (a function literal at line 175, handleSecondaryToolSelected, a function literal at line 142, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · GithubRenderer · ×1
  • GithubRenderer::render (cyclomatic 19) crates/ruff_db/src/diagnostic/render/github.rs:22 — GithubRenderer::render has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Collector · ×1
  • Collector::visit_stmt (cyclomatic 19) crates/ruff_graph/src/collector.rs:43 — Collector::visit_stmt has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SuppressionsBuilder · ×1
  • SuppressionsBuilder::load_from_tokens (cyclomatic 19) crates/ruff_linter/src/suppression.rs:752 — SuppressionsBuilder::load_from_tokens has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FormatExprSlice · ×1
  • FormatExprSlice::fmt_fields (cyclomatic 19) crates/ruff_python_formatter/src/expression/expr_slice.rs:17 — FormatExprSlice::fmt_fields has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FormatParameters · ×1
  • FormatParameters::fmt_fields (cyclomatic 19) crates/ruff_python_formatter/src/other/parameters.rs:51 — FormatParameters::fmt_fields has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · StringNormalizer · ×1
  • StringNormalizer::preferred_quote_style (cyclomatic 19) crates/ruff_python_formatter/src/string/normalize.rs:44 — StringNormalizer::preferred_quote_style has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RuffSettingsIndex · ×1
  • RuffSettingsIndex::new (cyclomatic 19) crates/ruff_server/src/session/index/ruff_settings.rs:166 — RuffSettingsIndex::new has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · ruff_server · ×1
  • ruff_server::lint::to_lsp_diagnostic (cyclomatic 19) crates/ruff_server/src/lint.rs:371 — ruff_server::lint::to_lsp_diagnostic has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · VariableLengthTuple · ×1
  • VariableLengthTuple::mixed_forward_slice_plan (cyclomatic 19) crates/ty_python_semantic/src/types/tuple.rs:1833 — VariableLengthTuple::mixed_forward_slice_plan has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Unpacker · ×1
  • Unpacker::unpack_inner (cyclomatic 19) crates/ty_python_semantic/src/types/unpacker.rs:182 — Unpacker::unpack_inner has cyclomatic complexity 19 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · ConciseRenderer · ×1
  • ConciseRenderer::render (cyclomatic 18) crates/ruff_db/src/diagnostic/render/concise.rs:20 — ConciseRenderer::render has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · SuspiciousVariablesVisitor · ×1
  • SuspiciousVariablesVisitor::visit_expr (cyclomatic 18) crates/ruff_linter/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs:126 — SuspiciousVariablesVisitor::visit_expr has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · UselessSuppressionComments · ×1
  • UselessSuppressionComments::check_suppression_comment (cyclomatic 18) crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:129 — UselessSuppressionComments::check_suppression_comment has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ReFunc · ×1
  • ReFunc::from_call_expr (cyclomatic 18) crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs:175 — ReFunc::from_call_expr has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BinaryLike · ×1
  • BinaryLike::fmt (cyclomatic 18) crates/ruff_python_formatter/src/expression/binary_like.rs:267 — BinaryLike::fmt has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · NotebookDocument · ×1
  • NotebookDocument::update (cyclomatic 18) crates/ruff_server/src/edit/notebook.rs:110 — NotebookDocument::update has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CodeActions · ×1
  • CodeActions::run_with_snapshot (cyclomatic 18) crates/ruff_server/src/server/api/requests/code_action.rs:27 — CodeActions::run_with_snapshot has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · PythonFilesVisitor · ×1
  • PythonFilesVisitor::visit (cyclomatic 18) crates/ruff_workspace/src/resolver.rs:650 — PythonFilesVisitor::visit has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ExportFinder · ×1
  • ExportFinder::visit_stmt (cyclomatic 18) crates/ty_python_core/src/re_exports.rs:181 — ExportFinder::visit_stmt has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Binding · ×1
  • Binding::argument_type_context (cyclomatic 18) crates/ty_python_semantic/src/types/call/bind.rs:8996 — Binding::argument_type_context has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Signature · ×1
  • Signature::bind_self_with_receiver (cyclomatic 18) crates/ty_python_semantic/src/types/signatures.rs:1538 — Signature::bind_self_with_receiver has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Server · ×1
  • Server::main_loop (cyclomatic 18) crates/ty_server/src/server/main_loop.rs:16 — Server::main_loop has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ruff_python_edits · ×1
  • ruff_python_edits::call::unwrapped_call_argument (cyclomatic 18) crates/ruff_python_edits/src/call.rs:18 — ruff_python_edits::call::unwrapped_call_argument has cyclomatic complexity 18 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · ReturnVisitor · ×1
  • ReturnVisitor::visit_stmt (cyclomatic 17) crates/ruff_linter/src/rules/flake8_return/visitor.rs:83 — ReturnVisitor::visit_stmt has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · HashableExpr · ×1
  • HashableExpr::from (cyclomatic 17) crates/ruff_python_ast/src/comparable.rs:2207 — HashableExpr::from has cyclomatic complexity 17 (threshold 15). Most of this is not in the body itself: 1 of the 17 points is its own statement and the rest belongs to 3 function items inside it that branch (as_number, as_hashable_constant, as_hashable). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest. This is NOT this file's highest cyclomatic complexity: ComparableExpr::hash (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · MaybeParenthesizeExpression · ×1
  • MaybeParenthesizeExpression::fmt (cyclomatic 17) crates/ruff_python_formatter/src/expression/mod.rs:346 — MaybeParenthesizeExpression::fmt has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: ruff_python_formatter::expression::format_with_parentheses_comments (cyclomatic 35) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · CFGBuilder · ×1
  • CFGBuilder::process_stmts (cyclomatic 17) crates/ruff_python_semantic/src/cfg/graph.rs:194 — CFGBuilder::process_stmts has cyclomatic complexity 17 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · CallableDescription · ×1
  • CallableDescription::new_with_settings (cyclomatic 17) crates/ty_python_semantic/src/types/call/bind.rs:10080 — CallableDescription::new_with_settings has cyclomatic complexity 17 (threshold 15). Of this number, 15 points are the body's own statements and 2 belong to one function item inside it that branches. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · OverloadLiteral · ×1
  • OverloadLiteral::raw_signature (cyclomatic 17) crates/ty_python_semantic/src/types/function.rs:614 — OverloadLiteral::raw_signature has cyclomatic complexity 17 (threshold 15). Of this number, 10 points are the body's own statements and 7 belong to one function item inside it that branches. To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · Parameters · ×1
  • Parameters::with_transformed_parameters (cyclomatic 17) crates/ty_python_semantic/src/types/signatures.rs:5282 — Parameters::with_transformed_parameters has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Tuple · ×1
  • Tuple::try_for_each_element_pair (cyclomatic 17) crates/ty_python_semantic/src/types/tuple.rs:2738 — Tuple::try_for_each_element_pair has cyclomatic complexity 17 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · Files.FileEntry (cyclomatic 17) · ×1
  • Files.FileEntry (cyclomatic 17) playground/ty/src/Editor/Files.tsx:138 — Files.FileEntry has cyclomatic complexity 17 (threshold 15). Of this number, 9 points are the body's own statements and 8 belong to 3 function items inside it that branch. To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ruff_macros · ×1
  • ruff_macros::rule_namespace::derive_impl (cyclomatic 16) crates/ruff_macros/src/rule_namespace.rs:8 — ruff_macros::rule_namespace::derive_impl has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ruff_markdown · ×1
  • ruff_markdown::format_code_blocks (cyclomatic 16) crates/ruff_markdown/src/lib.rs:64 — ruff_markdown::format_code_blocks has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ComparablePattern · ×1
  • ComparablePattern::eq (cyclomatic 16) crates/ruff_python_ast/src/comparable.rs:45 — ComparablePattern::eq has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing. This is NOT this file's highest cyclomatic complexity: ComparableExpr::hash (cyclomatic 33) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded function is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · ruff_python_parser · ×1
  • ruff_python_parser::parser::recovery::pattern_to_expr (cyclomatic 16) crates/ruff_python_parser/src/parser/recovery.rs:28 — ruff_python_parser::parser::recovery::pattern_to_expr has cyclomatic complexity 16 (threshold 15). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Where every arm is uniform — the same kind of value, with no behaviour of its own — a table keyed by the case is the shorter form; wherever the arms carry different data or different behaviour, keep them as cases, because collapsing those trades an explicit, reviewable set of cases for nothing.
D1 · Cyclomatic Complexity · CommentRanges · ×1
  • CommentRanges::block_comments (cyclomatic 16) crates/ruff_python_trivia/src/comment_ranges.rs:157 — CommentRanges::block_comments has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Importer · ×1
  • Importer::import_for_diagnostic (cyclomatic 16) crates/ty_python_semantic/src/importer.rs:323 — Importer::import_for_diagnostic has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · FieldMetadata · ×1
  • FieldMetadata::collect_from_annotation (cyclomatic 16) crates/ty_python_semantic/src/types/dedicated/pydantic.rs:194 — FieldMetadata::collect_from_annotation has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ProtocolClass · ×1
  • ProtocolClass::validate_type_parameter_variance (cyclomatic 16) crates/ty_python_semantic/src/types/protocol_class.rs:340 — ProtocolClass::validate_type_parameter_variance has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · IntersectionBuilder · ×1
  • IntersectionBuilder::add_negative_impl (cyclomatic 16) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:1799 — IntersectionBuilder::add_negative_impl has cyclomatic complexity 16 (threshold 15). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D1 · Cyclomatic Complexity · TypeVarInstance · ×1
  • TypeVarInstance::type_is_self_referential (cyclomatic 16) crates/ty_python_semantic/src/types/typevar.rs:507 — TypeVarInstance::type_is_self_referential has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 1 of the 16 points is its own statement and the rest belongs to 3 function items inside it that branch (type_is_self_referential_impl, type_alias_is_self_referential, typevar_default_is_self_referential). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D1 · Cyclomatic Complexity · Chrome.Chrome (cyclomatic 16) · ×1
  • Chrome.Chrome (cyclomatic 16) playground/ruff/src/Editor/Chrome.tsx:17 — Chrome.Chrome has cyclomatic complexity 16 (threshold 15). Most of this is not in the body itself: 3 of the 16 points are its own statements and the rest belongs to 7 function literals inside it that branch (lines 47, 26, 33, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D1 · Cyclomatic Complexity · ShareButton.ShareButton (cyclomatic 16) · ×1
  • ShareButton.ShareButton (cyclomatic 16) playground/shared/src/ShareButton.tsx:17 — ShareButton.ShareButton has cyclomatic complexity 16 (threshold 15). Of this number, 9 points are the body's own statements and 7 belong to 2 function literals inside it that branch. To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D15 · Churn × Complexity Hotspots · Repeated repair · ×1
  • Repeated repair: crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs:129 — crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs changed 5 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 10 (its worst body is ruff_linter::rules::pyupgrade::rules::pep695::non_pep695_type_alias::non_pep695_type_alias_type at line 129), AT OR UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “[`pyupgrade`] Remove mentions of variance related to fix safety (`UP040`, `UP047`) (#29592)”; “[`pyupgrade`] Preserve grouping in multiline `UP040` fixes (#28164)”; “[`pyupgrade`] Make the fix for `UP040` always unsafe (#28526)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-15..2026-11-13, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-15 22:46:48 +00:00' --until='2026-11-13 22:46:48 +00:00' --full-history --no-merges -- crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D2 · Cognitive Complexity · KnownFunction · ×1
  • KnownFunction::check_call (cognitive 157) crates/ty_python_semantic/src/types/infer/builder/function.rs:1627 — KnownFunction::check_call has cognitive complexity 157 (threshold 15). Drivers by points: if/else 53 (126 pts), match/switch 6 (14 pts), loops 4 (13 pts), boolean chains 4 (nesting depth added 90). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · BindingError · ×1
  • BindingError::report_diagnostic (cognitive 149) crates/ty_python_semantic/src/types/call/bind.rs:10621 — BindingError::report_diagnostic has cognitive complexity 149 (threshold 15). Drivers by points: if/else 55 (125 pts), match/switch 8 (18 pts), loops 1 (4 pts), boolean chains 2 (nesting depth added 83). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ProjectDatabase · ×1
  • ProjectDatabase::apply_changes (cognitive 142) crates/ty_project/src/db/changes.rs:94 — ProjectDatabase::apply_changes has cognitive complexity 142 (threshold 15). Drivers by points: if/else 42 (117 pts), match/switch 6 (15 pts), boolean chains 7, loops 2 (3 pts) (nesting depth added 85). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · LintConfiguration · ×1
  • LintConfiguration::as_rule_table (cognitive 120) crates/ruff_workspace/src/configuration.rs:904 — LintConfiguration::as_rule_table has cognitive complexity 120 (threshold 15). Drivers by points: loops 22 (56 pts), if/else 23 (55 pts), boolean chains 6, match/switch 2 (3 pts) (nesting depth added 67). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · GotoTarget · ×1
  • GotoTarget::from_covering_node (cognitive 110) crates/ty_ide/src/goto.rs:976 — GotoTarget::from_covering_node has cognitive complexity 110 (threshold 15). Drivers by points: if/else 29 (79 pts), match/switch 7 (16 pts), boolean chains 13, loops 1 (2 pts) (nesting depth added 60). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatSuite · ×1
  • FormatSuite::fmt (cognitive 95) crates/ruff_python_formatter/src/statement/suite.rs:96 — FormatSuite::fmt has cognitive complexity 95 (threshold 15). Drivers by points: if/else 30 (48 pts), match/switch 13 (35 pts), boolean chains 11, loops 1 (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DisplayRepresentation · ×1
  • DisplayRepresentation::fmt_detailed (cognitive 93) crates/ty_python_semantic/src/types/display.rs:1183 — DisplayRepresentation::fmt_detailed has cognitive complexity 93 (threshold 15). Drivers by points: if/else 22 (49 pts), match/switch 15 (36 pts), loops 3 (8 pts) (nesting depth added 53). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · MainLoop · ×1
  • MainLoop::main_loop (cognitive 84) crates/ty/src/lib.rs:364 — MainLoop::main_loop has cognitive complexity 84 (threshold 15). Drivers by points: if/else 20 (65 pts), match/switch 7 (17 pts), boolean chains 1, loops 1 (nesting depth added 55). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatStatementsLastExpression · ×1
  • FormatStatementsLastExpression::fmt (cognitive 77) crates/ruff_python_formatter/src/statement/stmt_assign.rs:277 — FormatStatementsLastExpression::fmt has cognitive complexity 77 (threshold 15). Drivers by points: if/else 33 (68 pts), boolean chains 8, match/switch 1 (nesting depth added 35). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · DunderAllNamesCollector · ×1
  • DunderAllNamesCollector::visit_stmt (cognitive 70) crates/ty_python_semantic/src/dunder_all.rs:233 — DunderAllNamesCollector::visit_stmt has cognitive complexity 70 (threshold 15). Drivers by points: if/else 22 (52 pts), match/switch 5 (12 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 40). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SimpleTokenizer · ×1
  • SimpleTokenizer::next_token_inner (cognitive 69) crates/ruff_python_trivia/src/tokenizer.rs:567 — SimpleTokenizer::next_token_inner has cognitive complexity 69 (threshold 15). Drivers by points: if/else 43 (66 pts), boolean chains 2, match/switch 1 (nesting depth added 23). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FStringConversion · ×1
  • FStringConversion::try_convert (cognitive 65) crates/ruff_linter/src/rules/pyupgrade/rules/f_strings.rs:248 — FStringConversion::try_convert has cognitive complexity 65 (threshold 15). Drivers by points: if/else 18 (41 pts), match/switch 5 (17 pts), loops 2 (4 pts), boolean chains 3 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ComparableExpr · ×1
  • ComparableExpr::eq (cognitive 63) crates/ruff_python_ast/src/comparable.rs:45 — ComparableExpr::eq has cognitive complexity 63 (threshold 15). Drivers by points: match/switch 32 (63 pts) (nesting depth added 31). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SymbolVisitor · ×1
  • SymbolVisitor::visit_stmt_impl (cognitive 62) crates/ty_ide/src/symbols.rs:1299 — SymbolVisitor::visit_stmt_impl has cognitive complexity 62 (threshold 15). Drivers by points: if/else 27 (52 pts), loops 4 (8 pts), boolean chains 1, match/switch 1 (nesting depth added 29). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BinaryLike · ×1
  • BinaryLike::fmt (cognitive 60) crates/ruff_python_formatter/src/expression/binary_like.rs:267 — BinaryLike::fmt has cognitive complexity 60 (threshold 15). Drivers by points: if/else 20 (54 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 35). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Diff · ×1
  • Diff::write (cognitive 59) crates/ruff_db/src/diagnostic/render/full.rs:117 — Diff::write has cognitive complexity 59 (threshold 15). Drivers by points: if/else 11 (32 pts), loops 7 (19 pts), match/switch 1 (5 pts), boolean chains 3 (nesting depth added 37). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Truthiness · ×1
  • Truthiness::from_expr (cognitive 58) crates/ruff_python_ast/src/helpers.rs:1391 — Truthiness::from_expr has cognitive complexity 58 (threshold 15). Drivers by points: if/else 28 (48 pts), match/switch 3 (8 pts), boolean chains 2 (nesting depth added 25). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · BoundSuperType · ×1
  • BoundSuperType::build (cognitive 54) crates/ty_python_semantic/src/types/bound_super.rs:527 — BoundSuperType::build has cognitive complexity 54 (threshold 15). Drivers by points: match/switch 13 (27 pts), if/else 9 (20 pts), loops 4 (7 pts) (nesting depth added 28). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · NotebookDocument · ×1
  • NotebookDocument::update (cognitive 52) crates/ruff_server/src/edit/notebook.rs:110 — NotebookDocument::update has cognitive complexity 52 (threshold 15). Drivers by points: if/else 12 (32 pts), loops 6 (20 pts) (nesting depth added 34). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ProjectFilesWalker · ×1
  • ProjectFilesWalker::collect_vec (cognitive 51) crates/ty_project/src/walk.rs:154 — ProjectFilesWalker::collect_vec has cognitive complexity 51 (threshold 15). Drivers by points: if/else 16 (35 pts), match/switch 4 (11 pts), boolean chains 5 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextManagerError · ×1
  • ContextManagerError::report_diagnostic (cognitive 51) crates/ty_python_semantic/src/types/context_manager.rs:384 — ContextManagerError::report_diagnostic has cognitive complexity 51 (threshold 15). Drivers by points: if/else 13 (23 pts), loops 7 (14 pts), match/switch 10 (11 pts), boolean chains 3 (nesting depth added 18). Of this number, 50 points are the body's own statements and 1 belongs to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ResolvedPythonType · ×1
  • ResolvedPythonType::from (cognitive 49) crates/ruff_python_semantic/src/analyze/type_inference.rs:71 — ResolvedPythonType::from has cognitive complexity 49 (threshold 15). Drivers by points: match/switch 13 (34 pts), if/else 6 (15 pts) (nesting depth added 30). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SuspiciousVariablesVisitor · ×1
  • SuspiciousVariablesVisitor::visit_expr (cognitive 45) crates/ruff_linter/src/rules/flake8_bugbear/rules/function_uses_loop_variable.rs:126 — SuspiciousVariablesVisitor::visit_expr has cognitive complexity 45 (threshold 15). Drivers by points: if/else 9 (30 pts), loops 3 (11 pts), match/switch 2 (3 pts), boolean chains 1 (nesting depth added 30). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ComparableStmt · ×1
  • ComparableStmt::eq (cognitive 45) crates/ruff_python_ast/src/comparable.rs:45 — ComparableStmt::eq has cognitive complexity 45 (threshold 15). Drivers by points: match/switch 23 (45 pts) (nesting depth added 22). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · UvMetadata · ×1
  • UvMetadata::dependency_metadata (cognitive 45) crates/ty_project/src/uv/metadata/dependencies.rs:17 — UvMetadata::dependency_metadata has cognitive complexity 45 (threshold 15). Drivers by points: if/else 18 (32 pts), loops 6 (8 pts), boolean chains 4, match/switch 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PortableGlobPattern · ×1
  • PortableGlobPattern::parse (cognitive 44) crates/ty_project/src/glob/portable.rs:40 — PortableGlobPattern::parse has cognitive complexity 44 (threshold 15). Drivers by points: if/else 17 (31 pts), loops 3 (7 pts), boolean chains 3, match/switch 1 (3 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ty_test · ×1
  • ty_test::run_test (cognitive 42) crates/ty_test/src/lib.rs:90 — ty_test::run_test has cognitive complexity 42 (threshold 15). Drivers by points: if/else 23 (28 pts), boolean chains 5, match/switch 5, loops 2 (4 pts) (nesting depth added 7). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · BlockBuilder · ×1
  • BlockBuilder::visit_stmt (cognitive 41) crates/ruff_linter/src/rules/isort/block.rs:124 — BlockBuilder::visit_stmt has cognitive complexity 41 (threshold 15). Drivers by points: loops 16 (33 pts), if/else 5 (6 pts), boolean chains 1, match/switch 1 (nesting depth added 18). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · MatchPatternVisitor · ×1
  • MatchPatternVisitor::visit_pattern (cognitive 41) crates/ruff_python_parser/src/semantic_errors.rs:2278 — MatchPatternVisitor::visit_pattern has cognitive complexity 41 (threshold 15). Drivers by points: if/else 10 (27 pts), loops 6 (12 pts), boolean chains 1, match/switch 1 (nesting depth added 23). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · IterationError · ×1
  • IterationError::report_diagnostic (cognitive 41) crates/ty_python_semantic/src/types/iteration.rs:774 — IterationError::report_diagnostic has cognitive complexity 41 (threshold 15). Drivers by points: if/else 18 (29 pts), match/switch 5 (9 pts), loops 1 (3 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatInterpolatedElement · ×1
  • FormatInterpolatedElement::fmt (cognitive 40) crates/ruff_python_formatter/src/other/interpolated_string_element.rs:95 — FormatInterpolatedElement::fmt has cognitive complexity 40 (threshold 15). Drivers by points: if/else 16 (27 pts), loops 2 (5 pts), match/switch 3 (5 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AllMembers · ×1
  • AllMembers::extend_with_type (cognitive 40) crates/ty_python_semantic/src/types/list_members.rs:176 — AllMembers::extend_with_type has cognitive complexity 40 (threshold 15). Drivers by points: if/else 11 (24 pts), match/switch 6 (11 pts), boolean chains 3, loops 1 (2 pts) (nesting depth added 19). Of this number, 37 points are the body's own statements and 3 belong to one function item inside it that branches. The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ReFunc · ×1
  • ReFunc::from_call_expr (cognitive 39) crates/ruff_linter/src/rules/ruff/rules/unnecessary_regular_expression.rs:175 — ReFunc::from_call_expr has cognitive complexity 39 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 3 (10 pts), match/switch 3 (4 pts), boolean chains 3 (nesting depth added 24). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · PythonFilesVisitor · ×1
  • PythonFilesVisitor::visit (cognitive 39) crates/ruff_workspace/src/resolver.rs:650 — PythonFilesVisitor::visit has cognitive complexity 39 (threshold 15). Drivers by points: if/else 16 (29 pts), match/switch 3 (10 pts) (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NarrowingProjector · ×1
  • NarrowingProjector::project (cognitive 39) crates/ty_python_semantic/src/reachability.rs:1473 — NarrowingProjector::project has cognitive complexity 39 (threshold 15). Drivers by points: if/else 7 (19 pts), match/switch 4 (13 pts), boolean chains 6, loops 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SuppressionsBuilder · ×1
  • SuppressionsBuilder::load_from_tokens (cognitive 38) crates/ruff_linter/src/suppression.rs:752 — SuppressionsBuilder::load_from_tokens has cognitive complexity 38 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 3 (7 pts), match/switch 3 (6 pts), boolean chains 3 (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DisplaySpecialization · ×1
  • DisplaySpecialization::fmt_normal (cognitive 38) crates/ty_python_semantic/src/types/display.rs:2382 — DisplaySpecialization::fmt_normal has cognitive complexity 38 (threshold 15). Drivers by points: if/else 9 (30 pts), loops 2 (5 pts), match/switch 1 (3 pts) (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TruthinessAnalyzer · ×1
  • TruthinessAnalyzer::evaluate (cognitive 38) crates/ty_python_semantic/src/types/infer/expression_truthiness.rs:87 — TruthinessAnalyzer::evaluate has cognitive complexity 38 (threshold 15). Drivers by points: if/else 7 (18 pts), match/switch 6 (13 pts), boolean chains 5, loops 1 (2 pts) (nesting depth added 19). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · rule-filters.document$.subscribe() (cognitive 38) · ×1
  • rule-filters.document$.subscribe() (cognitive 38) docs/js/rule-filters.js:4 — rule-filters.document$.subscribe() has cognitive complexity 38 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 11, loops 9 (10 pts), ternaries 3 (4 pts) (nesting depth added 5). Most of this is not in the body itself: 8 of the 38 points are its own statements and the rest belongs to 11 function items inside it that branch (updateURL, a function literal at line 89, filter, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · GithubRenderer · ×1
  • GithubRenderer::render (cognitive 37) crates/ruff_db/src/diagnostic/render/github.rs:22 — GithubRenderer::render has cognitive complexity 37 (threshold 15). Drivers by points: if/else 12 (21 pts), loops 4 (8 pts), match/switch 2 (5 pts), boolean chains 3 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Terminal · ×1
  • Terminal::from_body (cognitive 37) crates/ruff_python_semantic/src/analyze/terminal.rs:49 — Terminal::from_body has cognitive complexity 37 (threshold 15). Drivers by points: if/else 13 (33 pts), match/switch 2 (3 pts), loops 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AbstractMethods · ×1
  • AbstractMethods::annotate_diagnostic (cognitive 37) crates/ty_python_semantic/src/types/abstract_methods.rs:42 — AbstractMethods::annotate_diagnostic has cognitive complexity 37 (threshold 15). Drivers by points: if/else 22 (33 pts), boolean chains 3, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DisplayUnionType · ×1
  • DisplayUnionType::fmt_detailed (cognitive 37) crates/ty_python_semantic/src/types/display.rs:3231 — DisplayUnionType::fmt_detailed has cognitive complexity 37 (threshold 15). Drivers by points: if/else 16 (26 pts), loops 5 (7 pts), boolean chains 2, match/switch 1 (2 pts) (nesting depth added 13). Of this number, 30 points are the body's own statements and 7 belong to one function item inside it that branches. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AddBinding · ×1
  • AddBinding::insert (cognitive 37) crates/ty_python_semantic/src/types/infer/builder.rs:13606 — AddBinding::insert has cognitive complexity 37 (threshold 15). Drivers by points: if/else 14 (28 pts), boolean chains 7, match/switch 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Unpacker · ×1
  • Unpacker::unpack_inner (cognitive 37) crates/ty_python_semantic/src/types/unpacker.rs:182 — Unpacker::unpack_inner has cognitive complexity 37 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 5 (13 pts), loops 4 (8 pts), boolean chains 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConciseRenderer · ×1
  • ConciseRenderer::render (cognitive 36) crates/ruff_db/src/diagnostic/render/concise.rs:20 — ConciseRenderer::render has cognitive complexity 36 (threshold 15). Drivers by points: if/else 15 (30 pts), match/switch 1 (3 pts), boolean chains 2, loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Collector · ×1
  • Collector::visit_stmt (cognitive 36) crates/ruff_graph/src/collector.rs:43 — Collector::visit_stmt has cognitive complexity 36 (threshold 15). Drivers by points: if/else 9 (24 pts), loops 4 (10 pts), boolean chains 1, match/switch 1 (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LinePreprocessor · ×1
  • LinePreprocessor::next (cognitive 36) crates/ruff_linter/src/rules/pycodestyle/rules/blank_lines.rs:430 — LinePreprocessor::next has cognitive complexity 36 (threshold 15). Drivers by points: if/else 12 (29 pts), boolean chains 3, match/switch 1 (3 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BodyVisitor · ×1
  • BodyVisitor::visit_stmt (cognitive 35) crates/ruff_linter/src/rules/pydoclint/rules/check_docstring.rs:980 — BodyVisitor::visit_stmt has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (24 pts), loops 2 (10 pts), match/switch 1 (nesting depth added 21). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · UselessSuppressionComments · ×1
  • UselessSuppressionComments::check_suppression_comment (cognitive 34) crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:129 — UselessSuppressionComments::check_suppression_comment has cognitive complexity 34 (threshold 15). Drivers by points: if/else 13 (30 pts), boolean chains 4 (nesting depth added 17). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ImportStatement · ×1
  • ImportStatement::detect (cognitive 34) crates/ty_ide/src/completion.rs:2698 — ImportStatement::detect has cognitive complexity 34 (threshold 15). Drivers by points: if/else 12 (20 pts), match/switch 4 (7 pts), boolean chains 5, loops 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Playground.Playground (cognitive 34) · ×1
  • Playground.Playground (cognitive 34) playground/ty/src/Playground.tsx:37 — Playground.Playground has cognitive complexity 34 (threshold 15). Drivers by points: if/else 16 (18 pts), error handling 2 (6 pts), boolean chains 5, ternaries 4, loops 1 (nesting depth added 6). Most of this is not in the body itself: 3 of the 34 points are its own statements and the rest belongs to 9 function literals inside it that branch (lines 145, 98, 221, …). The decisions are inside those literals, which nothing outside this body can call, review or test on its own, so splitting the enclosing body is not the move available here. To reduce it, lift the literals' work into a named function or method at the enclosing scope and have each literal call it, then reduce whichever part then reads as the largest.
D2 · Cognitive Complexity · LoopMutationsVisitor · ×1
  • LoopMutationsVisitor::visit_stmt (cognitive 33) crates/ruff_linter/src/rules/flake8_bugbear/rules/loop_iterator_mutation.rs:339 — LoopMutationsVisitor::visit_stmt has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (26 pts), loops 2 (4 pts), boolean chains 2, match/switch 1 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · KnownClass · ×1
  • KnownClass::check_call (cognitive 33) crates/ty_python_semantic/src/types/class/known.rs:2068 — KnownClass::check_call has cognitive complexity 33 (threshold 15). Drivers by points: if/else 8 (27 pts), match/switch 3 (6 pts) (nesting depth added 22). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · DocstringLinePrinter · ×1
  • DocstringLinePrinter::run_action_queue (cognitive 32) crates/ruff_python_formatter/src/string/docstring.rs:312 — DocstringLinePrinter::run_action_queue has cognitive complexity 32 (threshold 15). Drivers by points: loops 5 (16 pts), if/else 3 (11 pts), match/switch 2 (5 pts) (nesting depth added 22). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · ClassInfoConstraint · ×1
  • ClassInfoConstraint::generate_impl (cognitive 32) crates/ty_python_semantic/src/types/narrow.rs:568 — ClassInfoConstraint::generate_impl has cognitive complexity 32 (threshold 15). Drivers by points: if/else 10 (17 pts), match/switch 7 (14 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CommentRanges · ×1
  • CommentRanges::block_comments (cognitive 31) crates/ruff_python_trivia/src/comment_ranges.rs:157 — CommentRanges::block_comments has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (25 pts), boolean chains 5, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IsortOptions · ×1
  • IsortOptions::try_into_settings (cognitive 31) crates/ruff_workspace/src/options.rs:3059 — IsortOptions::try_into_settings has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (22 pts), boolean chains 4, loops 4, match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SpecializationFlowGraph · ×1
  • SpecializationFlowGraph::strongly_connected_parameter_components (cognitive 31) crates/ty_python_semantic/src/types/cyclic.rs:455 — SpecializationFlowGraph::strongly_connected_parameter_components has cognitive complexity 31 (threshold 15). Drivers by points: if/else 7 (20 pts), loops 6 (11 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BoundTypeVarInstance · ×1
  • BoundTypeVarInstance::apply_type_mapping_impl (cognitive 31) crates/ty_python_semantic/src/types/typevar.rs:1378 — BoundTypeVarInstance::apply_type_mapping_impl has cognitive complexity 31 (threshold 15). Drivers by points: if/else 19 (27 pts), boolean chains 3, match/switch 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ResolvedClientCapabilities · ×1
  • ResolvedClientCapabilities::new (cognitive 30) crates/ty_server/src/capabilities.rs:216 — ResolvedClientCapabilities::new has cognitive complexity 30 (threshold 15). Drivers by points: if/else 26 (30 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · SubscriptErrorKind · ×1
  • SubscriptErrorKind::report_diagnostic (cognitive 30) crates/ty_python_semantic/src/types/subscript.rs:294 — SubscriptErrorKind::report_diagnostic has cognitive complexity 30 (threshold 15). Drivers by points: if/else 12 (27 pts), match/switch 2 (3 pts) (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · StringNormalizer · ×1
  • StringNormalizer::preferred_quote_style (cognitive 29) crates/ruff_python_formatter/src/string/normalize.rs:44 — StringNormalizer::preferred_quote_style has cognitive complexity 29 (threshold 15). Drivers by points: if/else 14 (24 pts), boolean chains 4, match/switch 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Definitions · ×1
  • Definitions::resolve (cognitive 29) crates/ruff_python_semantic/src/definition.rs:217 — Definitions::resolve has cognitive complexity 29 (threshold 15). Drivers by points: if/else 8 (20 pts), match/switch 2 (5 pts), boolean chains 3, loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InlayHint · ×1
  • InlayHint::type_annotation (cognitive 29) crates/ty_ide/src/inlay_hints.rs:62 — InlayHint::type_annotation has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (25 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Debouncer · ×1
  • Debouncer::add_event (cognitive 29) crates/ty_project/src/watch/watcher.rs:214 — Debouncer::add_event has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 7 (14 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LoopBindingsVisitor · ×1
  • LoopBindingsVisitor::visit_stmt (cognitive 29) crates/ty_python_core/src/builder/loop_bindings_visitor.rs:66 — LoopBindingsVisitor::visit_stmt has cognitive complexity 29 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 7 (14 pts), match/switch 1 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ExportFinder · ×1
  • ExportFinder::visit_stmt (cognitive 29) crates/ty_python_core/src/re_exports.rs:181 — ExportFinder::visit_stmt has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 4 (11 pts), boolean chains 1, match/switch 1 (nesting depth added 16). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FormatExprSlice · ×1
  • FormatExprSlice::fmt_fields (cognitive 28) crates/ruff_python_formatter/src/expression/expr_slice.rs:17 — FormatExprSlice::fmt_fields has cognitive complexity 28 (threshold 15). Drivers by points: if/else 16 (22 pts), boolean chains 6 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MaybeParenthesizeExpression · ×1
  • MaybeParenthesizeExpression::fmt (cognitive 27) crates/ruff_python_formatter/src/expression/mod.rs:346 — MaybeParenthesizeExpression::fmt has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10 (17 pts), match/switch 5 (8 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ty_completion_eval · ×1
  • ty_completion_eval::main (cognitive 27) crates/ty_completion_eval/src/main.rs:126 — ty_completion_eval::main has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (19 pts), loops 3 (7 pts), match/switch 1 (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · VariableLengthTuple · ×1
  • VariableLengthTuple::mixed_forward_slice_plan (cognitive 27) crates/ty_python_semantic/src/types/tuple.rs:1833 — VariableLengthTuple::mixed_forward_slice_plan has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (20 pts), boolean chains 5, match/switch 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Tuple · ×1
  • Tuple::try_for_each_element_pair (cognitive 27) crates/ty_python_semantic/src/types/tuple.rs:2738 — Tuple::try_for_each_element_pair has cognitive complexity 27 (threshold 15). Drivers by points: loops 13 (26 pts), match/switch 1 (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Notebook · ×1
  • Notebook::from_raw_notebook (cognitive 26) crates/ruff_notebook/src/notebook.rs:127 — Notebook::from_raw_notebook has cognitive complexity 26 (threshold 15). Drivers by points: if/else 5 (13 pts), loops 3 (8 pts), match/switch 2 (4 pts), boolean chains 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FlatBinaryExpressionSlice · ×1
  • FlatBinaryExpressionSlice::fmt (cognitive 26) crates/ruff_python_formatter/src/expression/binary_like.rs:640 — FlatBinaryExpressionSlice::fmt has cognitive complexity 26 (threshold 15). Drivers by points: if/else 10 (19 pts), match/switch 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatExprAttribute · ×1
  • FormatExprAttribute::fmt_fields (cognitive 26) crates/ruff_python_formatter/src/expression/expr_attribute.rs:28 — FormatExprAttribute::fmt_fields has cognitive complexity 26 (threshold 15). Drivers by points: if/else 14 (16 pts), boolean chains 7, match/switch 1 (3 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · UnionElement · ×1
  • UnionElement::try_reduce (cognitive 26) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:484 — UnionElement::try_reduce has cognitive complexity 26 (threshold 15). Drivers by points: if/else 16 (20 pts), boolean chains 3, match/switch 2 (3 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ErrorAssertionParser · ×1
  • ErrorAssertionParser::parse (cognitive 25) crates/mdtest/src/assertion.rs:408 — ErrorAssertionParser::parse has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (22 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_formatter · ×1
  • ruff_formatter::buffer::clean_interned (cognitive 25) crates/ruff_formatter/src/buffer.rs:381 — ruff_formatter::buffer::clean_interned has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 3 (8 pts), loops 1 (3 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ReturnVisitor · ×1
  • ReturnVisitor::visit_stmt (cognitive 25) crates/ruff_linter/src/rules/flake8_return/visitor.rs:83 — ReturnVisitor::visit_stmt has cognitive complexity 25 (threshold 15). Drivers by points: if/else 6 (17 pts), loops 2 (4 pts), match/switch 2 (4 pts) (nesting depth added 15). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · TypingTarget · ×1
  • TypingTarget::try_from_expr (cognitive 25) crates/ruff_linter/src/rules/ruff/typing.rs:73 — TypingTarget::try_from_expr has cognitive complexity 25 (threshold 15). Drivers by points: if/else 18 (23 pts), boolean chains 1, match/switch 1 (nesting depth added 5). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FormatParameters · ×1
  • FormatParameters::fmt_fields (cognitive 25) crates/ruff_python_formatter/src/other/parameters.rs:51 — FormatParameters::fmt_fields has cognitive complexity 25 (threshold 15). Drivers by points: if/else 17 (20 pts), loops 3, boolean chains 2 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · StringParser · ×1
  • StringParser::parse_interpolated_string_middle (cognitive 25) crates/ruff_python_parser/src/string.rs:275 — StringParser::parse_interpolated_string_middle has cognitive complexity 25 (threshold 15). Drivers by points: if/else 7 (15 pts), match/switch 2 (7 pts), boolean chains 2, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PlaceFromDeclarationsResult · ×1
  • PlaceFromDeclarationsResult::with_imported_final_impl (cognitive 25) crates/ty_python_semantic/src/place.rs:952 — PlaceFromDeclarationsResult::with_imported_final_impl has cognitive complexity 25 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CallArguments · ×1
  • CallArguments::with_known_unpacking (cognitive 25) crates/ty_python_semantic/src/types/call/arguments.rs:595 — CallArguments::with_known_unpacking has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (22 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Signature · ×1
  • Signature::bind_self_with_receiver (cognitive 25) crates/ty_python_semantic/src/types/signatures.rs:1538 — Signature::bind_self_with_receiver has cognitive complexity 25 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 8, match/switch 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · CodeActions · ×1
  • CodeActions::run_with_snapshot (cognitive 24) crates/ruff_server/src/server/api/requests/code_action.rs:27 — CodeActions::run_with_snapshot has cognitive complexity 24 (threshold 15). Drivers by points: if/else 13 (19 pts), boolean chains 3, match/switch 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ty · ×1
  • ty::run_check (cognitive 24) crates/ty/src/lib.rs:95 — ty::run_check has cognitive complexity 24 (threshold 15). Drivers by points: if/else 19, boolean chains 3, match/switch 2. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · PendingReachability · ×1
  • PendingReachability::merge_place_states (cognitive 24) crates/ty_python_core/src/use_def.rs:2035 — PendingReachability::merge_place_states has cognitive complexity 24 (threshold 15). Drivers by points: if/else 8 (18 pts), match/switch 1 (3 pts), boolean chains 2, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · CodeActionRequestHandler · ×1
  • CodeActionRequestHandler::run_with_snapshot (cognitive 24) crates/ty_server/src/server/api/requests/code_action.rs:33 — CodeActionRequestHandler::run_with_snapshot has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 3 (8 pts), loops 2 (4 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · InlineFileAssertions · ×1
  • InlineFileAssertions::from_comment_ranges (cognitive 23) crates/mdtest/src/assertion.rs:92 — InlineFileAssertions::from_comment_ranges has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (19 pts), loops 2 (4 pts) (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UvEnvironments · ×1
  • UvEnvironments::poll_sync (cognitive 23) crates/ty_project/src/uv/environments.rs:318 — UvEnvironments::poll_sync has cognitive complexity 23 (threshold 15). Drivers by points: if/else 4 (11 pts), match/switch 4 (11 pts), loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BoundSuperError · ×1
  • BoundSuperError::report_diagnostic (cognitive 23) crates/ty_python_semantic/src/types/bound_super.rs:103 — BoundSuperError::report_diagnostic has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (19 pts), match/switch 2 (4 pts) (nesting depth added 13). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · DisplayParameter · ×1
  • DisplayParameter::fmt_detailed (cognitive 23) crates/ty_python_semantic/src/types/display.rs:2985 — DisplayParameter::fmt_detailed has cognitive complexity 23 (threshold 15). Drivers by points: if/else 8 (14 pts), match/switch 2 (7 pts), boolean chains 2 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · JunitRenderer · ×1
  • JunitRenderer::render (cognitive 22) crates/ruff_db/src/diagnostic/render/junit.rs:34 — JunitRenderer::render has cognitive complexity 22 (threshold 15). Drivers by points: if/else 7 (16 pts), loops 2 (5 pts), boolean chains 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FileNoqaDirectives · ×1
  • FileNoqaDirectives::extract (cognitive 22) crates/ruff_linter/src/noqa.rs:260 — FileNoqaDirectives::extract has cognitive complexity 22 (threshold 15). Drivers by points: if/else 3 (11 pts), loops 2 (5 pts), match/switch 2 (5 pts), boolean chains 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LoggerCandidateVisitor · ×1
  • LoggerCandidateVisitor::visit_expr (cognitive 22) crates/ruff_linter/src/rules/tryceratops/helpers.rs:26 — LoggerCandidateVisitor::visit_expr has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (20 pts), match/switch 1 (2 pts) (nesting depth added 15). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · SectionItem · ×1
  • SectionItem::render (cognitive 22) crates/ty_ide/src/docstring/markdown/structured.rs:252 — SectionItem::render has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (20 pts), match/switch 1 (2 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DisplayKnownInstanceRepr · ×1
  • DisplayKnownInstanceRepr::fmt_detailed (cognitive 22) crates/ty_python_semantic/src/types/display.rs:3892 — DisplayKnownInstanceRepr::fmt_detailed has cognitive complexity 22 (threshold 15). Drivers by points: if/else 12 (19 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SecondaryPanel.SecondaryPanel (cognitive 22) · ×1
  • SecondaryPanel.SecondaryPanel (cognitive 22) playground/ruff/src/Editor/SecondaryPanel.tsx:26 — SecondaryPanel.SecondaryPanel has cognitive complexity 22 (threshold 15). Drivers by points: if/else 9 (10 pts), match/switch 2 (5 pts), boolean chains 4, ternaries 1 (3 pts) (nesting depth added 6). Of this number, 14 points are the body's own statements and 8 belong to 5 function literals inside it that branch. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · Files.FileEntry (cognitive 22) · ×1
  • Files.FileEntry (cognitive 22) playground/ty/src/Editor/Files.tsx:138 — Files.FileEntry has cognitive complexity 22 (threshold 15). Drivers by points: ternaries 5 (11 pts), if/else 5 (6 pts), boolean chains 3, match/switch 1 (2 pts) (nesting depth added 8). Of this number, 14 points are the body's own statements and 8 belong to 3 function items inside it that branch. To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MemoryWalker · ×1
  • MemoryWalker::walk (cognitive 21) crates/ruff_db/src/system/memory_fs.rs:618 — MemoryWalker::walk has cognitive complexity 21 (threshold 15). Drivers by points: match/switch 4 (10 pts), if/else 2 (8 pts), loops 2 (3 pts) (nesting depth added 13). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Document · ×1
  • Document::propagate_expand::propagate_expands (cognitive 21) crates/ruff_formatter/src/format_element/document.rs:57 — Document::propagate_expand::propagate_expands has cognitive complexity 21 (threshold 15). Drivers by points: if/else 5 (12 pts), match/switch 3 (8 pts), loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SortClassification · ×1
  • SortClassification::of_elements (cognitive 21) crates/ruff_linter/src/rules/ruff/rules/sequence_sorting.rs:265 — SortClassification::of_elements has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (4 pts), match/switch 1 (4 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RuffSettingsIndex · ×1
  • RuffSettingsIndex::new (cognitive 21) crates/ruff_server/src/session/index/ruff_settings.rs:166 — RuffSettingsIndex::new has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (12 pts), match/switch 4 (7 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · Group · ×1
  • Group::merge (cognitive 21) crates/ty_ide/src/all_symbols.rs:381 — Group::merge has cognitive complexity 21 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (5 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Options · ×1
  • Options::to_search_paths (cognitive 21) crates/ty_project/src/metadata/options.rs:385 — Options::to_search_paths has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 4, match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DisplayCallableType · ×1
  • DisplayCallableType::fmt_detailed (cognitive 21) crates/ty_python_semantic/src/types/display.rs:2529 — DisplayCallableType::fmt_detailed has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OverloadLiteral · ×1
  • OverloadLiteral::raw_signature (cognitive 21) crates/ty_python_semantic/src/types/function.rs:614 — OverloadLiteral::raw_signature has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 6 (nesting depth added 2). Of this number, 14 points are the body's own statements and 7 belong to one function item inside it that branches. To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · AwaitError · ×1
  • AwaitError::report_diagnostic (cognitive 21) crates/ty_python_semantic/src/types.rs:12523 — AwaitError::report_diagnostic has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (16 pts), loops 1 (3 pts), boolean chains 1, match/switch 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SysPrefixPath · ×1
  • SysPrefixPath::from_executable_home_path_real (cognitive 21) crates/ty_site_packages/src/lib.rs:2094 — SysPrefixPath::from_executable_home_path_real has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ConfigArgumentParser · ×1
  • ConfigArgumentParser::parse_ref (cognitive 20) crates/ruff/src/args.rs:989 — ConfigArgumentParser::parse_ref has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (14 pts), match/switch 4 (6 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ExplicitConfigOverrides · ×1
  • ExplicitConfigOverrides::transform (cognitive 20) crates/ruff/src/args.rs:1412 — ExplicitConfigOverrides::transform has cognitive complexity 20 (threshold 15). Drivers by points: if/else 20. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · ruff_python_codegen · ×1
  • ruff_python_codegen::stylist::detect_indentation (cognitive 20) crates/ruff_python_codegen/src/stylist.rs:90 — ruff_python_codegen::stylist::detect_indentation has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (18 pts), loops 1 (2 pts) (nesting depth added 11). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Indentation · ×1
  • Indentation::trim_start (cognitive 20) crates/ruff_python_formatter/src/string/docstring.rs:1749 — Indentation::trim_start has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (16 pts), match/switch 3 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TyFormat · ×1
  • TyFormat::format_event (cognitive 20) crates/ty/src/logging.rs:220 — TyFormat::format_event has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 1 (3 pts), loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ContextCursor · ×1
  • ContextCursor::incomplete_keywords (cognitive 20) crates/ty_ide/src/completion.rs:1282 — ContextCursor::incomplete_keywords has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (9 pts), boolean chains 7, match/switch 4 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · NodeId · ×1
  • NodeId::is_never_satisfied_with_limits (cognitive 20) crates/ty_python_semantic/src/types/constraints.rs:2516 — NodeId::is_never_satisfied_with_limits has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), match/switch 2 (3 pts), boolean chains 2, loops 1 (nesting depth added 9). Most of this is not in the body itself: 6 of the 20 points are its own statements and the rest belongs to one function item inside it that branches (simple_conjunction_is_satisfiable). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · DisplayParameters · ×1
  • DisplayParameters::fmt_detailed::display_parameters (cognitive 20) crates/ty_python_semantic/src/types/display.rs:2817 — DisplayParameters::fmt_detailed::display_parameters has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 3, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ErrorContext · ×1
  • ErrorContext::render (cognitive 20) crates/ty_python_semantic/src/types/relation_error.rs:251 — ErrorContext::render has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 5 (8 pts), boolean chains 2 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · FormatCommandError · ×1
  • FormatCommandError::fmt (cognitive 19) crates/ruff/src/commands/format.rs:926 — FormatCommandError::fmt has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12 (18 pts), match/switch 1 (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · TokenFlags · ×1
  • TokenFlags::prefix (cognitive 19) crates/ruff_python_ast/src/token.rs:806 — TokenFlags::prefix has cognitive complexity 19 (threshold 15). Drivers by points: if/else 16 (19 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ProjectWatcher · ×1
  • ProjectWatcher::update_once (cognitive 19) crates/ty_project/src/watch/project_watcher.rs:70 — ProjectWatcher::update_once has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FieldMetadata · ×1
  • FieldMetadata::collect_from_annotation (cognitive 19) crates/ty_python_semantic/src/types/dedicated/pydantic.rs:194 — FieldMetadata::collect_from_annotation has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (15 pts), match/switch 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DisplayTuple · ×1
  • DisplayTuple::fmt_detailed (cognitive 19) crates/ty_python_semantic/src/types/display.rs:1890 — DisplayTuple::fmt_detailed has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SelectionRangeRequestHandler · ×1
  • SelectionRangeRequestHandler::run_with_snapshot (cognitive 19) crates/ty_server/src/server/api/requests/selection_range.rs:27 — SelectionRangeRequestHandler::run_with_snapshot has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (4 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · UnittestAssert · ×1
  • UnittestAssert::generate_assert (cognitive 18) crates/ruff_linter/src/rules/flake8_pytest_style/rules/unittest_assert.rs:280 — UnittestAssert::generate_assert has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (15 pts), match/switch 2 (3 pts) (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ExprSubscript · ×1
  • ExprSubscript::needs_parentheses (cognitive 18) crates/ruff_python_formatter/src/expression/expr_subscript.rs:84 — ExprSubscript::needs_parentheses has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (15 pts), match/switch 1 (2 pts), boolean chains 1 (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · QualifiedName · ×1
  • QualifiedName::fmt (cognitive 18) crates/ruff_python_ast/src/name.rs:424 — QualifiedName::fmt has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3 (6 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AnyStringFlags · ×1
  • AnyStringFlags::prefix (cognitive 18) crates/ruff_python_ast/src/nodes.rs:2543 — AnyStringFlags::prefix has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (18 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatBody · ×1
  • FormatBody::fmt (cognitive 18) crates/ruff_python_formatter/src/expression/expr_lambda.rs:261 — FormatBody::fmt has cognitive complexity 18 (threshold 15). Drivers by points: if/else 12 (16 pts), boolean chains 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FieldNamePart · ×1
  • FieldNamePart::parse_part (cognitive 18) crates/ruff_python_literal/src/format.rs:481 — FieldNamePart::parse_part has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (12 pts), loops 2 (4 pts), boolean chains 1, match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · InlayHintVisitor · ×1
  • InlayHintVisitor::visit_expr (cognitive 18) crates/ty_ide/src/inlay_hints.rs:579 — InlayHintVisitor::visit_expr has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (13 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (nesting depth added 10). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ModuleSearchCursor · ×1
  • ModuleSearchCursor::list_modules (cognitive 18) crates/ty_module_resolver/src/resolve/search.rs:216 — ModuleSearchCursor::list_modules has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (14 pts), loops 3 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OverrideOptions · ×1
  • OverrideOptions::lint (cognitive 18) crates/ty_project/src/metadata/options.rs:2128 — OverrideOptions::lint has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (16 pts), boolean chains 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PublicTypeBuilder · ×1
  • PublicTypeBuilder::add (cognitive 18) crates/ty_python_semantic/src/place.rs:2087 — PublicTypeBuilder::add has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 1, match/switch 1 (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ClassBase · ×1
  • ClassBase::try_from_type (cognitive 18) crates/ty_python_semantic/src/types/class_base.rs:145 — ClassBase::try_from_type has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), match/switch 4 (8 pts) (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · AmbiguousNameCollector · ×1
  • AmbiguousNameCollector::record (cognitive 18) crates/ty_python_semantic/src/types/display.rs:609 — AmbiguousNameCollector::record has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (15 pts), match/switch 2 (3 pts) (nesting depth added 11). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · CallableSignature · ×1
  • CallableSignature::apply_type_mapping_impl (cognitive 18) crates/ty_python_semantic/src/types/signatures.rs:321 — CallableSignature::apply_type_mapping_impl has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), loops 1 (2 pts), boolean chains 1, match/switch 1 (nesting depth added 5). Most of this is not in the body itself: 6 of the 18 points are its own statements and the rest belongs to one function item inside it that branches (try_apply_type_mapping_for_paramspec). Those helpers are already separate functions, so extracting the branching again is not available. To reduce it, move them out of the body to the enclosing scope, where each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D2 · Cognitive Complexity · TypedDictType · ×1
  • TypedDictType::openness::class_based_openness (cognitive 18) crates/ty_python_semantic/src/types/typed_dict.rs:277 — TypedDictType::openness::class_based_openness has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (14 pts), match/switch 2 (3 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_python_edits · ×1
  • ruff_python_edits::call::unwrapped_call_argument (cognitive 18) crates/ruff_python_edits/src/call.rs:18 — ruff_python_edits::call::unwrapped_call_argument has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 8, if/else 5 (7 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · FormatResults · ×1
  • FormatResults::to_diagnostics (cognitive 17) crates/ruff/src/commands/format.rs:676 — FormatResults::to_diagnostics has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (15 pts), boolean chains 1, match/switch 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AzureRenderer · ×1
  • AzureRenderer::render (cognitive 17) crates/ruff_db/src/diagnostic/render/azure.rs:22 — AzureRenderer::render has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (13 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SectionContexts · ×1
  • SectionContexts::from_docstring (cognitive 17) crates/ruff_linter/src/docstrings/sections.rs:156 — SectionContexts::from_docstring has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SuppressionParser · ×1
  • SuppressionParser::eat_codes (cognitive 17) crates/ruff_linter/src/suppression.rs:1313 — SuppressionParser::eat_codes has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (16 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ComparablePattern · ×1
  • ComparablePattern::eq (cognitive 17) crates/ruff_python_ast/src/comparable.rs:45 — ComparablePattern::eq has cognitive complexity 17 (threshold 15). Drivers by points: match/switch 9 (17 pts) (nesting depth added 8). To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · ClauseHeader · ×1
  • ClauseHeader::visit (cognitive 17) crates/ruff_python_formatter/src/statement/clause.rs:108 — ClauseHeader::visit has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 1 (2 pts), match/switch 1 (nesting depth added 8). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Insertion · ×1
  • Insertion::start_of_file (cognitive 17) crates/ruff_python_importer/src/insertion.rs:57 — Insertion::start_of_file has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (13 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ruff_python_parser · ×1
  • ruff_python_parser::lexer::keywords::find_multiplier (cognitive 17) crates/ruff_python_parser/src/lexer/keywords.rs:82 — ruff_python_parser::lexer::keywords::find_multiplier has cognitive complexity 17 (threshold 15). Drivers by points: loops 5 (9 pts), if/else 2 (8 pts) (nesting depth added 10). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
D2 · Cognitive Complexity · Resolver · ×1
  • Resolver::package_roots (cognitive 17) crates/ruff_workspace/src/resolver.rs:195 — Resolver::package_roots has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · IntervalIndex · ×1
  • IntervalIndex::intersecting_rev (cognitive 17) crates/ty_python_semantic/src/suppression.rs:913 — IntervalIndex::intersecting_rev has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (12 pts), boolean chains 2, match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SpecialFormType · ×1
  • SpecialFormType::in_type_expression (cognitive 17) crates/ty_python_semantic/src/types/special_form.rs:814 — SpecialFormType::in_type_expression has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 2, match/switch 1 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · TypeExpander · ×1
  • TypeExpander::expand (cognitive 17) crates/ty_python_semantic/src/types/type_expansion.rs:77 — TypeExpander::expand has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), match/switch 3 (6 pts) (nesting depth added 9). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · Diagnostics · ×1
  • Diagnostics::to_lsp_diagnostics (cognitive 17) crates/ty_server/src/server/api/diagnostics.rs:108 — Diagnostics::to_lsp_diagnostics has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (11 pts), loops 3 (6 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · PythonEnvironmentPath · ×1
  • PythonEnvironmentPath::new (cognitive 17) crates/ty_site_packages/src/lib.rs:1947 — PythonEnvironmentPath::new has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4, match/switch 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ruff_benchmark · ×1
  • ruff_benchmark::real_world_projects::copy_directory_recursive (cognitive 16) crates/ruff_benchmark/src/real_world_projects.rs:217 — ruff_benchmark::real_world_projects::copy_directory_recursive has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 2, loops 1 (2 pts), match/switch 1 (2 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TypingReference · ×1
  • TypingReference::from_references (cognitive 16) crates/ruff_linter/src/rules/flake8_type_checking/helpers.rs:45 — TypingReference::from_references has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, loops 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SequenceIndexVisitor · ×1
  • SequenceIndexVisitor::visit_expr (cognitive 16) crates/ruff_linter/src/rules/pylint/helpers.rs:151 — SequenceIndexVisitor::visit_expr has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (16 pts) (nesting depth added 10). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · CodeDiff · ×1
  • CodeDiff::fmt (cognitive 16) crates/ruff_linter/src/source_kind.rs:316 — CodeDiff::fmt has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (10 pts), loops 2 (3 pts), match/switch 1 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AnyNodeRef · ×1
  • AnyNodeRef::last_child_in_body (cognitive 16) crates/ruff_python_ast/src/node.rs:590 — AnyNodeRef::last_child_in_body has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (15 pts), match/switch 1 (nesting depth added 7). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · SideEffect · ×1
  • SideEffect::from_expr (cognitive 16) crates/ruff_python_ast/src/helpers.rs:74 — SideEffect::from_expr has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 1, match/switch 1 (nesting depth added 6). The drivers above price the dispatch low by construction — a dispatch is charged once however many cases it lists, while each branch inside an arm is charged in full — so most of this count is what the case bodies hold, and the arms are where it can be reduced. To reduce it, keep the dispatch but shrink the arms: move each non-trivial case body into its own named function (or onto the value being matched) so the dispatch reads one line per case, and group related cases into a sub-dispatch. Keep every case explicit, and make the behaviour for cases you do not list a deliberate choice rather than an accident.
D2 · Cognitive Complexity · CallChainLayout · ×1
  • CallChainLayout::from_expression (cognitive 16) crates/ruff_python_formatter/src/expression/mod.rs:978 — CallChainLayout::from_expression has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (12 pts), match/switch 1 (2 pts), boolean chains 1, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · NarrowRange · ×1
  • NarrowRange::enter_node (cognitive 16) crates/ruff_python_formatter/src/range.rs:370 — NarrowRange::enter_node has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (6 pts), loops 2 (6 pts), boolean chains 3, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · TriviaRanges · ×1
  • TriviaRanges::from (cognitive 16) crates/ruff_python_ast/src/token/tokens.rs:304 — TriviaRanges::from has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (13 pts), match/switch 1 (2 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Relevance · ×1
  • Relevance::new (cognitive 16) crates/ty_ide/src/completion.rs:1861 — Relevance::new has cognitive complexity 16 (threshold 15). Drivers by points: if/else 14, boolean chains 2. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · PackageName · ×1
  • PackageName::new (cognitive 16) crates/ty_project/src/metadata/pyproject.rs:205 — PackageName::new has cognitive complexity 16 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 1, loops 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DynamicClassLiteral · ×1
  • DynamicClassLiteral::try_metaclass (cognitive 16) crates/ty_python_semantic/src/types/class/dynamic_literal.rs:287 — DynamicClassLiteral::try_metaclass has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 1, match/switch 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Constrained · ×1
  • Constrained::preferred_constraint (cognitive 16) crates/ty_python_semantic/src/types/constraints/solutions.rs:2063 — Constrained::preferred_constraint has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (8 pts), loops 2 (3 pts), match/switch 1 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · VarianceComponent · ×1
  • VarianceComponent::solution (cognitive 16) crates/ty_python_semantic/src/types/variance/equations.rs:245 — VarianceComponent::solution has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (9 pts), loops 4 (7 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Pool · ×1
  • Pool::new (cognitive 16) crates/ty_server/src/server/schedule/thread/pool.rs:47 — Pool::new has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 2 (3 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Editor.Editor (cognitive 16) · ×1
  • Editor.Editor (cognitive 16) playground/ruff/src/Editor/Editor.tsx:53 — Editor.Editor has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8, boolean chains 4, error handling 2, match/switch 1, ternaries 1. Most of this is not in the body itself: 4 of the 16 points are its own statements and the rest belongs to 6 function items inside it that branch (handleSecondaryToolSelected, a function literal at line 175, a function literal at line 62, …). The named helpers are already separate functions; the literals' work cannot be called, reviewed or tested from outside this body. To reduce it, move the named helpers out of the body to the enclosing scope and lift each literal's work into a named function there, so each is measured, reviewed and tested on its own, and reduce whichever one then reads as the largest.
D30 · Dependency Vulnerabilities · Medium vulnerability · ×1
  • REDACTED
D30 · Dependency Vulnerabilities · Medium advisory (unsound) · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D4 · Code Duplication · Near-duplicate member family (6 members, 32 shared lines) · ×1
  • Near-duplicate member family (6 members, 32 shared lines) crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:50 — crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:50-97 | crates/ruff_linter/src/rules/pylint/rules/invalid_bytes_return.rs:50-96 | crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs:54-101 | crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs:56-103 | crates/ruff_linter/src/rules/pylint/rules/invalid_length_return.rs:55-104 | crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs:50-96 — These 6 members are variants of one another: a block of 32 lines reported below appears in every one of them, and the pairwise near-duplicate rows they would otherwise produce are collapsed into this row. Read them as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Near-duplicate member pair (239 shared lines) · ×1
  • Near-duplicate member pair (239 shared lines) crates/ruff_python_ast/src/visitor.rs:362 — crates/ruff_python_ast/src/visitor.rs:362-631 | crates/ruff_python_ast/src/visitor/transformer.rs:349-627 — These two members are variants of one another: 239 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (68 shared lines) · ×1
  • Near-duplicate member pair (68 shared lines) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:87 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:87-312 | crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:99-367 — These two members are variants of one another: 68 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (57 shared lines) · ×1
  • Near-duplicate member pair (57 shared lines) crates/ruff_server/src/server/schedule/thread/pool.rs:48 — crates/ruff_server/src/server/schedule/thread/pool.rs:48-109 | crates/ty_server/src/server/schedule/thread/pool.rs:47-112 — These two members are variants of one another: 57 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (52 shared lines) · ×1
  • Near-duplicate member pair (52 shared lines) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:322 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:322-471 | crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:376-505 — These two members are variants of one another: 52 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Near-duplicate member pair (33 shared lines) · ×1
  • Near-duplicate member pair (33 shared lines) crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:99 — crates/ruff_linter/src/rules/pyupgrade/rules/os_error_alias.rs:99-160 | crates/ruff_linter/src/rules/pyupgrade/rules/timeout_error_alias.rs:125-182 — These two members are variants of one another: 33 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Members sharing a duplicated core (13 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (13 members, 50+ identical tokens) crates/ty_server/src/server/api/requests/completion.rs:42 — crates/ty_server/src/server/api/requests/completion.rs:42-171 | crates/ty_server/src/server/api/requests/doc_highlights.rs:31-75 | crates/ty_server/src/server/api/requests/goto_declaration.rs:30-74 | crates/ty_server/src/server/api/requests/goto_definition.rs:31-75 | crates/ty_server/src/server/api/requests/goto_implementation.rs:30-74 | crates/ty_server/src/server/api/requests/goto_type_definition.rs:31-75 | crates/ty_server/src/server/api/requests/hover.rs:30-77 | crates/ty_server/src/server/api/requests/prepare_call_hierarchy.rs:39-74 | crates/ty_server/src/server/api/requests/prepare_rename.rs:30-63 | crates/ty_server/src/server/api/requests/prepare_type_hierarchy.rs:40-70 | crates/ty_server/src/server/api/requests/references.rs:31-66 | crates/ty_server/src/server/api/requests/rename.rs:32-74 | crates/ty_server/src/server/api/requests/signature_help.rs:33-150 — These 13 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 13 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 13 times.
D4 · Code Duplication · Members sharing a duplicated core (9 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (9 members, 50+ identical tokens) crates/ty_python_semantic/src/types.rs:9815 — crates/ty_python_semantic/src/types.rs:9815-9886 | crates/ty_python_semantic/src/types.rs:10124-10409 | crates/ty_python_semantic/src/types.rs:10437-10776 | crates/ty_python_semantic/src/types/infer/comparisons.rs:84-550 | crates/ty_python_semantic/src/types/method.rs:426-468 | crates/ty_python_semantic/src/types/method.rs:477-534 | crates/ty_python_semantic/src/types/method.rs:537-566 | crates/ty_python_semantic/src/types/method.rs:878-1032 | crates/ty_python_semantic/src/types/relation.rs:323-395 — These 9 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 9 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 9 times.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (6 members, 50+ identical tokens) crates/ty_python_semantic/src/types/infer/builder.rs:5783 — crates/ty_python_semantic/src/types/infer/builder.rs:5783-5921 | crates/ty_python_semantic/src/types/infer/builder.rs:11713-11939 | crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:478-1214 | crates/ty_python_semantic/src/types/infer/comparisons.rs:84-550 | crates/ty_python_semantic/src/types/narrow.rs:5564-5614 | crates/ty_python_semantic/src/types/typed_dict.rs:1928-2121 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Edited copy of a member (65 corresponding lines) · ×1
  • Edited copy of a member (65 corresponding lines) crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:206 — crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/space_around_operator.rs:206-270 | crates/ruff_linter/src/rules/pycodestyle/rules/logical_lines/whitespace_around_keywords.rs:131-197 — These two members are one piece of code written twice and then edited apart: 65 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (58 corresponding lines) · ×1
  • Edited copy of a member (58 corresponding lines) crates/ruff_python_parser/src/string.rs:371 — crates/ruff_python_parser/src/string.rs:371-439 | crates/ruff_python_parser/src/string.rs:441-498 — These two members are one piece of code written twice and then edited apart: 58 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (81 corresponding lines) · ×1
  • Edited copy of a member (81 corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:3804 — crates/ty_python_semantic/src/types/infer/builder.rs:3804-3884 | crates/ty_python_semantic/src/types/infer/builder.rs:4221-4308 — These two members are one piece of code written twice and then edited apart: 81 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (70 corresponding lines) · ×1
  • Edited copy of a member (70 corresponding lines) crates/ruff_linter/src/fix/mod.rs:57 — crates/ruff_linter/src/fix/mod.rs:57-128 | crates/ty_python_semantic/src/fixes.rs:509-578 — These two members are one piece of code written twice and then edited apart: 70 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (64 corresponding lines) · ×1
  • Edited copy of a member (64 corresponding lines) crates/ty_python_semantic/src/types/constraints/variables.rs:220 — crates/ty_python_semantic/src/types/constraints/variables.rs:220-296 | crates/ty_python_semantic/src/types/constraints/variables.rs:309-372 — These two members are one piece of code written twice and then edited apart: 64 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (71 corresponding lines) · ×1
  • Edited copy of a member (71 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:76 — crates/ruff_linter/src/rules/pylint/rules/too_many_arguments.rs:76-146 | crates/ruff_linter/src/rules/pylint/rules/too_many_positional_arguments.rs:77-150 — These two members are one piece of code written twice and then edited apart: 71 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (72 corresponding lines) · ×1
  • Edited copy of a member (72 corresponding lines) crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs:79 — crates/ruff_linter/src/rules/mccabe/rules/function_is_too_complex.rs:79-165 | crates/ruff_linter/src/rules/pylint/helpers.rs:332-403 — These two members are one piece of code written twice and then edited apart: 72 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (59 corresponding lines) · ×1
  • Edited copy of a member (59 corresponding lines) crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs:61 — crates/ruff_linter/src/rules/flake8_pyi/rules/duplicate_literal_member.rs:61-119 | crates/ruff_linter/src/rules/ruff/rules/unnecessary_nested_literal.rs:80-141 — These two members are one piece of code written twice and then edited apart: 59 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (60 corresponding lines) · ×1
  • Edited copy of a member (60 corresponding lines) crates/ruff_python_formatter/src/other/arguments.rs:17 — crates/ruff_python_formatter/src/other/arguments.rs:17-114 | crates/ruff_python_formatter/src/pattern/pattern_arguments.rs:13-72 — These two members are one piece of code written twice and then edited apart: 60 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (55 corresponding lines) · ×1
  • Edited copy of a member (55 corresponding lines) crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs:73 — crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_period.rs:73-127 | crates/ruff_linter/src/rules/pydocstyle/rules/ends_with_punctuation.rs:67-121 — These two members are one piece of code written twice and then edited apart: 55 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (47 corresponding lines) · ×1
  • Edited copy of a member (47 corresponding lines) crates/ruff_linter/src/rules/airflow/helpers.rs:85 — crates/ruff_linter/src/rules/airflow/helpers.rs:85-131 | crates/ruff_linter/src/rules/numpy/rules/numpy_2_0_deprecation.rs:758-804 — These two members are one piece of code written twice and then edited apart: 47 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (40 corresponding lines) · ×1
  • Edited copy of a member (40 corresponding lines) crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:72 — crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:72-112 | crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs:75-114 — These two members are one piece of code written twice and then edited apart: 40 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (35 corresponding lines) · ×1
  • Edited copy of a member (35 corresponding lines) crates/ty_module_resolver/src/resolve.rs:584 — crates/ty_module_resolver/src/resolve.rs:584-633 | crates/ty_module_resolver/src/resolve.rs:653-687 — These two members are one piece of code written twice and then edited apart: 35 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (50 corresponding lines) · ×1
  • Edited copy of a member (50 corresponding lines) crates/ty_python_semantic/src/types/list_members.rs:37 — crates/ty_python_semantic/src/types/list_members.rs:37-86 | crates/ty_python_semantic/src/types/list_members.rs:93-144 — These two members are one piece of code written twice and then edited apart: 50 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 24+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 24+ corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:2031 — crates/ty_python_semantic/src/types/constraints/sequents.rs:2031-2054 | crates/ty_python_semantic/src/types/constraints/sequents.rs:2063-2091 | crates/ty_python_semantic/src/types/constraints/sequents.rs:2114-2142 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 24 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 30+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 30+ corresponding lines) crates/ruff_python_formatter/src/comments/map.rs:75 — crates/ruff_python_formatter/src/comments/map.rs:75-106 | crates/ruff_python_formatter/src/comments/map.rs:112-143 | crates/ruff_python_formatter/src/comments/map.rs:149-178 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 30 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (5 members, 46+ corresponding lines) · ×1
  • Edited copies of one member (5 members, 46+ corresponding lines) crates/ty_python_semantic/src/types/set_theoretic.rs:569 — crates/ty_python_semantic/src/types/set_theoretic.rs:569-618 | crates/ty_python_semantic/src/types/set_theoretic.rs:625-681 | crates/ty_python_semantic/src/types/set_theoretic.rs:1378-1423 | crates/ty_python_semantic/src/types/set_theoretic.rs:1430-1483 | crates/ty_python_semantic/src/types/typevar.rs:2334-2385 — These 5 members are one piece of code written 5 times and then edited apart: every two of them correspond over at least 46 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 5 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 35+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 35+ corresponding lines) crates/ty_python_semantic/src/types/relation.rs:638 — crates/ty_python_semantic/src/types/relation.rs:638-679 | crates/ty_python_semantic/src/types/relation.rs:718-757 | crates/ty_python_semantic/src/types/relation.rs:1016-1050 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 35 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 18+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 18+ corresponding lines) crates/ty_python_semantic/src/types/class/known.rs:1247 — crates/ty_python_semantic/src/types/class/known.rs:1247-1277 | crates/ty_python_semantic/src/types/set_theoretic.rs:145-163 | crates/ty_python_semantic/src/types/set_theoretic.rs:1165-1182 | crates/ty_python_semantic/src/types/set_theoretic.rs:1191-1209 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 18 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (49 corresponding lines) · ×1
  • Edited copy of a member (49 corresponding lines) crates/ruff_linter/src/suppression.rs:1069 — crates/ruff_linter/src/suppression.rs:1069-1117 | crates/ty_python_semantic/src/suppression.rs:761-818 — These two members are one piece of code written twice and then edited apart: 49 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 34+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 34+ corresponding lines) crates/ty_python_semantic/src/types/infer/builder.rs:8715 — crates/ty_python_semantic/src/types/infer/builder.rs:8715-8748 | crates/ty_python_semantic/src/types/infer/builder.rs:8754-8787 | crates/ty_python_semantic/src/types/infer/builder.rs:8793-8827 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 34 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copy of a member (39 corresponding lines) · ×1
  • Edited copy of a member (39 corresponding lines) crates/ruff_linter/src/rules/ruff/rules/suppression_comment_visitor.rs:70 — crates/ruff_linter/src/rules/ruff/rules/suppression_comment_visitor.rs:70-108 | crates/ruff_python_formatter/src/comments/visitor.rs:73-112 — These two members are one piece of code written twice and then edited apart: 39 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copies of one member (9 members, 28+ corresponding lines) · ×1
  • Edited copies of one member (9 members, 28+ corresponding lines) crates/ty_python_semantic/src/types/constraints/sequents.rs:953 — crates/ty_python_semantic/src/types/constraints/sequents.rs:953-983 | crates/ty_python_semantic/src/types/constraints/sequents.rs:991-1021 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1160-1187 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1195-1222 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1230-1257 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1265-1292 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1300-1327 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1335-1362 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1370-1397 — These 9 members are one piece of code written 9 times and then edited apart: every two of them correspond over at least 28 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 9 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 21+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 21+ corresponding lines) crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:81 — crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_fromtimestamp.rs:81-104 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_now_without_tzinfo.rs:79-99 | crates/ruff_linter/src/rules/flake8_datetimez/rules/call_datetime_without_tzinfo.rs:78-98 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 21 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 26+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 26+ corresponding lines) crates/ty_python_semantic/src/types/infer.rs:427 — crates/ty_python_semantic/src/types/infer.rs:427-453 | crates/ty_python_semantic/src/types/infer.rs:547-572 | crates/ty_python_semantic/src/types/infer.rs:652-680 | crates/ty_python_semantic/src/types/infer.rs:775-801 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 26 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 19+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 19+ corresponding lines) crates/ty_wasm/src/lib.rs:325 — crates/ty_wasm/src/lib.rs:325-344 | crates/ty_wasm/src/lib.rs:351-369 | crates/ty_wasm/src/lib.rs:376-394 | crates/ty_wasm/src/lib.rs:782-805 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 19 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 22+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 22+ corresponding lines) crates/ty_ide/src/call_hierarchy/incoming_calls.rs:174 — crates/ty_ide/src/call_hierarchy/incoming_calls.rs:174-195 | crates/ty_ide/src/references.rs:253-281 | crates/ty_ide/src/references.rs:315-336 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 22 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 18+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 18+ corresponding lines) crates/ruff_python_ast/src/comparable.rs:485 — crates/ruff_python_ast/src/comparable.rs:485-502 | crates/ruff_python_ast/src/comparable.rs:1647-1668 | crates/ruff_python_ast/src/comparable.rs:1679-1696 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 18 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 12+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 12+ corresponding lines) crates/ty_python_semantic/src/types/class.rs:1260 — crates/ty_python_semantic/src/types/class.rs:1260-1271 | crates/ty_python_semantic/src/types/class.rs:1279-1300 | crates/ty_python_semantic/src/types/class.rs:2609-2620 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 15+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 15+ corresponding lines) crates/ty_python_semantic/src/types/generics.rs:1650 — crates/ty_python_semantic/src/types/generics.rs:1650-1665 | crates/ty_python_semantic/src/types/relation.rs:904-924 | crates/ty_python_semantic/src/types/relation.rs:1124-1142 | crates/ty_python_semantic/src/types/relation.rs:1179-1197 | crates/ty_python_semantic/src/types/signatures.rs:643-657 | crates/ty_python_semantic/src/types/signatures.rs:2491-2505 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 15 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 11+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 11+ corresponding lines) crates/ty_python_core/src/builder.rs:5904 — crates/ty_python_core/src/builder.rs:5904-5919 | crates/ty_python_core/src/builder.rs:5921-5939 | crates/ty_python_core/src/builder.rs:5941-5951 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 17+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 17+ corresponding lines) crates/ruff_server/src/server/api.rs:303 — crates/ruff_server/src/server/api.rs:303-319 | crates/ruff_server/src/server/api.rs:356-375 | crates/ty_server/src/server/api.rs:501-517 | crates/ty_server/src/server/api.rs:551-570 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 17 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (6 members, 11+ corresponding lines) · ×1
  • Edited copies of one member (6 members, 11+ corresponding lines) crates/ty_python_semantic/src/types/constraints.rs:1401 — crates/ty_python_semantic/src/types/constraints.rs:1401-1412 | crates/ty_python_semantic/src/types/constraints.rs:1439-1450 | crates/ty_python_semantic/src/types/constraints.rs:1493-1503 | crates/ty_python_semantic/src/types/constraints.rs:1535-1545 | crates/ty_python_semantic/src/types/constraints.rs:1547-1558 | crates/ty_python_semantic/src/types/constraints.rs:1560-1571 — These 6 members are one piece of code written 6 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 6 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 13+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 13+ corresponding lines) crates/ruff_python_ast/src/nodes.rs:2609 — crates/ruff_python_ast/src/nodes.rs:2609-2621 | crates/ruff_python_ast/src/nodes.rs:2631-2643 | crates/ruff_python_ast/src/nodes.rs:2653-2665 | crates/ruff_python_ast/src/nodes.rs:2675-2687 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 13 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 7+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 7+ corresponding lines) crates/ruff_python_formatter/src/comments/map.rs:220 — crates/ruff_python_formatter/src/comments/map.rs:220-226 | crates/ruff_python_formatter/src/comments/map.rs:229-235 | crates/ruff_python_formatter/src/comments/map.rs:238-244 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 7 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 11+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 11+ corresponding lines) crates/ty_python_semantic/src/types/class/dynamic_literal.rs:245 — crates/ty_python_semantic/src/types/class/dynamic_literal.rs:245-255 | crates/ty_python_semantic/src/types/class/enum_literal.rs:172-182 | crates/ty_python_semantic/src/types/class/named_tuple.rs:220-231 | crates/ty_python_semantic/src/types/class/typed_dict.rs:949-959 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 11 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (4 members, 10+ corresponding lines) · ×1
  • Edited copies of one member (4 members, 10+ corresponding lines) crates/ty_python_semantic/src/types/diagnostic.rs:3888 — crates/ty_python_semantic/src/types/diagnostic.rs:3888-3899 | crates/ty_python_semantic/src/types/diagnostic.rs:3922-3933 | crates/ty_python_semantic/src/types/diagnostic.rs:4831-4840 | crates/ty_python_semantic/src/types/diagnostic.rs:4847-4856 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 10 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 9+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 9+ corresponding lines) crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs:102 — crates/ruff_linter/src/rules/flake8_bugbear/rules/duplicate_exceptions.rs:102-110 | crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1258-1267 | crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_builtin_import.rs:52-61 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 9 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Edited copies of one member (3 members, 4+ corresponding lines) · ×1
  • Edited copies of one member (3 members, 4+ corresponding lines) crates/ty_python_semantic/src/types/class.rs:1612 — crates/ty_python_semantic/src/types/class.rs:1612-1615 | crates/ty_python_semantic/src/types/class/dynamic_literal.rs:263-266 | crates/ty_python_semantic/src/types/class/static_literal.rs:1294-1297 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 4 lines, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below: the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain. Factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication · Duplicated block (217 lines × 2) · ×1
  • Duplicated block (217 lines × 2) crates/ruff_python_ast/src/visitor.rs:136 — crates/ruff_python_ast/src/visitor.rs:136-352 | crates/ruff_python_ast/src/visitor/transformer.rs:123-339 — before extracting anything, compare `crates/ruff_python_ast/src/visitor.rs` and `crates/ruff_python_ast/src/visitor/transformer.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (152 lines × 2) · ×1
  • Duplicated block (152 lines × 2) crates/ruff_python_ast/src/visitor.rs:363 — crates/ruff_python_ast/src/visitor.rs:363-514 | crates/ruff_python_ast/src/visitor/transformer.rs:350-501 — before extracting anything, compare `crates/ruff_python_ast/src/visitor.rs` and `crates/ruff_python_ast/src/visitor/transformer.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/visitor.rs:363` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (77 lines × 2) · ×1
  • Duplicated block (77 lines × 2) crates/ruff_python_ast/src/visitor.rs:555 — crates/ruff_python_ast/src/visitor.rs:555-631 | crates/ruff_python_ast/src/visitor/transformer.rs:551-627 — before extracting anything, compare `crates/ruff_python_ast/src/visitor.rs` and `crates/ruff_python_ast/src/visitor/transformer.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/visitor.rs:555` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (40 lines × 2) · ×1
  • Duplicated block (40 lines × 2) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:598 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:598-637 | crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:656-695 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/ast_bool_op.rs:598` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (37–40 lines × 2) · ×1
  • Duplicated block (37–40 lines × 2) crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs:186 — crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs:186-222 | crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs:226-265 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_encode_utf8.rs:186` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (39 lines × 2) · ×1
  • Duplicated block (39 lines × 2) crates/ty_python_semantic/src/types/infer/builder/subscript.rs:843 — crates/ty_python_semantic/src/types/infer/builder/subscript.rs:843-881 | crates/ty_python_semantic/src/types/infer/builder/subscript.rs:931-969 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (31–38 lines × 2) · ×1
  • Duplicated block (31–38 lines × 2) crates/ruff_python_semantic/src/analyze/terminal.rs:193 — crates/ruff_python_semantic/src/analyze/terminal.rs:193-230 | crates/ruff_python_semantic/src/analyze/terminal.rs:251-281 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_semantic/src/analyze/terminal.rs:193` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (37 lines × 2) · ×1
  • Duplicated block (37 lines × 2) crates/ruff_python_ast/src/visitor.rs:708 — crates/ruff_python_ast/src/visitor.rs:708-744 | crates/ruff_python_ast/src/visitor/transformer.rs:722-758 — before extracting anything, compare `crates/ruff_python_ast/src/visitor.rs` and `crates/ruff_python_ast/src/visitor/transformer.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (36–37 lines × 2) · ×1
  • Duplicated block (36–37 lines × 2) crates/ruff_python_formatter/src/verbatim.rs:284 — crates/ruff_python_formatter/src/verbatim.rs:284-319 | crates/ruff_python_formatter/src/verbatim.rs:363-399 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/verbatim.rs:284` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (35 lines × 4) · ×1
  • Duplicated block (35 lines × 4) crates/ty_python_semantic/src/types/set_theoretic/builder.rs:880 — crates/ty_python_semantic/src/types/set_theoretic/builder.rs:880-914 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:937-971 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:996-1030 | crates/ty_python_semantic/src/types/set_theoretic/builder.rs:1075-1109 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/set_theoretic/builder.rs:880` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (35 lines × 2) · ×1
  • Duplicated block (35 lines × 2) crates/ruff_python_ast/src/visitor.rs:755 — crates/ruff_python_ast/src/visitor.rs:755-789 | crates/ruff_python_ast/src/visitor/transformer.rs:769-803 — before extracting anything, compare `crates/ruff_python_ast/src/visitor.rs` and `crates/ruff_python_ast/src/visitor/transformer.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 538 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (33–34 lines × 3) · ×1
  • Duplicated block (33–34 lines × 3) crates/ty_python_semantic/src/types/signatures.rs:3571 — crates/ty_python_semantic/src/types/signatures.rs:3571-3603 | crates/ty_python_semantic/src/types/signatures.rs:3764-3796 | crates/ty_python_semantic/src/types/signatures.rs:3936-3969 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3571` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (17–33 lines × 2) · ×1
  • Duplicated block (17–33 lines × 2) crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1594 — crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1594-1610 | crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1677-1709 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pydocstyle/rules/sections.rs:1594` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (33 lines × 2) · ×1
  • Duplicated block (33 lines × 2) crates/ty_ide/src/goto.rs:550 — crates/ty_ide/src/goto.rs:550-582 | crates/ty_ide/src/goto.rs:821-853 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_ide/src/goto.rs:550` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (30–32 lines × 2) · ×1
  • Duplicated block (30–32 lines × 2) crates/ty_python_semantic/src/types.rs:8548 — crates/ty_python_semantic/src/types.rs:8548-8579 | crates/ty_python_semantic/src/types.rs:8597-8626 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types.rs:8548` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (31 lines × 2) · ×1
  • Duplicated block (31 lines × 2) crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:73 — crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:73-103 | crates/ruff_linter/src/rules/flake8_async/rules/long_sleep_not_forever.rs:66-96 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (26–31 lines × 2) · ×1
  • Duplicated block (26–31 lines × 2) crates/ruff_linter/src/rules/isort/order.rs:59 — crates/ruff_linter/src/rules/isort/order.rs:59-84 | crates/ruff_linter/src/rules/isort/order.rs:197-227 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/isort/order.rs:197` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (28–31 lines × 2) · ×1
  • Duplicated block (28–31 lines × 2) crates/ruff_python_formatter/src/statement/stmt_assign.rs:387 — crates/ruff_python_formatter/src/statement/stmt_assign.rs:387-414 | crates/ruff_python_formatter/src/statement/stmt_assign.rs:473-503 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_assign.rs:387` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (30–31 lines × 2) · ×1
  • Duplicated block (30–31 lines × 2) crates/ruff_python_formatter/src/statement/stmt_assign.rs:816 — crates/ruff_python_formatter/src/statement/stmt_assign.rs:816-846 | crates/ruff_python_formatter/src/statement/stmt_assign.rs:957-986 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/statement/stmt_assign.rs:816` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (29 lines × 3) · ×1
  • Duplicated block (29 lines × 3) crates/ruff_linter/src/linter.rs:372 — crates/ruff_linter/src/linter.rs:372-400 | crates/ruff_linter/src/linter.rs:441-469 | crates/ruff_linter/src/linter.rs:551-579 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/linter.rs:372` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (26–28 lines × 2) · ×1
  • Duplicated block (26–28 lines × 2) crates/ruff_linter/src/suppression.rs:1092 — crates/ruff_linter/src/suppression.rs:1092-1117 | crates/ty_python_semantic/src/suppression.rs:791-818 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/suppression.rs:1092` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (25–27 lines × 2) · ×1
  • Duplicated block (25–27 lines × 2) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:255 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:255-279 | crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:314-340 — before extracting anything, compare `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs` and `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:255` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–26 lines × 3) · ×1
  • Duplicated block (22–26 lines × 3) crates/ruff_python_parser/src/parser/statement.rs:3288 — crates/ruff_python_parser/src/parser/statement.rs:3288-3313 | crates/ruff_python_parser/src/parser/statement.rs:3732-3753 | crates/ruff_python_parser/src/parser/statement.rs:3795-3818 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (25–26 lines × 2) · ×1
  • Duplicated block (25–26 lines × 2) crates/ty_project/src/db.rs:421 — crates/ty_project/src/db.rs:421-446 | crates/ty_project/src/db.rs:501-525 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (23–26 lines × 2) · ×1
  • Duplicated block (23–26 lines × 2) crates/ty_server/src/server/api/requests/folding_range.rs:32 — crates/ty_server/src/server/api/requests/folding_range.rs:32-54 | crates/ty_server/src/server/api/requests/semantic_tokens.rs:31-56 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (24 lines × 4) · ×1
  • Duplicated block (24 lines × 4) crates/ty_python_semantic/src/types/signatures.rs:3586 — crates/ty_python_semantic/src/types/signatures.rs:3586-3609 | crates/ty_python_semantic/src/types/signatures.rs:3779-3802 | crates/ty_python_semantic/src/types/signatures.rs:3952-3975 | crates/ty_python_semantic/src/types/signatures.rs:4476-4499 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3586` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (21–24 lines × 2) · ×1
  • Duplicated block (21–24 lines × 2) crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:101 — crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:101-124 | crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs:116-136 — before extracting anything, compare `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs` and `crates/ruff_linter/src/rules/perflint/rules/manual_list_comprehension.rs` as WHOLE FILES: this scan already matched 7 separate duplicated blocks between them, totalling at least 125 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/perflint/rules/manual_dict_comprehension.rs:101` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22–24 lines × 2) · ×1
  • Duplicated block (22–24 lines × 2) crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:73 — crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:73-96 | crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs:63-84 — before extracting anything, compare `crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs` and `crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:73` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19–23 lines × 2) · ×1
  • Duplicated block (19–23 lines × 2) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:143 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:143-161 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs:144-166 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs` and `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:143` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18–23 lines × 2) · ×1
  • Duplicated block (18–23 lines × 2) crates/ruff_linter/src/rules/ruff/rules/never_union.rs:93 — crates/ruff_linter/src/rules/ruff/rules/never_union.rs:93-115 | crates/ruff_linter/src/rules/ruff/rules/never_union.rs:118-135 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (21–23 lines × 2) · ×1
  • Duplicated block (21–23 lines × 2) crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:582 — crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:582-604 | crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:613-633 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:582` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (22 lines × 3) · ×1
  • Duplicated block (22 lines × 3) crates/ruff_dev/src/generate_json_schema.rs:30 — crates/ruff_dev/src/generate_json_schema.rs:30-51 | crates/ruff_dev/src/generate_ty_rules.rs:37-58 | crates/ruff_dev/src/generate_ty_schema.rs:30-51 — before extracting anything, compare `crates/ruff_dev/src/generate_json_schema.rs` and `crates/ruff_dev/src/generate_ty_schema.rs` as WHOLE FILES: 88% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_dev/src/generate_json_schema.rs:30` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–22 lines × 2) · ×1
  • Duplicated block (16–22 lines × 2) crates/ruff_linter/src/noqa.rs:441 — crates/ruff_linter/src/noqa.rs:441-456 | crates/ruff_linter/src/noqa.rs:471-492 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/noqa.rs:441` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×1
  • Duplicated block (21–22 lines × 2) crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:595 — crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:595-616 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:817-837 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:595` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19–22 lines × 2) · ×1
  • Duplicated block (19–22 lines × 2) crates/ty_python_semantic/src/types/signatures.rs:3744 — crates/ty_python_semantic/src/types/signatures.rs:3744-3762 | crates/ty_python_semantic/src/types/signatures.rs:4165-4186 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3744` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 6) · ×1
  • Duplicated block (21 lines × 6) crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:52 — crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:52-72 | crates/ruff_linter/src/rules/pylint/rules/invalid_bytes_return.rs:52-72 | crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs:56-76 | crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs:58-78 | crates/ruff_linter/src/rules/pylint/rules/invalid_length_return.rs:57-77 | crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs:52-72 — before extracting anything, compare `crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs` and `crates/ruff_linter/src/rules/pylint/rules/invalid_bytes_return.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:52` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18–20 lines × 2) · ×1
  • Duplicated block (18–20 lines × 2) crates/ty_python_semantic/src/types/class/typed_dict.rs:421 — crates/ty_python_semantic/src/types/class/typed_dict.rs:421-440 | crates/ty_python_semantic/src/types/class/typed_dict.rs:616-633 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/class/typed_dict.rs:421` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (9–20 lines × 2) · ×1
  • Duplicated block (9–20 lines × 2) crates/ty_python_semantic/src/types/constraints.rs:4442 — crates/ty_python_semantic/src/types/constraints.rs:4442-4450 | crates/ty_python_semantic/src/types/constraints.rs:4498-4517 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints.rs:4442` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19 lines × 13) · ×1
  • Duplicated block (19 lines × 13) crates/ty_server/src/server/api/requests/completion.rs:45 — crates/ty_server/src/server/api/requests/completion.rs:45-63 | crates/ty_server/src/server/api/requests/doc_highlights.rs:32-50 | crates/ty_server/src/server/api/requests/goto_declaration.rs:31-49 | crates/ty_server/src/server/api/requests/goto_definition.rs:32-50 | crates/ty_server/src/server/api/requests/goto_implementation.rs:31-49 | crates/ty_server/src/server/api/requests/goto_type_definition.rs:32-50 | crates/ty_server/src/server/api/requests/hover.rs:31-49 | crates/ty_server/src/server/api/requests/prepare_call_hierarchy.rs:40-58 | crates/ty_server/src/server/api/requests/prepare_rename.rs:31-49 | crates/ty_server/src/server/api/requests/prepare_type_hierarchy.rs:41-59 | crates/ty_server/src/server/api/requests/references.rs:32-50 | crates/ty_server/src/server/api/requests/rename.rs:33-51 | crates/ty_server/src/server/api/requests/signature_help.rs:34-52 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 13 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `params` to `&CompletionParams` in one and `&DocumentHighlightParams` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_server/src/server/api/requests/completion.rs:43` calls `now` and `crates/ty_server/src/server/api/requests/goto_declaration.rs:30` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (15–19 lines × 3) · ×1
  • Duplicated block (15–19 lines × 3) crates/ty_python_semantic/src/types/constraints/paths.rs:336 — crates/ty_python_semantic/src/types/constraints/paths.rs:336-354 | crates/ty_python_semantic/src/types/constraints/paths.rs:362-380 | crates/ty_python_semantic/src/types/constraints/paths.rs:387-401 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/paths.rs:336` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13–19 lines × 2) · ×1
  • Duplicated block (13–19 lines × 2) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:3395 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:3395-3413 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:3543-3555 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:3395` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–18 lines × 3) · ×1
  • Duplicated block (15–18 lines × 3) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:103 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:103-117 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:550-567 | crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:860-875 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs` and `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 55 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:103` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_literal_within_tuple_call.rs:101` calls `List`, `Tuple` and `crates/ruff_linter/src/rules/flake8_pytest_style/rules/parametrize.rs:549` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–18 lines × 3) · ×1
  • Duplicated block (16–18 lines × 3) crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:583 — crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:583-600 | crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:614-629 | crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:662-678 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/named_tuple.rs:583` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–18 lines × 3) · ×1
  • Duplicated block (17–18 lines × 3) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2673 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2673-2689 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2772-2788 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2802-2819 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2673` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–17 lines × 4) · ×1
  • Duplicated block (16–17 lines × 4) crates/ty_python_semantic/src/types/signatures.rs:3570 — crates/ty_python_semantic/src/types/signatures.rs:3570-3585 | crates/ty_python_semantic/src/types/signatures.rs:3763-3778 | crates/ty_python_semantic/src/types/signatures.rs:3935-3951 | crates/ty_python_semantic/src/types/signatures.rs:4454-4469 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/signatures.rs:3570` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×1
  • Duplicated block (17 lines × 3) crates/ruff_linter/src/rules/pylint/rules/bad_staticmethod_argument.rs:67 — crates/ruff_linter/src/rules/pylint/rules/bad_staticmethod_argument.rs:67-83 | crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs:78-94 | crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs:68-84 — before extracting anything, compare `crates/ruff_linter/src/rules/pylint/rules/singledispatch_method.rs` and `crates/ruff_linter/src/rules/pylint/rules/singledispatchmethod_function.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 53 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/bad_staticmethod_argument.rs:67` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (14–17 lines × 2) · ×1
  • Duplicated block (14–17 lines × 2) crates/ruff_server/src/server/api.rs:70 — crates/ruff_server/src/server/api.rs:70-83 | crates/ty_server/src/server/api.rs:152-168 — before extracting anything, compare `crates/ruff_server/src/server/api.rs` and `crates/ty_server/src/server/api.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 69 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/api.rs:70` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 10) · ×1
  • Duplicated block (15–16 lines × 10) crates/ty_python_semantic/src/types.rs:9864 — crates/ty_python_semantic/src/types.rs:9864-9879 | crates/ty_python_semantic/src/types.rs:10382-10396 | crates/ty_python_semantic/src/types.rs:10751-10765 | crates/ty_python_semantic/src/types/infer/comparisons.rs:384-398 | crates/ty_python_semantic/src/types/method.rs:450-465 | crates/ty_python_semantic/src/types/method.rs:517-531 | crates/ty_python_semantic/src/types/method.rs:546-561 | crates/ty_python_semantic/src/types/method.rs:990-1004 | crates/ty_python_semantic/src/types/method.rs:1014-1028 | crates/ty_python_semantic/src/types/relation.rs:332-346 — there are 10 copies across 4 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 10 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (16 lines × 4) · ×1
  • Duplicated block (16 lines × 4) crates/ruff_server/src/server/api/requests/code_action.rs:194 — crates/ruff_server/src/server/api/requests/code_action.rs:194-209 | crates/ruff_server/src/server/api/requests/code_action.rs:229-244 | crates/ruff_server/src/server/api/requests/code_action.rs:264-279 | crates/ruff_server/src/server/api/requests/code_action.rs:299-314 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/api/requests/code_action.rs:194` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 3) · ×1
  • Duplicated block (15–16 lines × 3) crates/ty_python_semantic/src/types/infer/builder.rs:716 — crates/ty_python_semantic/src/types/infer/builder.rs:716-731 | crates/ty_python_semantic/src/types/infer/builder.rs:830-844 | crates/ty_python_semantic/src/types/infer/builder.rs:911-925 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder.rs:716` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ty_python_semantic/src/types/infer/builder.rs:715` calls `extend`, `iter`, `copied` and `crates/ty_python_semantic/src/types/infer/builder.rs:829` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×1
  • Duplicated block (16 lines × 3) crates/ty_python_semantic/src/types/infer/builder.rs:5820 — crates/ty_python_semantic/src/types/infer/builder.rs:5820-5835 | crates/ty_python_semantic/src/types/narrow.rs:5596-5611 | crates/ty_python_semantic/src/types/typed_dict.rs:2103-2118 — before extracting anything, compare `crates/ty_python_semantic/src/types/narrow.rs` and `crates/ty_python_semantic/src/types/typed_dict.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (24–25 lines × 2) · ×1
  • Duplicated block (24–25 lines × 2) crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:74 — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:74-98 | crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs:75-98 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs` and `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 73 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:74` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (14–16 lines × 2) · ×1
  • Duplicated block (14–16 lines × 2) crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:131 — crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:131-146 | crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:150-163 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:131` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12–16 lines × 2) · ×1
  • Duplicated block (12–16 lines × 2) crates/ruff_python_ast/src/node.rs:694 — crates/ruff_python_ast/src/node.rs:694-705 | crates/ruff_python_ast/src/node.rs:731-746 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/node.rs:731` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14–15 lines × 4) · ×1
  • Duplicated block (14–15 lines × 4) crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:84 — crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:84-97 | crates/ruff_linter/src/rules/pylint/rules/type_bivariance.rs:106-120 | crates/ruff_linter/src/rules/pylint/rules/type_name_incorrect_variance.rs:100-113 | crates/ruff_linter/src/rules/pylint/rules/type_param_name_mismatch.rs:92-105 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_pyi/rules/prefix_type_params.rs:84` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15 lines × 4) · ×1
  • Duplicated block (15 lines × 4) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs:314 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs:314-328 | crates/ruff_linter/src/rules/flake8_simplify/rules/zip_dict_keys_and_values.rs:127-141 | crates/ruff_linter/src/rules/refurb/rules/verbose_decimal_constructor.rs:157-171 | crates/ruff_linter/src/rules/refurb/rules/verbose_decimal_constructor.rs:203-217 — there are 4 copies across 3 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/ast_expr.rs:314` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: the declarations holding them bind `expr` to `&Expr` in one and `&ast::ExprCall` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (12–15 lines × 3) · ×1
  • Duplicated block (12–15 lines × 3) crates/ruff_python_semantic/src/analyze/type_inference.rs:191 — crates/ruff_python_semantic/src/analyze/type_inference.rs:191-205 | crates/ruff_python_semantic/src/analyze/type_inference.rs:241-254 | crates/ruff_python_semantic/src/analyze/type_inference.rs:269-280 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_semantic/src/analyze/type_inference.rs:191` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13–14 lines × 5) · ×1
  • Duplicated block (13–14 lines × 5) crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:74 — crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:74-87 | crates/ruff_linter/src/rules/pylint/rules/invalid_bytes_return.rs:74-86 | crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs:78-91 | crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs:80-93 | crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs:74-86 — before extracting anything, compare `crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs` and `crates/ruff_linter/src/rules/pylint/rules/invalid_bytes_return.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:74` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14 lines × 5) · ×1
  • Duplicated block (14 lines × 5) crates/ty_python_semantic/src/types/constraints/sequents.rs:1206 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1206-1219 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1241-1254 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1276-1289 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1346-1359 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1381-1394 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1206` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (13–14 lines × 3) · ×1
  • Duplicated block (13–14 lines × 3) crates/ruff_python_ast/src/nodes.rs:2818 — crates/ruff_python_ast/src/nodes.rs:2818-2831 | crates/ruff_python_codegen/src/generator.rs:399-411 | crates/ruff_python_formatter/src/expression/operator.rs:27-39 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/nodes.rs:2818` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_formatter/src/expression/operator.rs:42` calls `token`, `fmt` and `crates/ruff_python_ast/src/nodes.rs:2831` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10–14 lines × 2) · ×1
  • Duplicated block (10–14 lines × 2) crates/ruff_linter/src/rules/refurb/helpers.rs:262 — crates/ruff_linter/src/rules/refurb/helpers.rs:262-275 | crates/ruff_linter/src/rules/refurb/helpers.rs:313-322 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (12–14 lines × 2) · ×1
  • Duplicated block (12–14 lines × 2) crates/ruff_python_semantic/src/analyze/type_inference.rs:175 — crates/ruff_python_semantic/src/analyze/type_inference.rs:175-188 | crates/ruff_python_semantic/src/analyze/type_inference.rs:273-284 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_semantic/src/analyze/type_inference.rs:175` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×1
  • Duplicated block (13 lines × 3) crates/ty_python_semantic/src/types/call/bind.rs:2963 — crates/ty_python_semantic/src/types/call/bind.rs:2963-2975 | crates/ty_python_semantic/src/types/call/bind.rs:2992-3004 | crates/ty_python_semantic/src/types/call/bind.rs:3021-3033 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:2963` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (10–13 lines × 2) · ×1
  • Duplicated block (10–13 lines × 2) crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:139 — crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:139-148 | crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:194-206 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/refurb/rules/unnecessary_enumerate.rs:139` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8–13 lines × 2) · ×1
  • Duplicated block (8–13 lines × 2) crates/ruff_python_formatter/src/other/interpolated_string_element.rs:136 — crates/ruff_python_formatter/src/other/interpolated_string_element.rs:136-148 | crates/ruff_python_formatter/src/other/interpolated_string_element.rs:217-224 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_formatter/src/other/interpolated_string_element.rs:136` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–12 lines × 3) · ×1
  • Duplicated block (11–12 lines × 3) crates/ty_python_semantic/src/types/call/bind.rs:3171 — crates/ty_python_semantic/src/types/call/bind.rs:3171-3182 | crates/ty_python_semantic/src/types/call/bind.rs:3244-3255 | crates/ty_python_semantic/src/types/call/bind.rs:3297-3307 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:3171` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (11 lines × 6) · ×1
  • Duplicated block (11 lines × 6) crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:74 — crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:74-84 | crates/ruff_linter/src/rules/pylint/rules/invalid_bytes_return.rs:74-84 | crates/ruff_linter/src/rules/pylint/rules/invalid_hash_return.rs:78-88 | crates/ruff_linter/src/rules/pylint/rules/invalid_index_return.rs:80-90 | crates/ruff_linter/src/rules/pylint/rules/invalid_length_return.rs:79-89 | crates/ruff_linter/src/rules/pylint/rules/invalid_str_return.rs:74-84 — before extracting anything, compare `crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs` and `crates/ruff_linter/src/rules/pylint/rules/invalid_bytes_return.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 46 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/pylint/rules/invalid_bool_return.rs:74` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11 lines × 5) · ×1
  • Duplicated block (11 lines × 5) crates/ruff_python_ast/src/name.rs:532 — crates/ruff_python_ast/src/name.rs:532-542 | crates/ruff_python_ast/src/name.rs:545-555 | crates/ruff_python_ast/src/name.rs:559-569 | crates/ruff_python_ast/src/name.rs:574-584 | crates/ruff_python_ast/src/name.rs:590-600 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_python_ast/src/name.rs:532` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ruff_python_ast/src/name.rs:556` calls `as_str` and `crates/ruff_python_ast/src/name.rs:543` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–11 lines × 4) · ×1
  • Duplicated block (8–11 lines × 4) crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1554 — crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1554-1563 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1585-1594 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1626-1636 | crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1656-1663 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1554` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1552` calls `unnecessary_list_set_comprehension` and `crates/ruff_linter/src/checkers/ast/analyze/expression.rs:1656` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–11 lines × 4) · ×1
  • Duplicated block (7–11 lines × 4) crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:786 — crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:786-792 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:813-819 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:902-912 | crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:937-947 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_annotations/rules/definition.rs:786` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (11 lines × 4) · ×1
  • Duplicated block (11 lines × 4) crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs:210 — crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs:210-220 | crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs:227-237 | crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs:241-251 | crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs:260-270 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs:210` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 6) · ×1
  • Duplicated block (10 lines × 6) crates/ty_python_semantic/src/types/infer/builder.rs:5818 — crates/ty_python_semantic/src/types/infer/builder.rs:5818-5827 | crates/ty_python_semantic/src/types/infer/builder.rs:11916-11925 | crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:1162-1171 | crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:1190-1199 | crates/ty_python_semantic/src/types/narrow.rs:5594-5603 | crates/ty_python_semantic/src/types/typed_dict.rs:2101-2110 — before extracting anything, compare `crates/ty_python_semantic/src/types/narrow.rs` and `crates/ty_python_semantic/src/types/typed_dict.rs` as WHOLE FILES: this scan already matched 4 separate duplicated blocks between them, totalling at least 56 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `crates/ty_python_semantic/src/types/infer/builder/binary_expressions.rs:1172` calls `Intersection`, `EnumComplement` and `crates/ty_python_semantic/src/types/infer/builder.rs:5828` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (10 lines × 5) · ×1
  • Duplicated block (10 lines × 5) crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:263 — crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:263-273 | crates/ruff_linter/src/rules/airflow/rules/moved_to_provider_in_3.rs:1200-1210 | crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs:1096-1106 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs:326-336 | crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:387-396 — before extracting anything, compare `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs` and `crates/ruff_linter/src/rules/airflow/rules/removal_in_3.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 68 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:263` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21 lines × 3) · ×1
  • Duplicated block (21 lines × 3) crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:588 — crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:588-608 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:610-630 | crates/ruff_linter/src/rules/flake8_comprehensions/fixes.rs:632-652 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (8–10 lines × 2) · ×1
  • Duplicated block (8–10 lines × 2) crates/ty_python_semantic/src/types/subclass_of.rs:462 — crates/ty_python_semantic/src/types/subclass_of.rs:462-469 | crates/ty_python_semantic/src/types/subclass_of.rs:498-507 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/subclass_of.rs:462` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6–9 lines × 4) · ×1
  • Duplicated block (6–9 lines × 4) crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs:84 — crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs:84-92 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:107-112 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_mkdir.rs:105-110 | crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_symlink.rs:109-114 — before extracting anything, compare `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs` and `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_symlink.rs` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 34 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs:84` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_getcwd.rs:83` calls `is_fix_os_getcwd_enabled`, `settings` and `crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_makedirs.rs:105` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8–9 lines × 4) · ×1
  • Duplicated block (8–9 lines × 4) crates/ty_python_core/src/narrowing_constraints.rs:300 — crates/ty_python_core/src/narrowing_constraints.rs:300-307 | crates/ty_python_core/src/narrowing_constraints.rs:367-374 | crates/ty_python_core/src/reachability_constraints.rs:434-442 | crates/ty_python_core/src/reachability_constraints.rs:515-523 — before extracting anything, compare `crates/ty_python_core/src/narrowing_constraints.rs` and `crates/ty_python_core/src/reachability_constraints.rs` as WHOLE FILES: this scan already matched 5 separate duplicated blocks between them, totalling at least 59 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (6–8 lines × 3) · ×1
  • Duplicated block (6–8 lines × 3) crates/ty_python_semantic/src/types/constraints/variables.rs:257 — crates/ty_python_semantic/src/types/constraints/variables.rs:257-262 | crates/ty_python_semantic/src/types/constraints/variables.rs:334-339 | crates/ty_python_semantic/src/types/constraints/variables.rs:421-428 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/variables.rs:257` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (7 lines × 5) · ×1
  • Duplicated block (7 lines × 5) crates/ty_python_semantic/src/types/constraints/sequents.rs:1049 — crates/ty_python_semantic/src/types/constraints/sequents.rs:1049-1055 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1146-1152 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1251-1257 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1356-1362 | crates/ty_python_semantic/src/types/constraints/sequents.rs:1391-1397 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/constraints/sequents.rs:1049` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (6–7 lines × 3) · ×1
  • Duplicated block (6–7 lines × 3) crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:281 — crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:281-286 | crates/ruff_linter/src/rules/refurb/rules/check_and_remove_from_set.rs:192-197 | crates/ruff_linter/src/rules/refurb/rules/reimplemented_starmap.rs:324-330 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_linter/src/rules/flake8_simplify/rules/ast_unary_op.rs:281` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×1
  • Duplicated block (5 lines × 3) crates/ruff_annotate_snippets/src/renderer/source_map.rs:72 — crates/ruff_annotate_snippets/src/renderer/source_map.rs:72-76 | crates/ruff_annotate_snippets/src/renderer/source_map.rs:101-105 | crates/ruff_annotate_snippets/src/renderer/source_map.rs:117-121 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_annotate_snippets/src/renderer/source_map.rs:72` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (68 lines × 2) · ×1
  • Duplicated block (68 lines × 2) crates/ruff_server/src/server/schedule/thread.rs:41 — crates/ruff_server/src/server/schedule/thread.rs:41-108 | crates/ty_server/src/server/schedule/thread.rs:41-108 — before extracting anything, compare `crates/ruff_server/src/server/schedule/thread.rs` and `crates/ty_server/src/server/schedule/thread.rs` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/server/schedule/thread.rs:41` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (180 lines × 2) · ×1
  • Duplicated block (180 lines × 2) crates/ruff_server/src/session/request_queue.rs:17 — crates/ruff_server/src/session/request_queue.rs:17-197 | crates/ty_server/src/session/request_queue.rs:17-196 — before extracting anything, compare `crates/ruff_server/src/session/request_queue.rs` and `crates/ty_server/src/session/request_queue.rs` as WHOLE FILES: 99% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ruff_server/src/session/request_queue.rs:17` it runs out through the closing brace of the declaration holding it and carries on into the declaration that follows — the window is the tail of one member plus the head of the next, so no call can be substituted for those exact lines, and the smallest declaration that contains all of them is the type they sit in. The repeated unit is the member each site sits in: where those members' bodies are the same, move one whole member to the shared location and have the others delegate to it; where the copies are a run of near-identical overloads or wrappers that differ only in their signatures, the repetition IS the run — a one-line delegation has no helper inside it to lift — so generate the run from the set it enumerates, or accept it and keep each member's own documentation with it.
D4 · Code Duplication · Duplicated block (10 lines × 8) · ×1
  • Duplicated block (10 lines × 8) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2062 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2062-2071 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2074-2083 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2086-2095 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2098-2107 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2110-2119 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2122-2131 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2134-2143 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2146-2155 — all 8 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2062` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (10 lines × 9) · ×1
  • Duplicated block (10 lines × 9) crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2062 — crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2062-2071 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2074-2083 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2086-2095 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2098-2107 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2110-2119 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2122-2131 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2134-2143 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2146-2155 | crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:3184-3193 — all 9 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/infer/builder/type_expression.rs:2062` it runs out through the closing brace of the declaration holding it — the window is that declaration's tail, not a fragment that begins part-way through something, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×1
  • Duplicated block (8 lines × 5) crates/ty_python_semantic/src/types/relation_error.rs:270 — crates/ty_python_semantic/src/types/relation_error.rs:270-277 | crates/ty_python_semantic/src/types/relation_error.rs:288-296 | crates/ty_python_semantic/src/types/relation_error.rs:298-305 | crates/ty_python_semantic/src/types/relation_error.rs:322-329 | crates/ty_python_semantic/src/types/relation_error.rs:347-354 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Each matched range is the entire body of the declaration above it, so the region is already a complete unit: move that whole declaration to the shared location and have each site call it, rather than lifting the lines out of their bodies. Any `return` inside it is the body's own exit and keeps its meaning in the moved unit.
D4 · Code Duplication · Duplicated block (5 lines × 5) · ×1
  • Duplicated block (5 lines × 5) crates/ty_python_semantic/src/types/call/bind.rs:2252 — crates/ty_python_semantic/src/types/call/bind.rs:2252-2256 | crates/ty_python_semantic/src/types/call/bind.rs:2270-2274 | crates/ty_python_semantic/src/types/call/bind.rs:2300-2304 | crates/ty_python_semantic/src/types/call/bind.rs:2321-2325 | crates/ty_python_semantic/src/types/call/bind.rs:2341-2345 — all 5 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `crates/ty_python_semantic/src/types/call/bind.rs:2252` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D5 · Coupling · Unstable project mdtest · ×1
  • Unstable project mdtest — mdtest has instability 0.88 with 1 dependents.
D5 · Coupling · Unstable project ruff · ×1
  • Unstable project ruff — ruff has instability 0.90 with 2 dependents.
D5 · Coupling · Unstable project ruff_server · ×1
  • Unstable project ruff_server — ruff_server has instability 0.94 with 1 dependents.
D5 · Coupling · Unstable project ty_server · ×1
  • Unstable project ty_server — ty_server has instability 0.93 with 1 dependents.
S1 · Web-Security Posture · Third-party script without Subresource Integrity · ×1
  • Third-party script without Subresource Integrity playground/ruff/index.html:29 — `https://cdn.usefathom.com/script.js` is executed by this page with no Subresource Integrity. Whoever can answer that request — the CDN, anyone who compromises it, anyone on the network path — runs arbitrary script in this page's origin, with its session. The URL also names no version, so it resolves to whatever that origin serves at fetch time — the executed bytes can change with nobody touching this repository. 2 such include(s) across the repository's markup.
Minor — 198 finding(s)
D34 · Knowledge Freshness · Orphaned file · ×95
  • Orphaned file crates/ty_python_core/src/builder/loop_bindings_visitor.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/flake8_copyright/mod.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ty_ide/src/call_hierarchy.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/ruff/rules/assert_with_print_message.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/flake8_todos/rules/todos.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_server/src/server/schedule/thread/priority.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/ruff/rules/invalid_formatter_suppression_comment.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_python_semantic/src/cfg/graph.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/flake8_async/helpers.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/pylint/rules/non_slot_assignment.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/flake8_pyi/rules/unnecessary_type_union.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/airflow/rules/moved_in_3_1.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/ruff/rules/needless_else.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/ruff/rules/suppression_comment_visitor.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/ruff/rules/useless_finally.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/pylint/rules/swap_with_temporary_variable.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_annotate_snippets/src/level.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/ruff/rules/class_with_mixed_type_vars.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/refurb/rules/fstring_number_format.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/flake8_use_pathlib/rules/os_stat.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_python_semantic/src/cfg/visualize.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_macros/src/rule_namespace.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file crates/ruff_linter/src/rules/pylint/rules/no_method_decorator.rs:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • + 70 more in this group — see findings.md.
X10 · Duplicated predicate · Duplicated predicate · ×40
  • Duplicated predicate playground/ruff/src/Editor/Diagnostics.tsx:113 — `secondaryAnnotations.length > 0 || diagnostic.subDiagnostics.length > 0` appears character-identically in 2 files — playground/ruff/src/Editor/Diagnostics.tsx, playground/ty/src/Editor/Diagnostics.tsx. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff/src/commands/format.rs:607 — `!cfg!(test) && colored::control::SHOULD_COLORIZE.should_colorize()` appears character-identically in 2 files — crates/ruff/src/commands/format.rs, crates/ruff/src/printer.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_db/src/diagnostic/render.rs:193 — `!config.preview || config.prefer_rule_codes` appears character-identically in 2 files — crates/ruff_db/src/diagnostic/render.rs, crates/ruff_db/src/diagnostic/render/sarif.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs:100 — `!has_leading_content(stmt.start(), checker.source()) && !has_trailing_content(stmt.end(), checker.source())` appears character-identically in 2 files — crates/ruff_linter/src/rules/pycodestyle/rules/lambda_assignment.rs, crates/ruff_linter/src/rules/ruff/rules/legacy_form_pytest_raises.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/importer/mod.rs:558 — `!import_from.is_lazy && import_from.module.as_deref() == Some("__future__")` appears character-identically in 2 files — crates/ruff_linter/src/importer/mod.rs, crates/ty_python_semantic/src/importer.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ty_ide/src/docstring/document/syntax.rs:38 — `!name.is_empty() && name.split('.').all(is_identifier)` appears character-identically in 2 files — crates/ty_ide/src/docstring/document/syntax.rs, crates/ty_module_resolver/src/module_name.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ty_python_core/src/narrowing_constraints.rs:169 — `!node.is_terminal() && !self.interior_used[node.index()]` appears character-identically in 2 files — crates/ty_python_core/src/narrowing_constraints.rs, crates/ty_python_core/src/reachability_constraints.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ty_python_core/src/narrowing_constraints.rs:179 — `a == b || (a.is_terminal() && b.is_terminal())` appears character-identically in 2 files — crates/ty_python_core/src/narrowing_constraints.rs, crates/ty_python_core/src/reachability_constraints.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs:257 — `attr == "format" && value.is_literal_expr()` appears character-identically in 2 files — crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs, crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs:90 — `attr_name.nfkc().collect::<String>() != attr_name || has_comments` appears character-identically in 3 files — crates/ruff_linter/src/rules/flake8_bugbear/rules/delattr_with_constant.rs, crates/ruff_linter/src/rules/flake8_bugbear/rules/getattr_with_constant.rs, crates/ruff_linter/src/rules/flake8_bugbear/rules/setattr_with_constant.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs:159 — `binding.is_global() || binding.is_nonlocal()` appears character-identically in 2 files — crates/ruff_linter/src/rules/pyupgrade/rules/yield_in_for_loop.rs, crates/ruff_linter/src/rules/ruff/rules/used_dummy_variable.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_python_parser/src/lexer/cursor.rs:115 — `chars.next() == Some(c1) && chars.next() == Some(c2)` appears character-identically in 2 files — crates/ruff_python_parser/src/lexer/cursor.rs, crates/ruff_python_trivia/src/cursor.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_python_parser/src/lexer/cursor.rs:126 — `chars.next() == Some(c1) && chars.next() == Some(c2) && chars.next() == Some(c3)` appears character-identically in 2 files — crates/ruff_python_parser/src/lexer/cursor.rs, crates/ruff_python_trivia/src/cursor.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_continue.rs:68 — `check_typed_exception || is_untyped_exception(type_, checker.semantic())` appears character-identically in 2 files — crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_continue.rs, crates/ruff_linter/src/rules/flake8_bandit/rules/try_except_pass.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs:73 — `checker.semantic().seen_module(Modules::TRIO) || checker.semantic().seen_module(Modules::ANYIO)` appears character-identically in 2 files — crates/ruff_linter/src/rules/flake8_async/rules/async_zero_sleep.rs, crates/ruff_linter/src/rules/flake8_async/rules/long_sleep_not_forever.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/checkers/ast/analyze/definitions.rs:32 — `checker.source_type.is_stub() && checker.is_rule_enabled(Rule::DocstringInStub)` appears character-identically in 2 files — crates/ruff_linter/src/checkers/ast/analyze/definitions.rs, crates/ruff_linter/src/checkers/ast/analyze/suite.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/pyupgrade/rules/pep695/mod.rs:414 — `checker.target_version() < PythonVersion::PY313 || !is_type_var_default_enabled(checker.settings())` appears character-identically in 2 files — crates/ruff_linter/src/rules/pyupgrade/rules/pep695/mod.rs, crates/ruff_linter/src/rules/pyupgrade/rules/pep695/non_pep695_type_alias.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ty_python_semantic/src/types/infer/builder/enum_call.rs:428 — `definition.name(db) && Some(assigned_name.as_str()) != name` appears character-identically in 2 files — crates/ty_python_semantic/src/types/infer/builder/enum_call.rs, crates/ty_python_semantic/src/types/infer/builder/typed_dict.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ty/src/lib.rs:733 — `diagnostic.severity() == Severity::Hint && diagnostic.id().is_lint()` appears character-identically in 2 files — crates/ty/src/lib.rs, crates/ty_python_semantic/src/fixes.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs:84 — `f.options().source_type().is_ipynb() && f.context().node_level().is_last_top_level_statement() && target.is_name_expr() && trailing_semicolo…` appears character-identically in 2 files — crates/ruff_python_formatter/src/statement/stmt_ann_assign.rs, crates/ruff_python_formatter/src/statement/stmt_aug_assign.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs:260 — `flags.is_triple_quoted() || flags.is_raw_string()` appears character-identically in 2 files — crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs, crates/ruff_linter/src/rules/flake8_quotes/rules/unnecessary_escaped_quote.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs:298 — `flags.is_triple_quoted() || flags.prefix().is_raw()` appears character-identically in 2 files — crates/ruff_linter/src/rules/flake8_quotes/rules/avoidable_escaped_quote.rs, crates/ruff_linter/src/rules/flake8_quotes/rules/unnecessary_escaped_quote.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs:97 — `generator.ifs.is_empty() && !generator.is_async` appears character-identically in 2 files — crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_list.rs, crates/ruff_linter/src/rules/flake8_comprehensions/rules/unnecessary_generator_set.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs:76 — `ignore_names.matches(name) || ignore_names.matches(asname)` appears character-identically in 5 files — crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_acronym.rs, crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_constant.rs, crates/ruff_linter/src/rules/pep8_naming/rules/camelcase_imported_as_lowercase.rs, crates/ruff_linter/src/rules/pep8_naming/rules/constant_imported_as_non_constant.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs:154 — `index_name.id == "_" || value_name.id == "_"` appears character-identically in 2 files — crates/ruff_linter/src/rules/pylint/rules/unnecessary_dict_index_lookup.rs, crates/ruff_linter/src/rules/pylint/rules/unnecessary_list_index_lookup.rs. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • + 15 more in this group — see findings.md.
X4 · Structured logging · Interpolated log message defeats structured logging · ×40
  • Interpolated log message defeats structured logging crates/ty_test/src/db.rs:45 — `trace!` at line 45 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `trace!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_test/src/lib.rs:436 — `debug!` at line 436 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:315 — `debug!` at line 315 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:343 — `debug!` at line 343 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:403 — `trace!` at line 403 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `trace!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:759 — `debug!` at line 759 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:805 — `warn!` at line 805 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:831 — `warn!` at line 831 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:874 — `trace!` at line 874 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `trace!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:906 — `warn!` at line 906 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:930 — `warn!` at line 930 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:935 — `warn!` at line 935 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:944 — `debug!` at line 944 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:980 — `debug!` at line 980 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:990 — `debug!` at line 990 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:1224 — `debug!` at line 1224 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:1241 — `debug!` at line 1241 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:1674 — `debug!` at line 1674 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_site_packages/src/lib.rs:1823 — `debug!` at line 1823 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_server/src/document.rs:108 — `warn!` at line 108 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_server/src/lib.rs:68 — `warn!` at line 68 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `warn!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_server/src/server.rs:84 — `error!` at line 84 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `error!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_server/src/server.rs:87 — `debug!` at line 87 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_server/src/server.rs:88 — `debug!` at line 88 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • Interpolated log message defeats structured logging crates/ty_server/src/server.rs:92 — `debug!` at line 92 is handed a format string with `{…}` values in it, so tracing records one finished `message` field — the values in it cannot be queried, filtered or aggregated as fields, and every occurrence reads as a different message. Record the values as fields beside a constant message instead: `debug!(order_id = %order_id, status = ?status, "order status updated")` (`%` records a value by its `Display`, `?` by its `Debug`, a bare name as itself), which a JSON subscriber, OpenTelemetry or a log store keeps as queryable keys. An error goes in as a field too: `error = %err`.
  • + 15 more in this group — see findings.md.
D16 · Bus Factor · Off-boarding risk · ×5
  • Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 20 significant file(s) lose their only recent owner: crates/ty_python_semantic/src/importer.rs, crates/ty_python_semantic/src/types/definition_resolution.rs, crates/ty_python_semantic/src/types/infer/builder/post_inference/function.rs, crates/ty_python_semantic/src/types/class/implicit_attributes.rs, crates/ty_python_semantic/src/types/infer/builder/post_inference/overloaded_function.rs, crates/ty_python_semantic/src/types/infer/builder/post_inference/typed_dict.rs, crates/ty_python_semantic/src/types/abstract_methods.rs, crates/ruff_python_index/src/indexer.rs (+12 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #2 — If anonymized user #2 becomes unavailable, 14 significant file(s) lose their only recent owner: crates/ty_ide/src/docstring/document/google.rs, crates/ty_ide/src/docstring/document/numpy.rs, crates/ty_ide/src/docstring/document/rst.rs, crates/ty_ide/src/docstring/markdown/structured.rs, crates/ty_ide/src/docstring/markdown/general/inline.rs, crates/ty_ide/src/docstring/document/syntax.rs, crates/ty_ide/src/docstring/markdown/structured/rst.rs, crates/ty_ide/src/docstring/document/preformatted.rs (+6 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #3 — If anonymized user #3 becomes unavailable, 11 significant file(s) lose their only recent owner: crates/ty_project/src/script.rs, crates/ty_server/src/session/file_watcher.rs, crates/ty_project/src/glob/portable.rs, crates/ty_project/src/glob/exclude.rs, crates/ty_project/src/watch.rs, crates/ty_server/src/server/script_progress.rs, crates/ruff_python_trivia/src/name_matcher.rs, crates/ruff_python_parser/src/parser/scratch_buffer.rs (+3 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #4 — If anonymized user #4 becomes unavailable, 10 significant file(s) lose their only recent owner: crates/ruff_unicode_names2/src/lib.rs, crates/ruff_db/src/diagnostic/render/rdjson.rs, crates/ruff_linter/src/rules/ruff/rules/access_annotations_from_class_dict.rs, crates/ruff_linter/src/rules/ruff/rules/noqa_comments.rs, crates/ruff_unicode_names2_generator/src/phf.rs, crates/ruff_linter/src/rules/pyupgrade/rules/replace_str_enum.rs, crates/ruff_linter/src/rules/flake8_implicit_str_concat/rules/collection_literal.rs, crates/ruff_db/src/diagnostic/render/pylint.rs (+2 more). Pair on, review, or document these before any departure.
  • Off-boarding risk: anonymized user #5 — If anonymized user #5 becomes unavailable, 3 significant file(s) lose their only recent owner: crates/ty_project/src/uv/metadata/dependencies.rs, crates/ty_ide/src/markup.rs, crates/ty_project/src/uv/metadata/string_interner.rs. Pair on, review, or document these before any departure.
X7 · Silent fallback defaults · Silent fallback default on Err · ×4
  • Silent fallback default on Err crates/ruff/src/commands/show_files.rs:31 — `show_files` turns every `Err` into `true` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/ruff/src/version.rs:62 — `version` turns every `Err` into `0` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/ty/src/version.rs:65 — `version` turns every `Err` into `0` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
  • Silent fallback default on Err crates/ty_ide/src/code_action.rs:29 — `code_actions` turns every `Err` into `Vec::new()` — a failure becomes a plausible value and a silent behavior change with no trail. Log the error or propagate it with `?`. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the arm or in the doc comment, and the row stops firing.
D16 · Bus Factor · Further sole-owners (lower concentration) · ×1
  • Further sole-owners (lower concentration) — 3 other contributor(s) are each the sole owner of a small amount of code below the off-boarding threshold — folded into the bus-factor score and metrics (61 single-owned of 1433 analysed files in total, counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 1433 of the 2875 production source files in this repository met that bar). They are anonymized user #6 (1 file(s)), anonymized user #7 (1 file(s)), anonymized user #8 (1 file(s)) — spread or document their files in the same way, at lower priority than the named off-boarding risks above. The files folded here: crates/ruff_annotate_snippets/src/renderer/source_map.rs, crates/ruff_python_literal/src/cformat.rs, crates/ruff_db/src/system/walk_directory.rs.
D19 · Documentation Quality · Documentation · ×1
  • Documentation: no build, run or usage example playground/api/README.md:1 — `api` is runnable (a `start` script in `package.json`) and neither `playground/api/README.md` nor the documents it links hold a code block or a command. Show the command that builds or runs it, or a usage snippet.
D20 · ADR Quality · No ADRs found · ×1
  • No ADRs found REDACTED:11 — No ADRs found. No recognised ADR directory (`docs/adr/`, `docs/decisions/`, `adr/`, `docs/rfcs/`, an `ADR0001/` folder, or their siblings) exists anywhere in this tree. What was searched, so you can tell an empty log from a search that missed one: every directory under the tree (build output, dependencies and VCS metadata excepted), for a document that is either any non-index page inside a recognised ADR directory, whatever its name and however deeply nested (`docs/adr/use-postgres.md`, `docs/adr/2024/0001-x.md`); or a file anywhere whose name is ADR-shaped (`0001-use-postgres.md`, `adr-012-caching.md`); or, when neither turned anything up, a document carrying the decision-record signature (an "Architecture Decision Record" heading, or Status / Context / Decision / Consequences as section headings). A decision log that clears none of these — unnumbered files outside any recognised directory, without those headings — is not seen by this check and this row is then wrong. If that is your case, say so rather than renaming anything; otherwise, consider recording architectural decisions in `docs/adr/`. ADRs are expected here because `REDACTED` makes this repository a deployable product (line 11).
D24 · Comment Value · redundant comment · ×1
  • redundant comment docs/js/extra.js:24 — "all "copy" buttons whose target selector is a <code> element" repeats the code it sits on: 5 of its 6 words (buttons, target, selector, code, element) are already in `const elements = document.querySelectorAll(`. Delete it, or replace it with what the code cannot say (why it is done here, a constraint, or a consequence).
D26 · Project Cohesion · Projects may be oversized for their cohesion · ×1
  • Projects may be oversized for their cohesion — 6 of 58 project(s) overshoot their size bounds, lowering Project Cohesion to 7.9/10. The most over is `crates/ty_python_semantic` (217437 LoC, 330 module-visible types across 23 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D34 · Knowledge Freshness · Orphaned files with no living knowledge · ×1
  • Orphaned files with no living knowledge — 95 of 1433 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 1433 of the 2875 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: crates/ty_python_core/src/builder/loop_bindings_visitor.rs, crates/ruff_linter/src/rules/flake8_copyright/mod.rs, crates/ty_ide/src/call_hierarchy.rs, crates/ruff_linter/src/rules/airflow/rules/suggested_to_update_3_0.rs, crates/ruff_linter/src/rules/ruff/rules/assert_with_print_message.rs, crates/ruff_linter/src/rules/flake8_todos/rules/todos.rs, crates/ruff_linter/src/rules/airflow/rules/suggested_to_move_to_provider_in_3.rs, crates/ruff_server/src/server/schedule/thread/priority.rs (and 87 more). Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
P2 · Observability · Logging is not universal · ×1
  • Logging is not universal — Only 25/29 runnable modules use logging (modules with no entry point or server are excluded — they are libraries a runnable module hosts). Silent: `.`, `crates/ty_completion_bench`, `crates/ty_completion_eval`, `python/py-fuzzer`.
P3 · Security & performance tooling · No dependency-update automation · ×1
  • No dependency-update automation playground/api/package.json:7 — `playground/api/package.json` declares packages, and nothing in the repository keeps them current: no Dependabot or Renovate configuration that schedules updates, and no dependency-review gate on pull requests. A pinned dependency stays at the version it was added at until someone notices — including after an advisory is published against it. Add a `.github/dependabot.yml` with one `package-ecosystem` entry per ecosystem the tree uses (or an enabled `renovate.json`), and gate pull requests with `actions/dependency-review-action`.
X2 · Cancellation propagation · Not all async functions that make a request accept an AbortSignal · ×1
  • Not all async functions that make a request accept an AbortSignal — Only 0/4 async functions that make a cancellable request (fetch, axios, ky, ofetch, got, undici, node:http) accept an AbortSignal or pass one on, so a request keeps running after whatever wanted it has given up — a page navigated away from, an unmounted component, a timed-out job. Take a `signal` (or an options object that carries one) and hand it to the request; where nothing could ever cancel the call, omitting it is a deliberate choice — judge against how the function is used.
X5 · Nullable reference types · Strict null checking is not enabled everywhere the repository type-checks · ×1
  • Strict null checking is not enabled everywhere the repository type-checks — 2/3 of this repository's type-checking configuration(s) turn on strict null checking (`"strict": true`, or `"strictNullChecks": true`). A configuration that states neither is counted as OFF, because off is tsc's own default; a solution-style one whose `"files"` is empty and whose `"references"` point at other projects is in neither number, because it checks no source itself. Where it is off, `string` admits `null` and `undefined`: passing a value that is null compiles silently and throws on the first property access.
X5 · Nullable reference types · Null assertions (`!`) override strict null checking · ×1
  • Null assertions (`!`) override strict null checking — ~0.7 `!` null assertions per 1k TypeScript source lines — 5 assertion(s) across the 7291 source line(s) of the 43 TypeScript file(s) read, which is the only code the operator asserts anything in (a `!` in a `.js` file is not this operator and was not counted, and one in a file whose null checking is off silences nothing). Densest: playground/ruff/src/Editor/Editor.tsx (2), playground/ruff/src/Editor/SecondaryPanel.tsx (2), playground/ruff/src/Editor/settings.ts (1). Each one tells the compiler to trust the author about null, suppressing the very diagnostic `strictNullChecks` exists to produce. Many are correct: each is a claim the checker could not verify, and it is wrong only where the value can in fact be missing, so review the densest places first.
Minor — 23 finding(s)
D12 · Dependency Hygiene · Outdated · ×21
  • Outdated: arc-swap — `arc-swap` is locked at 1.9.2 but 1.9.5 is the current stable release on crates.io, and it already satisfies the `"1.7.1"` requirement declared in crates/ruff_db/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p arc-swap` and commit the updated REDACTED.
  • Outdated: globset — `globset` is locked at 0.4.20 but 0.4.21 is the current stable release on crates.io, and it already satisfies the `"0.4.14"` requirement declared in crates/ruff_cache/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p globset` and commit the updated REDACTED.
  • Outdated: icu_normalizer — `icu_normalizer` is locked at 2.3.0 but 2.4.0 is the current stable release on crates.io, and it already satisfies the `"2.1.2"` requirement declared in crates/ruff_python_literal/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p icu_normalizer` and commit the updated REDACTED.
  • Outdated: icu_properties — `icu_properties` is locked at 2.3.0 but 2.4.0 is the current stable release on crates.io, and it already satisfies the `"2.1.2"` requirement declared in crates/ruff_python_literal/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p icu_properties` and commit the updated REDACTED.
  • Outdated: ignore — `ignore` is locked at 0.4.33 but 0.4.34 is the current stable release on crates.io, and it already satisfies the `"0.4.30"` requirement declared in crates/ruff/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p ignore` and commit the updated REDACTED.
  • Outdated: jiff — `jiff` is locked at 0.2.38 but 0.2.43 is the current stable release on crates.io, and it already satisfies the `"0.2.0"` requirement declared in crates/ruff/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p jiff` and commit the updated REDACTED.
  • Outdated: js-sys — `js-sys` is locked at 0.3.100 but 0.3.107 is the current stable release on crates.io, and it already satisfies the `"0.3.69"` requirement declared in crates/ruff_wasm/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p js-sys` and commit the updated REDACTED.
  • Outdated: libc — `libc` is locked at 0.2.190 but 0.2.191 is the current stable release on crates.io, and it already satisfies the `"0.2.153"` requirement declared in crates/ruff_server/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p libc` and commit the updated REDACTED.
  • Outdated: log — `log` is locked at 0.4.34 but 0.4.35 is the current stable release on crates.io, and it already satisfies the `"0.4.17"` requirement declared in crates/ruff/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p log` and commit the updated REDACTED.
  • Outdated: notify — `notify` is locked at 8.2.0 but 8.2.2 is the current stable release on crates.io, and it already satisfies the `"8.0.0"` requirement declared in crates/ruff/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p notify` and commit the updated REDACTED.
  • Outdated: schemars — `schemars` is locked at 1.2.2 but 1.2.3 is the current stable release on crates.io, and it already satisfies the `"1.0.4"` requirement declared in crates/ruff_db/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p schemars` and commit the updated REDACTED.
  • Outdated: similar — `similar` is locked at 3.2.0 but 3.2.1 is the current stable release on crates.io, and it already satisfies the `"3.0.0"` requirement declared in fuzz/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p similar` and commit the updated REDACTED.
  • Outdated: smallvec — `smallvec` is locked at 1.16.3 but 1.16.5 is the current stable release on crates.io, and it already satisfies the `"1.13.2"` requirement declared in crates/mdtest/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p smallvec` and commit the updated REDACTED.
  • Outdated: syn — `syn` is locked at 3.0.8 but 3.0.10 is the current stable release on crates.io, and it already satisfies the `"3.0.0"` requirement declared in crates/ruff_macros/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p syn` and commit the updated REDACTED.
  • Outdated: toml — `toml` is locked at 1.1.8+spec-1.1.0 but 1.2.1+spec-1.1.0 is the current stable release on crates.io, and it already satisfies the `"1.0.0"` requirement declared in crates/mdtest/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p toml` and commit the updated REDACTED.
  • Outdated: unicode-ident — `unicode-ident` is locked at 1.0.24 but 1.0.27 is the current stable release on crates.io, and it already satisfies the `"1.0.12"` requirement declared in crates/ruff_python_parser/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p unicode-ident` and commit the updated REDACTED.
  • Outdated: unicode-normalization — `unicode-normalization` is locked at 0.1.25 but 0.1.26 is the current stable release on crates.io, and it already satisfies the `"0.1.23"` requirement declared in crates/ruff_linter/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p unicode-normalization` and commit the updated REDACTED.
  • Outdated: unicode-width — `unicode-width` is locked at 0.2.2 but 0.2.3 is the current stable release on crates.io, and it already satisfies the `"0.2.0"` requirement declared in crates/ruff_annotate_snippets/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p unicode-width` and commit the updated REDACTED.
  • Outdated: uuid — `uuid` is locked at 1.28.0 but 1.29.2 is the current stable release on crates.io, and it already satisfies the `"1.6.1"` requirement declared in crates/ruff_notebook/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p uuid` and commit the updated REDACTED.
  • Outdated: wasm-bindgen — `wasm-bindgen` is locked at 0.2.123 but 0.2.130 is the current stable release on crates.io, and it already satisfies the `"0.2.92"` requirement declared in crates/ruff_wasm/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p wasm-bindgen` and commit the updated REDACTED.
  • Outdated: zip — `zip` is locked at 9.0.5 but 9.5.1 is the current stable release on crates.io, and it already satisfies the `"9.0.5"` requirement declared in crates/ruff_db/Cargo.toml — so the lockfile is behind this repository's own declared range. Run `cargo update -p zip` and commit the updated REDACTED.
D24 · Comment Value · doc comments repeat the names · ×1
  • doc comments repeat the names playground/ty/src/Editor/markdown.ts:20 — 0 of 3 documented parameters and 1 of 18 summaries in `ty-playground` only repeat the member or parameter name (e.g. "Generate a markdown link to the playground." for `generatePlaygroundMarkdownLink`). Delete the restating tags, or add what the name does not say.
D5 · Coupling · Off the main sequence · ×1
  • Off the main sequence: shared — shared: abstractness 0.06, instability 0.00, distance 0.94 — the shape a shared-kernel / building-block library has BY DESIGN — concrete and widely depended-on is what makes it useful, and this dimension does not penalise it (the distance is reported for completeness, not as a defect). Worth a look only if it has grown past one coherent kernel into an everything-bucket.

Appendix B — Reproduction & audit trail

Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-d1744c62ae8d40838b85de5d7e7ea6a4/history.json --exit-code 0 --source .0artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-d1744c62ae8d40838b85de5d7e7ea6a4/tree.json --exit-code 0 --source .0artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/canine-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt .71artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** .5artifacts/raw/trivy-fs.json
D31 · IaC & Container Securitytrivy—trivy config --format json --quiet .4artifacts/raw/trivy-config.json
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that. semgrep could not parse 364 file(s) — `crates/ruff_benchmark/resources/typeis_narrowing.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_invalid_annotation.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_invalid_target.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_invalid_value.py`, `crates/ruff_python_parser/resources/inline/err/ann_assign_stmt_missing_rhs.py`, … (+359 more) — so the PII/GDPR sweep did not cover the unparsed regions of them; rows reported elsewhere in those files are real.0—
D37 · Vulnerability-disclosure Policydisclosure—disclosure: not applicable — No vulnerability-disclosure policy file found (SECURITY.md/.markdown/.rst/.txt at root or under .github/.forgejo/.gitea/docs, .well-known/security.txt). A coordinated-disclosure policy may live off-repo, so this is not evidenced rather than failed.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciestrivy—trivy fs --scanners vuln --format json --quiet --severity CRITICAL,HIGH,MEDIUM,LOW --skip-dirs **/bin/** --skip-dirs **/obj/** .0artifacts/raw/trivy-fs.json

Run 01a1d8a5-8089-770e-82c3-1456acfe3ce2 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md