A standalone tool that converts Clang-Tidy diagnostics to Codacy's format.
It allows running Clang-Tidy either locally or as part of your CI process and then integrating the results into your Codacy workflow. This way, Codacy will present the results coming from Clang-Tidy alongside all the other code quality information in the dashboards.
To get your Clang-Tidy results into Codacy you'll need to:
- Enable Clang-Tidy and configure the corresponding code patterns on your repository Code patterns page
- Enable the setting Run analysis through build server on your repository Settings, tab General, Repository analysis
- Obtain a project API token
- Download codacy-clang-tidy
Sending the results of running Clang-Tidy to Codacy involves the steps below, which you can automate in your CI build process:
- Run Clang-Tidy
- Convert the Clang-Tidy output to a format that the Codacy API accepts
- Send the results to Codacy
- Finally, signal that Codacy can use the sent results and start a new analysis
When the option “Run analysis through build server” is enabled, the Codacy analysis will not start until you call the endpoint
/2.0/commit/{commitUuid}/resultsFinal
signalling that Codacy can use the sent results and start a new analysis.
With script:
export PROJECT_TOKEN="YOUR-TOKEN"
export COMMIT="COMMIT-UUID"
export CODACY_URL="CODACY-INSTALLATION-URL" # if not defined https://api.codacy.com will be used
export CODACY_CLANG_TIDY_VERSION=0.2.3 # if not defined, latest will be used
clang-tidy "<clang-tidy-configs>" | \
./<codacy-clang-tidy-path>/scripts/send-results.sh # requires a codacy-clang-tidy-"<version>" in the current directory
Without script (step-by-step):
export PROJECT_TOKEN="YOUR-TOKEN"
export COMMIT="COMMIT-UUID"
# 1. Run Clang-Tidy
clang-tidy "<clang-tidy-configs>" | \
# 2. Convert the Clang-Tidy output to a format that the Codacy API accepts
./codacy-clang-tidy-"<version>" | \
# 3. Send the results to Codacy
curl -XPOST -L -H "project-token: $PROJECT_TOKEN" \
-H "Content-type: application/json" -d @- \
"https://api.codacy.com/2.0/commit/$COMMIT/issuesRemoteResults"
# 4. Signal that Codacy can use the sent results and start a new analysis
curl -XPOST -L -H "project-token: $PROJECT_TOKEN" \
-H "Content-type: application/json" \
"https://api.codacy.com/2.0/commit/$COMMIT/resultsFinal"
For self-hosted installations:
export PROJECT_TOKEN="YOUR-TOKEN"
export COMMIT="COMMIT-UUID"
export CODACY_URL="CODACY-INSTALLATION-URL"
# 1. Run Clang-Tidy
clang-tidy "<clang-tidy-configs>" | \
# 2. Convert the Clang-Tidy output to a format that the Codacy API accepts
./codacy-clang-tidy-"<version>" | \
# 3. Send the results to Codacy
curl -XPOST -L -H "project-token: $PROJECT_TOKEN" \
-H "Content-type: application/json" -d @- \
"$CODACY_URL/2.0/commit/$COMMIT/issuesRemoteResults"
# 4. Signal that Codacy can use the sent results and start a new analysis
curl -XPOST -L -H "project-token: $PROJECT_TOKEN" \
-H "Content-type: application/json" \
"$CODACY_URL/2.0/commit/$COMMIT/resultsFinal"
codacy-clang-tidy
accepts as command line arguments:
-
--encoding <ENCODING>
or-e <ENCODING>
- encoding to use when parsing the input (default:UTF-8
). The encoding should be one of the possible Java Charsets. Example:./codacy-clang-tidy-"<version>" --encoding LATIN1
sbt compile
sbt ";scalafmt;test:scalafmt;sbt:scalafmt"
sbt test
sbt "nativeImage"
sbt assembly
If you want to change versions before generating the docs you can do it by
changing the llvmVersion
value in doc-generator/src/main/scala/Main.scala
sbt doc-generator/run
Clang-Tidy may return a different encoding as output than the default used by codacy-clang-tidy. You can specify the encoding to use on codacy-clang-tidy:
./codacy-clang-tidy-"<version>" --encoding <ENCODING>
Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.
- Identify new Static Analysis issues
- Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
- Auto-comments on Commits and Pull Requests
- Integrations with Slack, HipChat, Jira, YouTrack
- Track issues Code Style, Security, Error Proneness, Performance, Unused Code and other categories
Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.
Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.
Codacy is free for Open Source projects.