149

Language / Framework: Any language
Checks:
Categories: Bug Risk, Clarity, Compatibility, Complexity, Duplication, Performance, Security, Style

The grep engine allows you to create custom patterns to detect specific constructs in your repository. It uses GNU Grep and supports the extended grep syntax.

Enabling the Plugin

To enable the Grep engine, configure it in your .codeclimate.yml configuration file:

plugins:
  grep:
    enabled: true
    config:
      patterns:
        no-set-methods:
          pattern: def set_\w+
          annotation: "Don't define methods that start with `set_`"
          severity: minor
          categories: Bug Risk
          content: >
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc id
            urna eget libero fermentum bibendum. Duis dapibus, neque vel aliquet
            tincidunt, diam eros tempor neque
          path_patterns:
            - "**/*.rb"

Configuring the Plugin

The Grep engine requires manual configuration. A sample is presented above. The configuration options are as follows:

  • patterns (required): A list of match configurations. The key you use will be an issue's check name. The value will be the configuration for that pattern.
  • pattern (required): The regular expression to be used by Grep.

🚧

Note about YAML

Depending on what syntax you use, you may need to escape characters in the pattern. Refer to YAML's Escape characters spec for details.

  • annotation (required) The description for the issues emitted.
  • severity (optional) The severity for the issues emitted. This defaults to minor. It can be one of the following:
    • info
    • minor
    • major
    • critical
    • blocker
  • categories (optional) A list of categories for the issues emitted. This defaults to ["Bug Risk"], and can be either a string (for a single category), or a list of categories. The following categories are supported:
    • Bug Risk
    • Clarity
    • Compatibility
    • Complexity
    • Duplication
    • Performance
    • Security
    • Style
  • content (optional) An extended description of the issue. It will be displayed in a modal on the Code Climate website for each issue emitted. By default, this is blank.
  • path_patterns (optional) A list of path patterns (in shell glob syntax) in which to check for the given pattern. By default this is all files not excluded elsewhere in your configuration