Skip to content
This documentation applies to Codacy Self-hosted v2.0.0

For the latest updates and improvements, see the latest Cloud documentation instead.

Code patterns

As a wise man once said, "You can't please everyone", and that is true for code patterns. But don't you worry! You can choose from a range of patterns to fit your needs.

Pattern details and filters

Each pattern has a title and a short description. To see a detailed explanation you can click on Show Details in the top right corner (mouse over the pattern and the Show Details option will appear):

Code pattern details

The pattern explanation shows more detail about the issues it can detect and how to fix them.

You can filter the patterns by category using the side menu:

Filtering code patterns

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 or Option.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 do not have the correct comment annotations

Configuring your repository patterns

To configure the patterns used to analyze your repository click on the checkbox to the left of the title:

Enabling code patterns

When you change the enabled patterns you can reanalyze your repository. To do that, enter the latest commit from your list on the Commit view and click reanalyze.

Account vs repository patterns

Your account patterns allow you to change the default selection of patterns by enabling or disabling them for all future repositories added by you. See Default patterns for more details.

The repository patterns specify the patterns you want to use for each repository. When you change your account patterns it doesn't affect pattern selection for repositories already added. Open Code patterns:

Code patterns configuration page

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.

Using a configuration file

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 repo containing: skips: \['B101'\]
Brakeman Ruby config/brakeman.yml
Checkstyle Java checkstyle.xml Supports config file in other dirs than root and can search up to 5 dirs into the repository.
Codenarc Groovy .codenarcrc
credo Elixir .credo.exs
CSSLint CSS .csslintrc
detekt Kotlin default-detekt-config.yml, detekt.yml Supports config file in other dirs than root and can search up to 5 dirs into the repository.
ESLint JavaScript, Typescript, JSON .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 config file in other dirs than root and can search up to 5 dirs 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 config file in other dirs than root and can search up to 5 dirs into the repository.
Stylelint LESS, SASS, CSS .stylelintrc, stylelint.config.js, .stylelintrc.json, .stylelintrc.yaml, .stylelintrc.js, stylelintrc.yml Supports config file in other dirs than root and can search up to 5 dirs into the repository.
SwiftLint Swift .swiftlint.yml
Tailor Swift .tailor.yml
TSLint TypeScript tslint.json
tsqllint SQL .tsqllintrc
Revive Go revive.toml

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 needs to be named ".codacy.yaml" or ".codacy.yml" and must be placed in the repository's root.

See example below:

1
2
3
4
5
6
7
---
engines:
 rubocop:
 enabled: true
 exclude_paths:
 - config/engines.yml
 base_sub_dir: test/baseDir

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?

We're sorry to hear that. Please let us know what we can improve:

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.

Last modified August 16, 2020