Skip to content

Chore/prep for v1#37

Merged
itaymendel merged 10 commits intomainfrom
chore/prep-for-v1
Feb 8, 2026
Merged

Chore/prep for v1#37
itaymendel merged 10 commits intomainfrom
chore/prep-for-v1

Conversation

@itaymendel
Copy link
Owner

@itaymendel itaymendel commented Feb 8, 2026

Summary by CodeRabbit

  • New Features

    • Single unified complexity rule (cyclomatic + cognitive) with minLines toggle (default 10); enhanced extraction APIs and detection (external property/method mutations and this references).
  • Deprecated

    • max-cyclomatic and max-cognitive superseded by complexity.
  • Documentation

    • Updated README, CONTRIBUTING, and CHANGELOG with migration guidance and new configuration examples.
  • Tests

    • Added/expanded tests for combined complexity, minLines, and smart extraction detection.
  • Chores

    • Bumped package to 1.0.0-rc.2; added Dependabot ignore for semver-major updates to @types/node.

@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

Adds a single-pass combined complexity visitor and new complexity rule, refactors rule/shared helpers, enhances extraction (AST mutation detection and this-reference), exposes extraction APIs, removes React JSX detection, updates utilities and docs, and adds/adjusts extensive tests and test helpers.

Changes

Cohort / File(s) Summary
Configuration & Docs
\.github/dependabot.yml, CHANGELOG.md, CONTRIBUTING.md, README.md, package.json, .oxlintrc.json
Dependabot ignore for @types/node semver-major; package version bumped; docs switched npm→pnpm and updated to use consolidated complexity rule; changelog and example config updated.
Combined Complexity & Visitors
src/combined-visitor.ts, src/visitor.ts, src/cyclomatic.ts, src/cognitive/patterns.ts, src/cognitive/visitor.ts
New single-pass combined cyclomatic+cognitive visitor and related visitor refactors; unified node-handling, includes helper usage, and removal of isReactComponent tracking.
Rules Refactor & New Rules
src/rules/shared.ts, src/rules/complexity.ts, src/rules/max-cognitive.ts, src/rules/max-cyclomatic.ts, src/rules.ts
Removed monolithic rules file; added shared rule helpers; introduced complexity rule (single metric entry) and reintroduced focused max-* modules with migration/deprecation wiring.
Extraction Engine & Types
src/extraction/flow-analyzer.ts, src/extraction/boundary-detector.ts, src/extraction/suggestion-generator.ts, src/extraction/types.ts, src/extraction/index.ts, src/extraction/variable-tracker.ts
Added AST-based mutation detection (property assignments, updates, mutating method calls), range-walking helpers, deduplication, this-reference detection; analyzeVariableFlow now accepts functionNode; new this-reference issue type.
Utilities
src/utils.ts
Introduced type-safe includes, LOGICAL_ASSIGNMENT_OPERATORS, extractConstructFromMessage, and refactored name-extraction utilities used across summaries and breakdowns.
React detection removal
src/cognitive/react.ts
Deleted React JSX detection utilities and removed isReactComponent export.
Public API & Exports
src/index.ts
Re-exported extraction types and utilities; registered new complexity rule alongside legacy exports.
Tests & Test Helpers
tests/utils/test-helpers.ts, tests/utils/extraction-helpers.ts, tests/complexity.test.ts, tests/minlines.test.ts, tests/extraction-*.test.ts, tests/*
Added combined-complexity test helpers, extraction helpers, and comprehensive tests for mutation detection, this-reference handling, minLines behavior; refactored existing extraction tests to use shared helpers.
Misc small edits
src/cognitive/react.ts (removed), src/extraction/boundary-detector.ts (small change)
Minor refactors: replace in-file parsing with util extractors; small membership and import cleanups.

Sequence Diagram(s)

sequenceDiagram
    participant Analyzer as Analyzer
    participant Combined as CombinedVisitor
    participant Scope as FunctionScope
    participant Points as PointsCollector

    Analyzer->>Combined: walk AST
    Combined->>Scope: enter function (push scope)
    loop traverse nodes
        Combined->>Combined: detect control-flow / logical ops / recursion
        Combined->>Points: add cyclomatic point
        Combined->>Points: add cognitive point
        Combined->>Scope: update nesting / record points
    end
    Combined->>Scope: exit function (pop scope)
    Combined->>Analyzer: report CombinedComplexityResult (cyclomatic, cognitive, points)
Loading
sequenceDiagram
    participant FlowAnalyzer as Flow Analyzer
    participant AST as AST Walker
    participant Direct as DirectMutationChecker
    participant Prop as PropertyMutationChecker
    participant Dedup as Deduplicator

    FlowAnalyzer->>FlowAnalyzer: prepare candidate range
    par detect paths
        FlowAnalyzer->>Direct: check direct reassignments in range
        FlowAnalyzer->>AST: walk range (skip nested functions)
        AST->>Prop: detect property updates & mutating method calls
        Prop->>FlowAnalyzer: return AST-based mutations
    and
        Direct->>FlowAnalyzer: return direct mutations
    end
    FlowAnalyzer->>Dedup: combine and deduplicate mutations + detect this-reference
    Dedup->>FlowAnalyzer: return unique mutations + hasThisReference
    FlowAnalyzer->>Client: return VariableFlowAnalysis
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Poem

🐰 I hopped through nodes where functions hide,
I counted branches, nesting deep inside.
I sniffed for mutations and a secret "this",
One pass, two metrics—oh what bliss! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 23.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Chore/prep for v1' is vague and generic, using non-descriptive terms that don't convey meaningful information about the substantial changes in the changeset. Provide a more specific title that captures the main changes, such as 'Combine cyclomatic and cognitive complexity rules into single rule' or 'Refactor complexity rules and consolidate to v1.0.0-rc.2'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/prep-for-v1

No actionable comments were generated in the recent review. 🎉


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

39-52: ⚠️ Potential issue | 🟡 Minor

Add a language identifier to the fenced output block.
This addresses the MD040 warning and improves tooling support.

📝 Suggested fix
-```
+```text
```
🤖 Fix all issues with AI agents
In `@package.json`:
- Line 48: The "benchmark" npm script currently tries to run a TypeScript file
with node ("benchmark": "node benchmarks/run-benchmark.ts"), which won't work;
update the "benchmark" script to invoke a TypeScript runner (e.g., use "tsx"
like the other profile scripts) so benchmarks/run-benchmark.ts is executed via
tsx (or another configured TS runner) instead of node.

In `@README.md`:
- Around line 148-155: Change the heading for "Known Limitations" to the correct
level to avoid a markdown heading-level jump (MD001); locate the "Known
Limitations" heading (currently "##### Known Limitations") and adjust the number
of '#' characters so it follows the previous section's level (e.g., change to
"#### Known Limitations" or "### Known Limitations" as appropriate) so heading
depth increments/decrements by only one level relative to its surrounding
headings.
- Around line 74-123: Remove the outdated React component exclusion from the
"Cognitive Complexity" docs: edit the "Cognitive Complexity" section (the header
and its bullets) to delete the phrase "React components (PascalCase + returns
JSX)" from the "Excluded" line and ensure the remaining exclusion examples
(e.g., default value patterns like `a || []`) are kept accurate; update any
adjacent explanatory text or examples that reference React components so the
docs match the current implementation.

In `@src/rules/shared.ts`:
- Around line 109-123: warnDeprecated currently prints a deprecation warning
each time createOnce's before() runs (once per file); add a module-level
deduplication flag (e.g., let warned = false) and update warnDeprecated to
check/set that flag so it only logs the message the first time it's invoked;
reference the existing warnDeprecated function and the createOnce/before() usage
when making the change.

In `@tests/extraction-flow.test.ts`:
- Around line 159-166: Tests build ExtractionCandidate objects using
result.points.map(p => p.construct) but ComplexityPoint has no construct field;
replace that pattern by mapping the messages through
extractConstructFromMessage. Extract this into a helper (e.g.,
buildCandidateForRange) that accepts an ExtendedResult and start/end offsets,
computes funcStart/funcEnd from result.node.loc, sets startLine/endLine,
complexity, complexityPercentage, points: result.points, and constructs:
result.points.map(p => extractConstructFromMessage(p.message)); update all
occurrences (the repeated blocks around lines mentioned) to call this helper.

In `@tests/utils/extraction-helpers.ts`:
- Around line 66-69: The call in analyzeFlowFromResult passes a fourth argument
functionEndLine to analyzeVariableFlow but analyzeVariableFlow’s signature only
accepts (candidate, variables, functionNode); update the call (in
analyzeFlowFromResult) to remove the extra argument and call
analyzeVariableFlow(candidate, result.variables, result.node) or alternatively,
if functionEndLine is required, update the analyzeVariableFlow function
signature in src/extraction/flow-analyzer.ts to accept a fourth parameter (e.g.,
functionEndLine) and wire it through its implementation; reference symbols:
analyzeFlowFromResult, analyzeVariableFlow, buildCandidateFromResult,
ExtendedResult, VariableFlowAnalysis, functionEndLine.
- Around line 55-64: The buildCandidateFromResult function is using p.construct
(which doesn't exist on ComplexityPoint), so update it to derive constructs via
extractConstructFromMessage: import extractConstructFromMessage from
src/utils.ts and replace constructs: result.points.map(p => p.construct) with
constructs: result.points.map(p => extractConstructFromMessage(p.message)),
ensuring you reference buildCandidateFromResult and ComplexityPoint when making
the change.

@itaymendel itaymendel merged commit 70232f1 into main Feb 8, 2026
2 checks passed
@itaymendel itaymendel deleted the chore/prep-for-v1 branch February 8, 2026 12:51
@coderabbitai coderabbitai bot mentioned this pull request Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant