Conversation
_analyze_functions opened a new function only on begins_with("func "), which a
static declaration does not match. Two things followed from that single test.
The static function was never analysed, so no length, parameter, nesting,
complexity or return type check ever saw it.
Its body was appended to the function above, because the parser was still
inside that one, inflating that function's reported length and complexity.
Normalising a leading "static " before the test keeps the substr(5) assumption
in _parse_function_signature valid and fixes both.
Measured on a probe project against this tree. A two line function followed by
an eight line static function was reported at 12 lines and is now not reported
at all; the static function was reported not at all and is now reported at its
own 9 lines.
Same root as the open report about annotations in front of a declaration: the
parser decides what a declaration is from the text of one line. ignore-handler
and strict-handler have the same blind spot for their own ranges, which this
commit deliberately leaves alone.
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.
Fixes the two symptoms reported in #17.
_analyze_functionsopened a new function only onbegins_with("func "), which a static declaration does not match, so the static function was never analysed and its body was appended to the function above it. Normalising a leadingstaticbefore the test fixes both and keeps thesubstr(5)assumption in_parse_function_signaturevalid.Measured on a probe project against this tree, a two line function followed by an eight line static function:
ignore-handler.gdandstrict-handler.gddecide their own ranges the same way and have the same blind spot for astatic funcboundary. This change leaves them alone so the diff stays in one file; happy to follow up if you would like them in the same shape.Same root as #15: the parser decides what a declaration is from the text of one line, so an annotation breaks it there and
staticbreaks it here.