For the latest updates and improvements, see the latest Cloud documentation instead.
Code patterns¶
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 and select the tool to configure:
-
Enable or disable the patterns using the checkbox for each pattern.
To see a detailed explanation about the issues that a pattern can detect and how to fix them, click Details on the top right-hand corner of the pattern. Some patterns also allow you to configure the rules:
-
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.
Category filters¶
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
==
in JavaScript orOption.get
in Scala - 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.
Importing pattern configurations from another repository¶
Importing tool and pattern configurations from another repository can help you bootstrap and standardize the coding standard across your repositories.
For example, when adding a new repository on Codacy you can copy the tool and pattern configurations from an existing repository that's already configured, and then tweak and adapt the settings for your new repository.
Important
Consider the following when importing tool and pattern configurations:
- Tool matching: Codacy only copies settings for tools that are available on both the source and target repositories, and overwrites the existing settings for these tools on the target repository.
- Toggle status: Codacy copies the enabled or disabled status of the matching tools from the source to the target repository.
- Configuration files: Codacy copies the UI configuration of all matching tools, even those set to use configuration files. However, the import doesn't include the configuration mode itself.
The following example illustrates the points above:
Source repository | Target repository | Target repository after import |
---|---|---|
To import the tool and pattern configurations from another repository:
-
Open your repository Code patterns and click Import patterns.
-
Follow the instructions to select the source repository and complete the import.
-
Review and adjust your tool and pattern configurations if necessary.
Codacy will use the updated configurations on the next analysis.
Using your own tool configuration files¶
Codacy supports configuration files for several tools. To use a configuration file for your static analysis tool:
-
Add the configuration file to the root of your repository.
-
Open your repository Code patterns page and select Configuration file for the respective tool:
The known file names for each tool are the following:
Tool name | Language | Files detected | Other info |
---|---|---|---|
Ameba | Crystal | .ameba.yml |
|
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'\] |
Brakeman | Ruby | config/brakeman.yml |
|
Checkstyle | Java | checkstyle.xml |
Supports configuration file in directories other than root and can search up to 5 directories into the repository. |
CodeNarc | Groovy | .codenarcrc |
|
Credo | Elixir | .credo.exs |
|
CSSLint | CSS | .csslintrc |
|
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. |
ESLint | JavaScript, Typescript | .eslintrc.js , .eslintrc.yaml , .eslintrc.yml , .eslintrc.json , .eslintrc |
Plugins in the UI Other Plugins |
Hadolint | Docker | .hadolint.yaml |
|
JSHint | JavaScript | .jshintrc |
|
PHP CodeSniffer | PHP | phpcs.xml , phpcs.xml.dist |
|
PHPMD | PHP | codesize.xml |
|
PMD | Apex, Java, JavaScript, JSP, XML, Velocity and Visualforce | ruleset.xml , apex-ruleset.xml |
Supports configuration file in directories other than root and can search up to 5 directories into the repository. |
Prospector | Python | .landscape.yml , .landscape.yaml , landscape.yml , landscape.yaml , .prospector.yml , .prospector.yaml , prospector.yml , prospector.yaml |
|
Pylint | Python | pylintrc , .pylintrc |
Plugins |
RemarkLint | Markdown | .remarkrc , .remarkrc.json , .remarkrc.yaml , .remarkrc.yml , .remarkrc.js |
|
Rubocop | Ruby | .rubocop.yml |
|
Scalastyle | Scala | scalastyle_config.xml , scalastyle-config.xml |
|
SCSSLint | SASS | .scss-lint.yml |
|
Sonar C# | C# | SonarLint.xml |
|
SpotBugs | Java, Scala | findbugs.xml , findbugs-includes.xml , findbugs-excludes.xml |
Supports configuration file in directories other than root and can search up to 5 directories into the repository. |
Stylelint | LESS, SASS, CSS | .stylelintrc , stylelint.config.js , .stylelintrc.json , .stylelintrc.yaml , .stylelintrc.js , stylelintrc.yml |
Supports configuration file in directories other than root and can search up to 5 directories into the repository. |
SwiftLint | Swift | .swiftlint.yml |
|
Tailor | Swift | .tailor.yml |
|
TSLint | TypeScript | tslint.json |
|
TSQLLint | SQL | .tsqllintrc |
|
Revive | Go | revive.toml |
Note
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.
Share your feedback 📢
Did this page help you?
Thanks for the feedback! Is there anything else you'd like to tell us about this page?
255 characters left
We're sorry to hear that. Please let us know what we can improve:
255 characters left
Alternatively, you can create a more detailed issue on our GitHub repository.
Thanks for helping improve the Codacy documentation.
If you have a question or need help please contact support@codacy.com.