This is the docker engine we use at Codacy to have Dart Analyzer support. You can also create a docker to integrate the tool and language of your choice! See the codacy-engine-scala-seed repository for more information.
To support new packages just add them on Dockerfile after the development context is created, like so:
RUN dart pub add <package> --dev
- Update the version at
.tool_version
file with the new SDK version. - Re-run the doc generation.
We use dart analyze
command, which performs static analysis on dart source code. It works by having an analysis_options.yaml
file, which specifies all the necessary rules for analysis. This file has the following structure:
include: package:lints/recommended.yaml
analyzer:
exclude: [build/**]
language:
strict-casts: true
strict-raw-types: true
linter:
rules:
- cancel_subscriptions
The example above illustrates the most common entries you will have to specify:
- The include operation is used to import options from the specified URL. You can include at most one file.
- The analyzer entry customizes static analysis, where you can activate or de-activate specific rules, ignore files, etc.
- The linter entry specifies linting rules.
You can have multiple analysis_options.yaml
files in a project. However, there are some rules that apply when you do so.
The analyzer will always use the first analysis_options file it finds when searching through the file hierarchy.
The following image explains the rules used for the options files:
In the case demonstrated above, the analyzer uses file #1
to analyze the code in my_other_package
and my_other_other_package
, and file #2
to analyze the code in my_package
.
This implies that any analysis_options.yaml
files specified in the hierarchy will override the users' provided analysis configurations.
When building the docker image, we the necessary files required to support the include
operation on the analysis_options.yaml
files supported packages.
By default, dart outputs the analysis results in a human-readable format. However, there is an optional argument format
that makes it easier to parse.
We use --format=machine
to provide the best format for parsing the results by Codacy.
You can create the docker image by executing the following commands:
sbt graalvm-native-image:packageBin
docker build --build-arg TOOL_VERSION=$(cat .tool_version) -t codacy-dartanalyzer .
To run the docker image, you can use the following command:
docker run -it -v $srcDir:/src <DOCKER_NAME>:<DOCKER_VERSION>
For a faster development loop, you can create a JVM-based Docker image instead of creating a native-image:
sbt universal:stage
docker build --build-arg TOOL_VERSION=$(cat .tool_version) -t codacy-dartanalyzer -f Dockerfile.dev .
We use the codacy-plugins-test to test our external tools integration. You can follow the instructions there to make sure your tool is working as expected.
To generate the pattern.json and rules descriptions you must run a dart program from the project root.
dart run doc-generator/lib/generatedocs.dart
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 in 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, Dart, and Scala, among other languages.
Codacy is free for Open Source projects.