Skip to main content

Write Custom Code Analysis Rules

tip

Write new code analysis rules in seconds 💨 not hours 🥱

All rules have the following characteristics:

  • The rule code must be written in JavaScript
  • A rule must be in a ruleset

There are two kinds of rules:

  • AST: analyze the program AST to report errors
  • Pattern: use regular expressions to detect potential issues

Create an AST rule

By writing an AST rule, you accurately check the language element, which reduces the number of false positives.

Play Tutorial

Create a pattern rule

A pattern ruleset lets you catch a pattern of code and emits violations/errors. This tutorial explains how to write a Codiga Pattern rule.

Play Tutorial

Playground​

Codiga provides a playground to experiment our static analyzer and write your own rules. Use the playground to test your own rules, experiment by starting from other people rules and let your imagination write the best code analysis rules!

Explore the Hub

The Codiga Hub hosts hundreds of custom analysis rules you can reuse. Browse rules on the hub, import them in the playground and create new analysis rules for your team!

Explore Codiga Hub

Tutorials​

Explore the Hub​

The Codiga Hub hosts hundreds of custom analysis rules you can reuse. Browse rules on the hub, import them in the playground and create new analysis rules for your team!

Using the rules​

IDE​

Step 1: Create a codiga.yml file at the root of your project with the following content:

rulesets:
- <ruleset-identifier>
- <ruleset-identifier>

Step 2: Download the IDE extensions/plugin:

Codiga will analyze your code in real-time, report errors and suggest fixes.

Source code scanning​

Step 1: Create a codiga.yml file at the root of your project with the following content:

rulesets:
- <ruleset-identifier>
- <ruleset-identifier>

Create a project on Codiga with your code repository. Codiga is available for: