Repository navigation
feat: add checkstyle, junit, sarif, gitlab-codequality and github-actions reports - #15
Merged
Merged
Conversation
…ions reports CI tools and code hosts read violations in their own formats, so the analyse command can now write them next to the existing JSON, CSV, HTML and Markdown. Each format lists the methods whose score is above scoreThreshold. Paths are relative to the working directory with / separators when the file is below it, and absolute otherwise. Nothing is stripped from a path, which fixes the leading-character bug of the PHP implementation. Fingerprints are SHA-256 over the reported path, line, class and method, so they identify a finding across runs on different machines. The SARIF tool name is the product name cognitive-analysis, as in the command and the jar.
…ng PIT survivors The help of --report-type listed a hardcoded subset of the formats. It now completes from ReportType.commandNames(), so a new format shows up without an edit to the command. The SARIF goldens contained the build version of the tool driver, so every version bump changed them. The version is masked before the comparison. The null-message fallback in ReportWriter is a single expression now, so the conditional PIT mutated is gone without changing the behaviour. The interrupt path of the git wait is covered by a test that keeps the interrupt flag.
SARIF reads artifactLocation.uri as an RFC 3986 URI reference. Paths were written raw, so a space, # or % in a directory name produced an invalid location, and an absolute path was not a file URI. Paths inside the working directory are now percent-encoded per segment against the %SRCROOT% base, which run.originalUriBaseIds points at the working directory as a file URI. Absolute paths outside it are file URIs, Windows drive letters included, converted from the string so the result is the same on every platform. The other formats keep the plain path. A method line below one is reported as one, since the issue formats cannot express a line before the first, which SARIF and GitLab reject.
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
Adds five report types to
analyse --report-typefor CI tools and code hosts:checkstyle,junit,sarif,gitlab-codequalityandgithub-actions.Each one lists the methods whose score is above
scoreThreshold.8.0), onefileelement per file, severityerrorat twice the threshold or more.cognitive-complexity, levelserrorandwarning, and aprimaryLocationLineHashfingerprint.blockerfrom 3,criticalfrom 2,majorfrom 1.5,minorotherwise.Paths are relative to the working directory with
/separators when the file is below it, and absolute otherwise.Nothing is stripped from a path, which fixes the leading-character bug of the PHP implementation (PHP #79).
The shared pieces live in
ReportSupport: path normalisation, the violation filter, severity ratio checks, the issue message, the fingerprint, the JSON printer (now also used byJsonReport) and the XML serialiser.Decisions
The reported path is stable across checkouts, so the fingerprint identifies a finding across CI machines.
cognitive-analysis, the name of the command and the jar.jcca-build.propertiesand is left out when the build did not filter it in.infoseverity was dropped, because only violations reach the severity mapping and those are always above the threshold.Test plan
<,&,",|, backslashes and non-ASCII names.%, line feeds, commas and colons in the file and the message.0.3 * 3is not exact../and dot-directory names, relative paths leaving the directory, and Windows-style separators.path:line:class::method, and movement of the fingerprint when the line changes.App, with golden files, and the error message for an unknown type lists all names../mvnw -B verifyis green: JaCoCo line and branch coverage at or above 90%, PIT mutation score 99% on the configured packages.reportpackage has 96.8% line and 95.9% branch coverage.Docs:
docs/Reports.mddescribes each format, and the README lists the report types.