Tutorials

Create AST Rules

BackNext

7. Ignore test files

First, we will pass the analysis if the file is a test file. We will skip the analysis if the file starts with test_ or ends with _test.py.

Therefore, we add the following code at the beginning of the visit function. This code exists the visit function if the test matches the patterns in the condition.

1if (filename.includes("_test.py") || filename.includes("test_")) { 
2    return;
3}

Let's go!

Start interacting with the tutorial!

my-new-rule.js

Codiga Logo
Codiga Hub
  • Rulesets
  • Playground
  • Snippets
  • Cookbooks
soc-2 icon

We are SOC-2 Compliance Certified

G2 high performer medal

Codiga – All rights reserved 2022.