32
votes

We're adding CodeClimate to a project and running into a lot of method-lines errors for the render functions in our React components,

example:-

Function render has 78 lines of code (exceeds 40 allowed). Consider refactoring.

We would like to filter out all our render functions from the method-lines check. We could increase the line threshold or disable the check altogether, but we still want the check for other functions, so that's not desirable.

There is node filtering for duplication checks, but I can't find anything similar for method-lines.

1

1 Answers

-3
votes

you need a codwclimate.yml file and you can change the threshold with the following - although having a giant render function isn't really great - i'd suggest keeping it under 50 lines as well.

version: "2"         # required to adjust maintainability checks
checks:
 argument-count:
   config:
     threshold: 4
   complex-logic:
    config:
     threshold: 4
   file-lines:
    config:
     threshold: 250
   method-complexity:
    config:
     threshold: 5
   method-count:
    config:
     threshold: 20
   method-lines:
    config:
     threshold: 25

this is from the docs here: https://docs.codeclimate.com/docs/advanced-configuration#section-default-check-configurations

method-lines is the last one above - and please make sure to not cut/paste as the YML will need the indentation to be exact. Good luck!