Skip to content

8.3.0

Latest

Choose a tag to compare

@rohaquinlop rohaquinlop released this 27 Oct 05:03
· 8 commits to main since this release
710ee3a

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 --diff or --staged shows which functions fail it. A REGRESSED or NEW function above the threshold is listed as FAILED and marked FAILS in the diff table, which ends with a Gate: line that counts them. A function above the threshold that the gate lets through is listed as ALLOWED instead of FAILED, and --failed lists only the functions that fail the run. A snapshot run lists the functions its snapshot lets through as ALLOWED too, instead of PASSED. (#305)
  • SARIF output is diff-aware. With a diff, every result carries the baselineState of its function, new, unchanged, or updated, against the reference, and when the diff decides the exit code a complexity result's level is error for a function that fails the run, through the gate or the snapshot, and note for one the run lets through. The GitLab Code Quality report rates the same functions major and info. Fingerprints are unchanged. (#305)

Fixed

  • --diff and --diff-only read each file from the repository that holds it, so a run from outside the repository compares against the ref instead of reporting every function as NEW. 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 as NEW, and the run now prints a warning that names the cause. (#291)
  • --diff-only alone no longer warns that --diff and --diff-only are both set. (#291)
  • --staged compares only the staged files the run selects: the path arguments, paths, and exclude apply as they do without it, so complexipy one.py --staged no 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 as REMOVED: under a selected directory, outside hidden paths, and not matched by exclude, .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 --diff or --staged when 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 a REMOVED function 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 a Gate column, the REMOVED function each passing one replaces. has_regressions sees no bodies, so it still fails a moved function above the threshold. A function that an ignore comment now hides is not reported as REMOVED. A deleted Python file that discovery would have selected reports its functions as REMOVED in --diff too, 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-create records the function again, and a snapshot rewrite drops the entries of files that no longer exist. (#305)
  • --diff reports the functions of a file that does not parse at the reference as NEW, as --staged does, instead of leaving the file out of the comparison. (#305)
  • The C002 loop guard negates its condition the way a linter expects: x in y becomes x not in y, a is b becomes a is not b, and a name or a call gets a bare not, so --fix no longer writes E713/E714 violations. Parentheses stay around and, or, other comparisons, conditional expressions, lambdas, and walrus assignments. (#291)

Documentation

  • The README and the docs state that --diff, --diff-only, and --staged need Git 2.30 or newer on the PATH, and that analysis without these options does not need Git. (#301)

PRs

New Contributors

Full Changelog: 8.2.0...8.3.0