Repository navigation
Minor release: a clearer and more correct --diff gate. A run gated by --diff or --staged now shows which functions fail it, and SARIF output is diff-aware (#305). --diff works from outside the repository and inside submodules, --staged respects the selected paths, and a renamed or moved function no longer fails the gate (#291, #305). --fix writes loop guards that linters accept (#291).
Added
- A run gated by
--diffor--stagedshows which functions fail it. A REGRESSED or NEW function above the threshold is listed asFAILEDand markedFAILSin the diff table, which ends with aGate:line that counts them. A function above the threshold that the gate lets through is listed asALLOWEDinstead ofFAILED, and--failedlists only the functions that fail the run. A snapshot run lists the functions its snapshot lets through asALLOWEDtoo, instead ofPASSED. (#305) - SARIF output is diff-aware. With a diff, every result carries the
baselineStateof its function,new,unchanged, orupdated, against the reference, and when the diff decides the exit code a complexity result'sleveliserrorfor a function that fails the run, through the gate or the snapshot, andnotefor one the run lets through. The GitLab Code Quality report rates the same functionsmajorandinfo. Fingerprints are unchanged. (#305)
Fixed
--diffand--diff-onlyread each file from the repository that holds it, so a run from outside the repository compares against the ref instead of reporting every function asNEW. A submodule, a repository that the repository around it tracks as a gitlink, is read at the commit the outer repository pins for it at the ref, unless the run starts inside it. A file outside any repository, a ref that names no commit in the file's repository, or a submodule without a pinned commit it has, still reports its functions asNEW, and the run now prints a warning that names the cause. (#291)--diff-onlyalone no longer warns that--diffand--diff-onlyare both set. (#291)--stagedcompares only the staged files the run selects: the path arguments,paths, andexcludeapply as they do without it, socomplexipy one.py --stagedno longer reports the other staged files. They apply to the index, so a staged regular file is compared whatever the working tree holds at its path. A staged deletion that discovery would have selected still reports its functions asREMOVED: under a selected directory, outside hidden paths, and not matched byexclude,.gitignore,.ignore, or git's exclude file. Each file is named by the path the rest of the run reports. (#305)- A rename or a move no longer fails
--diffor--stagedwhen the function's body stays as it was. A file that git pairs as renamed compares with its old path when the run covers that path, and as added when it moves in from outside the selected paths; a file moved out of them reports nothing. A function above the threshold that the change adds passes only when it replaces aREMOVEDfunction with the same body and at least its complexity, each removed function replaced once, and the compared files (modified, renamed from a covered path, deleted from a covered path, or added) do not hold more functions with that body than they did at the ref, counting the functions that ignore comments hide. Bodies count and pair only within the repository that holds each file. Bodies compare structurally, without formatting, comments, the name, the decorators, or the parameters, so a function or class rename, a move to another file, and a method that becomes a function pass, and a function that moves and changes fails. The diff table names, in aGatecolumn, theREMOVEDfunction each passing one replaces.has_regressionssees no bodies, so it still fails a moved function above the threshold. A function that an ignore comment now hides is not reported asREMOVED. A deleted Python file that discovery would have selected reports its functions asREMOVEDin--difftoo, and a deleted symbolic link reports nothing. The snapshot gate does not pair functions: a moved or renamed function above the threshold fails it until--snapshot-createrecords the function again, and a snapshot rewrite drops the entries of files that no longer exist. (#305) --diffreports the functions of a file that does not parse at the reference asNEW, as--stageddoes, instead of leaving the file out of the comparison. (#305)- The
C002loop guard negates its condition the way a linter expects:x in ybecomesx not in y,a is bbecomesa is not b, and a name or a call gets a barenot, so--fixno longer writesE713/E714violations. Parentheses stay aroundand,or, other comparisons, conditional expressions, lambdas, and walrus assignments. (#291)
Documentation
- The README and the docs state that
--diff,--diff-only, and--stagedneed Git 2.30 or newer on thePATH, and that analysis without these options does not need Git. (#301)
PRs
- fix: compare --diff from any directory and write lint-clean --fix guards by @dsfaccini in #291
- fix(diff): follow renames, scope --staged, and show the gate's verdict by @dsfaccini in #305
- docs(diff): state minimum git version by @awais-ur-rehman in #301
- chore(release): release 8.3.0 by @rohaquinlop in #306
New Contributors
- @awais-ur-rehman made their first contribution in #301
Full Changelog: 8.2.0...8.3.0