Repository navigation
fix(complexity): point the nesting suggestion at the deepest block - #874
Merged
DaisukeYoda merged 1 commit intoNov 2, 2026
Merged
Conversation
DaisukeYoda
self-requested a review
November 2, 2026 12:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
For functions nested deeper than 4 levels, the suggestion step "Identify the deepest nested block at line N" always printed the function's
defline.CalculateMaxNestingDepthalready finds the right line, butCalculateComplexityWithConfigonly keptMaxDepth. This carriesDeepestNestingLinethroughanalyzer.ComplexityResultintodomain.ComplexityMetricsand uses it in the suggestion.Type of Change
Related Issues
Fixes #870
Changes
internal/analyzer/complexity.go: keepDeepestNestingLinefrom the nesting result inComplexityResultdomain/complexity.go: addDeepestNestingLinetoComplexityMetrics, exposed asdeepest_nesting_line, and list it inwebsite/docs/output/schemas.mdservice/complexity_service.go: map it into the domain metricsdomain/suggestion.go: use it in the nesting step, falling back toStartLinewhen it is 0Testing
make testpasses locally (the new and touched tests pass; see below for the rest)make lintpasses locally (go vetis clean; gofmt is clean on the changed files, see below)I ran these on Windows, where some existing tests fail on
mainas well (path separators in the module rollups, OS error text infile_reader_test.go), andgolangci-lintreports gofmt on three files this PR doesn't touch because of the CRLF checkout. Both are the same with and without this change. The new tests pass, and fail without the fix.Verified Against a Real Project
5acb8ff1(the project from the issue)pyscn analyze --json --no-open --select complexity pygame_menudeflines to the deepest blocks, e.g.Menu.update2683 → 3015 andRangeSlider.update1164 → 1322 (both checked in the source). Scores and other findings are unchanged.Documentation
Additional Context