Ignore issues

PyCodeQual allows you to ignore issues that match certain criteria. Ignored issues are hidden and not counted when issue-based metrics are evaluated.

On both the pages for issue groups and single issues you will find an “Ignore…” button which takes you to a dialogue that will allow creating a such a rule. The process consists of three steps

  1. Issue selection: what kind of issues shall be ignored?

  2. Location selection: which modules, packages, files, classes, methods or functions does the rule apply to?

  3. Metadata: provide a comment and set some flags.

1. Issue selection

A rule can either match All issues or a certain issue type (like C0103 Invalid name or C0115 Missing class docstring).

For some issue types rules can be more granular. Consider the following issue:

Pylint C0103: Invalid name
Variable name "fp" doesn't conform to snake_case naming style

Maybe your team decided that it is ok to use fp as a name because it is a very common short form of file_pointer. When you create a rule for this issue, you can add an additional restriction which will only ignore rules that e.g. have kind = "Variable" and name = "fp".

2. Location selection

In the next step, you have three options:

Anywhere in this repository

This will match issues in any files.

In files matching…

The rule will only be applied in files that match a pattern you specify. The pattern can contain an asterisk (*) as a wildcard character that matches zero or more characters ([a-zA-Z0-9._/]* in regexp).

E.g. the pattern */test_*.py would match

  • bar/test_y.py

  • tests/foo/test_foo.py

In objects matching…

The rule will only be applied if one their parent objects (module, package, function, class or method) matches the pattern you specify. The pattern can contain an asterisk (*) as a wildcard character that matches zero or more characters ([a-zA-Z0-9._]* in regexp).

E.g. the pattern my_pkg.module.MyClass.get_* would match all methods of my_pkg.module.MyClass that start with get_.

3. Metadata

In the last step, you can add a comment and add to flags to the rule:

Mark as false positive

This indicates that you think that the issues the rule ignores are actually false positive findings. These rules will be reported and PyCodeQual will check if there is something that can be done about them in order to lower the rate of false positive findings.

Do not use this rule in pull request reviews

When this flag is set, the rule will not be applied when checking for fixed and new issues on pull requests. This is helpful if you have a lot of issues that you do not consider critical but that should preferrably be caught in new or heavily edited parts of the code base.

Where can I find & remove existing rules?

On both the issues pages there is the “Ignore Rules” tab that takes you to a list of existing rules (sorted by how many issues they match).


Alternative approaches

Most of the issues PyCodeQual reports are from pylint. That means you could also ignore issues by adding # pylint: disable=X0123 comments. For PyCodeQual this kind of configuration would not work because it cannot be evaluated for commits that have been analyzed in the past. Thus, it is recommended not to use the message control comments.