How do you get CodeClimate to ignore max-lines and max statements in a file

898 views Asked by At

We have a reducer that has 350 or so lines. Our function limit is 75 (eslint) so we get the too many lines error. We also get too many return statements, but this is a reducer and that is not a problem. How do we ignore these CodeClimate errors in this one file?

Here are the errors:

enter image description here

enter image description here

2

There are 2 answers

0
user1007983 On

I contacted CodeClimate and they said, "We don't yet support the option to ignore specific issues for individual files.". They said to mark the error as invalid and CodeClimate won't bring it up again.

0
Michael Durrant On

You can't ignore the specific checks for specific files.

However (and for others looking for a solution) you can exclude individual files or directories via a .codeclimate.yml file. See https://docs.codeclimate.com/docs/excluding-files-and-folders

The drawback is that it means all rules will be excluded.
If you do this, make sure you have good lint rules that do apply to those files and that can help.
Some files such as reducers and other configuration and mapping files aren't appropriate for the linting that you do want for the rest of the code.

e.g.

.codeclimate.yml

## other configuration excluded from example...
exclude_patterns:
- "imageViewer/reducer.js"