Report static code analysis to Bitbucket Server.




Report static code analysis to Bitbucket Server. It uses the Violations Lib.
| Version | Java Version |
| ------------------| ------------ |
| version < 2.0.0 | 8 |
| 2.0.0 -> 2.2.1 | 11 |
| 2.3.0 <= version | 17 |
- The runnable jar can be found in Maven Central and used like java -jar violation-comments-to-bitbucket-server-command-line-*.jar .....
- The runnable can be found in NPM.
- The Docker image can be found in Dockerhub and used like docker run --mount src="$(pwd)",target=/usr/src/violation-comments-to-bitbucket-server-command-line,type=bind tomasbjerre/violation-comments-to-bitbucket-server-command-line:X.
Run it with:
``shell`
npx violation-comments-to-bitbucket-server-command-line \
-pat TOKENHERE \
-pk PROJECT_KEY \
-rs REPO_SLUT \
-prid 1234 \
-v "CHECKSTYLE" "." ".*checkstyle/main\.xml$" "Checkstyle" \
-v "JSHINT" "." ".*jshint/report\.xml$" "JSHint"
You must perform the merge before build. If you don't perform the merge, the reported violations will refer to other lines then those in the pull request. The merge can be done with a shell script like this.
`
echo ---
echo --- Merging from $FROM in $FROMREPO to $TO in $TOREPO
echo ---
git clone $TOREPO
cd *
git reset --hard $TO
git status
git remote add from $FROMREPO
git fetch from
git merge $FROM
git --no-pager log --max-count=10 --graph --abbrev-commit
Your build command here!
`
Example of supported reports are available here.
A number of parsers have been implemented. Some parsers can parse output from several reporters.
| Reporter | Parser | Notes
| --- | --- | ---
| _ARM-GCC_ | CLANG | ANDROIDLINT
| _AndroidLint_ | | ANSIBLELATER
| _Ansible-Later_ | | With json formatFLAKE8
| _AnsibleLint_ | | With -pCLANG
| _Bandit_ | | With bandit -r examples/ -f custom -o bandit.out --msg-template "{abspath}:{line}: {severity}: {test_id}: {msg}"CLANG
| _CLang_ | | CPD
| _CPD_ | | CPPCHECK
| _CPPCheck_ | | With cppcheck test.cpp --output-file=cppcheck.xml --xmlCPPLINT
| _CPPLint_ | | CSSLINT
| _CSSLint_ | | CHECKSTYLE
| _Checkstyle_ | | JUNIT
| _CloudFormation Linter_ | | cfn-lint . -f junit --output-file report-junit.xmlCODECLIMATE
| _CodeClimate_ | | CODENARC
| _CodeNarc_ | | COVERITY
| _Coverity_ | | MACHINE
| _Dart_ | | With dart analyze --format=machineSARIF
| _Dependency Check_ | | Using --format SARIFCHECKSTYLE
| _Detekt_ | | With --output-format xml.DOCFX
| _DocFX_ | | CLANG
| _Doxygen_ | | CLANG
| _ERB_ | | With erb -P -x -T '-' "${it}" \| ruby -c 2>&1 >/dev/null \| grep '^-' \| sed -E 's/^-([a-zA-Z0-9:]+)/${filename}\1 ERROR:/p' > erbfiles.out.CHECKSTYLE
| _ESLint_ | | With format: 'checkstyle'.FINDBUGS
| _Findbugs_ | | FLAKE8
| _Flake8_ | | FXCOP
| _FxCop_ | | CLANG
| _GCC_ | | GHS
| _GHS_ | | GENDARME
| _Gendarme_ | | GENERIC
| [_Generic reporter_]() | | Will create one single violation with all the content as message.GOLINT
| _GoLint_ | | GOLINT
| _GoVet_ | | Same format as GoLint.CHECKSTYLE
| _GolangCI-Lint_ | | With --out-format=checkstyle.GOOGLEERRORPRONE
| _GoogleErrorProne_ | | CHECKSTYLE
| _HadoLint_ | | With -f checkstyleIAR
| _IAR_ | | With --no_wrap_diagnosticsPMD
| _Infer_ | | Facebook Infer. With --pmd-xml.JACOCO
| _JACOCO_ | | JCREPORT
| _JCReport_ | | JSLINT
| _JSHint_ | | With --reporter=jslint or the CHECKSTYLE parser with --reporter=checkstyleJUNIT
| _JUnit_ | | It only contains the failures.CHECKSTYLE
| _KTLint_ | | KLOCWORK
| _Klocwork_ | | KOTLINGRADLE
| _KotlinGradle_ | | Output from Kotlin Gradle Plugin.KOTLINMAVEN
| _KotlinMaven_ | | Output from Kotlin Maven Plugin.LINT
| [_Lint_]() | | A common XML format, used by different linters.MSBULDLOG
| _MSBuildLog_ | | With -fileLogger use .*msbuild\\.log$ as pattern or -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic for a custom output filenameMSCPP
| _MSCpp_ | | FLAKE8
| _Mccabe_ | | MYPY
| _MyPy_ | | GOOGLEERRORPRONE
| _NullAway_ | | Same format as Google Error Prone.PCLINT
| _PCLint_ | | PC-Lint using the same output format as the Jenkins warnings plugin, _details here_CHECKSTYLE
| _PHPCS_ | | With phpcs api.php --report=checkstyle.PMD
| _PHPPMD_ | | With phpmd api.php xml ruleset.xml.PMD
| _PMD_ | | FLAKE8
| _Pep8_ | | PERLCRITIC
| _PerlCritic_ | | PITEST
| _PiTest_ | | PROTOLINT
| _ProtoLint_ | | CLANG
| _Puppet-Lint_ | | With -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message}PYDOCSTYLE
| _PyDocStyle_ | | FLAKE8
| _PyFlakes_ | | PYLINT
| _PyLint_ | | With pylint --output-format=parseable.RESHARPER
| _ReSharper_ | | CLANG
| _RubyCop_ | | With rubycop -f clang file.rbSARIF
| _SARIF_ | | v2.x. Microsoft Visual C# can generate it with ErrorLog="BuildErrors.sarif,version=2".SBTSCALAC
| _SbtScalac_ | | CHECKSTYLE
| _Scalastyle_ | | SEMGREP
| _Semgrep_ | | With --json.SIMIAN
| _Simian_ | | SONAR
| _Sonar_ | | With mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json. Removed in 7.7, see SONAR-11670 but can be retrieved with: curl --silent 'http://sonar-server/api/issues/search?componentKeys=unique-key&resolved=false' \| jq -f sonar-report-builder.jq > sonar-report.json.FINDBUGS
| _Spotbugs_ | | STYLECOP
| _StyleCop_ | | CHECKSTYLE
| _SwiftLint_ | | With --reporter checkstyle.CHECKSTYLE
| _TSLint_ | | With -t checkstyleVALGRIND
| _Valgrind_ | | With --xml=yes.XMLLINT
| _XMLLint_ | | XUNIT
| _XUnit_ | | It only contains the failures.YAMLLINT
| _YAMLLint_ | | With -f parsableZPTLINT
| _ZPTLint_ | |
52 parsers and 79 reporters.
Missing a format? Open an issue here!
`shell``
-comment-only-changed-content, -cocc
Default: true
-comment-only-changed-content-context, -coccc
Default: 5
-comment-only-changed-files, -cocf
files should be commented.
False if all findings should
be commented.
Default: true
-comment-template
com/tomasbjerre/violation-comments-lib
Default:
-create-comment-with-all-single-file-comments, -
ccwasfc
-create-single-file-comments, -csfc
Default: true
-create-single-file-comments-tasks, -csfct
Default: false
-h, --help
Default: If no specific parameter is given the whole usage text is given
--ignorePaths, -i
Example: -i node_modules [Supports Multiple occurrences]
Default: Empty list
-keep-old-comments
Default: false
-keystore-pass
Default: changeit
-keystore-path
Default:
-max-number-of-violations, -max
Default: 2,147,483,647
-password
Default:
-personal-access-token, -pat
Default:
-project-key, -pk
-proxy-host
Default:
-proxy-password
Default:
-proxy-port
Default: 0
-proxy-user
Default:
-pull-request-id, -prid
-repo-slug, -rs
-server-url, -url
-severity, -s
to report.
Default: INFO
-show-debug-info Please run your
command with this parameter
and supply output when
reporting bugs.
Default: disabled
-username
Default:
--violations, -v
for.
PARSER is one of:
ANDROIDLINT, CHECKSTYLE, CODENARC,
CLANG, CPD, CPPCHECK,
CPPLINT, CSSLINT, GENERIC,
FINDBUGS, FLAKE8, FXCOP,
GENDARME, IAR, JCREPORT, JSLINT,
JUNIT, LINT, KLOCWORK,
KOTLINMAVEN, KOTLINGRADLE, MSCPP,
MYPY, GOLINT,
GOOGLEERRORPRONE, PERLCRITIC, PITEST,
PMD, PROTOLINT, PYDOCSTYLE,
PYLINT, RESHARPER, SBTSCALAC,
SIMIAN, SONAR, STYLECOP,
XMLLINT, YAMLLINT, ZPTLINT,
DOCFX, PCLINT, CODECLIMATE,
XUNIT
Example: -v "JSHINT"
"." ".*/jshint.xml$"
"JSHint" [Supports Multiple occurrences]
Default: Empty list
Checkout the Violations Lib for more documentation.