Excluding Files and Folders

Our analysis lets you fine tune what Code Climate analyzes in your project.

You can specify files or directories that you'd like to exclude from your analysis using in-app configuration, or using the exclude_patterns key in a committed configuration file.

📘

Exclude Patterns

Exclusions can only be made at the global level (excluding code from all analysis) or at the plugin-level (excluding code only from specific third-party plugins). Currently, exclusions cannot be made for individual maintainability checks.

Exclude patterns apply only to static analysis from checks and plugins. To exclude files from test coverage reporting, you'll need to exclude them via your local test coverage suite.

Pattern Format

  • Each entry in a list of exclude_patterns is a "pattern".
  • Patterns can be filenames relative to the project root, or shell-style globs relative to the project root.
  • Patterns can be negated by prefixing them with a !. A negated pattern will include the matched files for analysis, even if they have been excluded by a previous pattern.
  • Patterns should be quoted to ensure your configuration file will be parsed correctly.

📘

Negated Patterns

If your pattern includes quotation marks, include the ! inside of your quotation marks.

  • i.e. "!lib/foundation.js"

Excluding Specific Files and File Types at any Level

To exclude specific files and files types, for example, your .codeclimate.yml would have the following key/values:

## other configuration excluded from example...
exclude_patterns:
- "lib/foundation.js"
- "**/*.rb"

Excluding Tests, Specs and Vendor Directories at any Level

To exclude tests and specs or a vendor directory at any level, for example, your .codeclimate.yml would have the following key/values:

## other configuration excluded from example...
exclude_patterns:
- "tests/"
- "spec/"
- "**/vendor/"

Exclude Paths for Specific Plugins

You can also specify exclude paths for specific plugins. These paths will be excluded in addition to the global exclude_patterns.

plugins:
  rubocop:
    enabled: true
    exclude_patterns:
    - "vendor/"
  eslint:
   	enabled: true
## other configuration excluded from example...
exclude_patterns:
- "tests/"
- "spec/"

📘

Exclude Patterns for Specific Plugins

Exclusions at the Plugin-level must be made via committed configuration file.

🚧

Impact of adding excludes

While often intentional, it's still worth noting that adding exclusions can (and in many cases likely will) change your maintainability ratings. This is because Code Climate is no longer penalizing you for issues that were detected in (now) excluded files.

Auto-generated file and folder exclusions

If you do not have a .codeclimate.yml committed, Code Climate will use a default config containing the following default exclude patterns:

config/
db/
dist/
features/
**/node_modules/
script/
**/spec/
**/test/
**/tests/
Tests/
**/vendor/
**/*_test.go
**/*.d.ts

We recommend and will attempt to add exclusions for:

  • third party libraries
  • production assets, such as minimized or cross-compiled files
  • automated test suites

Furthermore, engines only run their analysis on files with an appropriate file extension for the language being analyzed (.rb for a Ruby engine, .py for a Python engine, etc). Therefore, in most cases you should not need to specify excludes for files in languages other than your target languages.

🚧

.codeclimate.yml with NO exclude_patterns.

If you commit a .codeclimate.yml with NO exclude_patterns, Code Climate will use the default exclude patterns listed above.