By default, Codacy uses a subset of the patterns that exist for each tool to analyze your repositories. These default patterns result from community feedback or existing coding standards.
However, you can create a coding standard adapted to your scenario by configuring the tool patterns that Codacy uses to analyze each repository:
Open your repository Code patterns page.
Select the tool to configure.
Click the checkboxes to the left of the pattern names to enable or disable the patterns.
To see a detailed explanation about the issues that a pattern can detect and how to fix them, click on Details on the top right-hand corner of the pattern:
Optionally, manually reanalyze your repository to immediately take the changes into account. Otherwise, Codacy will use the new configuration when it analyzes a new commit or pull request.
To make it easier to find relevant patterns, you can use the sidebar to filter the patterns by category:
The issues detected by Codacy belong to one of the following categories:
- Code Style: Code formatting and syntax problems. For example, variable names style, enforcing the use of brackets and quotation marks
- Error Prone: Code that may hide bugs and language keywords that should be used with caution. For example, the operator
- Code Complexity: High complexity methods and classes that should be refactored
- Performance: Code that could have performance problems
- Compatibility: Used mainly for frontend code, detects compatibility problems across different browser versions
- Unused Code: Unused variables and methods, code that can't be reached
- Security: All security problems
- Documentation: Detects methods and classes that don't have the correct comment annotations
Setting a default configuration for new repositories¶
If you're adding multiple repositories to Codacy that should reuse the same pattern configuration for a tool, you can define that configuration as the default. Codacy automatically applies that default configuration to new repositories.
To apply the same pattern configuration to multiple repositories:
Add the first repository and configure the patterns on that repository for the relevant tools.
For each tool, expand the menu at the top of the pattern list and select Set default.
This option sets the current pattern configuration as the default for your account when adding new repositories to Codacy.
Add the remaining repositories to Codacy.
The new repositories will automatically use the tool pattern configuration that you set as default.
To reset the pattern configuration of a tool back to the default provided by Codacy:
Expand the menu at the top of the pattern list for that tool and select Reset to revert the configuration back to the one provided by Codacy.
Select Set default on the same menu to reset the default configuration.
I have my own tool configuration file¶
If you have configuration files for your static analysis tool of choice, add it to the root of your repository and Codacy will pick it up automatically.
Codacy supports configuration files for several tools. To have results according to your configuration file, you need to go to the Code Patterns view, select Configuration file for the respective tool, and select the option as shown in the example below.
The known file names for each tool are the following:
|Tool name||Language||Files detected||Other info|
|Bandit||Python||bandit.yml, .bandit||To solve flagged valid Python "assert" statements, create a bandit.yml in the root of the repository containing: skips: \['B101'\]|
|Checkstyle||Java||checkstyle.xml||Supports configuration file in directories other than root and can search up to 5 directories into the repository.|
|Detekt||Kotlin||default-detekt-config.yml, detekt.yml||Supports configuration file in directories other than root and can search up to 5 directories into the repository.|
|Plugins in the UI
|PHP CodeSniffer||PHP||phpcs.xml, phpcs.xml.dist|
|Prospector||Python||.landscape.yml, .landscape.yaml, landscape.yml, landscape.yaml,
.prospector.yml, .prospector.yaml, prospector.yml, prospector.yaml
|RemarkLint||Markdown||.remarkrc, .remarkrc.json, .remarkrc.yaml, .remarkrc.yml, .remarkrc.js|
|SpotBugs||Java, Scala||findbugs.xml, findbugs-includes.xml, findbugs-excludes.xml|
|Stylelint||LESS, SASS, CSS||.stylelintrc, stylelint.config.js, .stylelintrc.json, .stylelintrc.yaml, .stylelintrc.js, stylelintrc.yml|
For performance reasons, if you make changes to pattern settings using configuration files, Codacy may display outdated messages for issues that have already been identified by those patterns.
Configuring the repository root directory for analysis¶
By default, Codacy starts the analysis on the repository's root. However, you can set up a different repository folder on which to start the analysis using a Codacy configuration file. This file must be named ".codacy.yaml" or ".codacy.yml" and must be placed in the repository's root.
See the example below:
1 2 3 4 5 6 7