2

Pylint has many metrics to ensure that code is readable and not too complex.

[DESIGN]

# Maximum number of arguments for function / method.
max-args=5

# Maximum number of attributes for a class (see R0902).
max-attributes=7

# Maximum number of boolean expressions in an if statement.
max-bool-expr=5

# Maximum number of branch for function / method body.
max-branches=12

# Maximum number of locals for function / method body.
max-locals=15

# Maximum number of parents for a class (see R0901).
max-parents=7

# Maximum number of public methods for a class (see R0904).
max-public-methods=20

# Maximum number of return / yield for function / method body.
max-returns=6

# Maximum number of statements in function / method body.
max-statements=50

# Minimum number of public methods for a class (see R0903).
min-public-methods=2

What is the rationale (or some literature) behind these maximum numbers?

In particular, I would like to know for

  • Maximum number of arguments for function / method (5)
  • Maximum number of branch for function / method body (12)
  • Maximum number of locals for function / method body (15)

Thanks

S3DEV
  • 8,768
  • 3
  • 31
  • 42
Jean-Francois T.
  • 11,549
  • 7
  • 68
  • 107
  • The general rationale would be to keep individual methods as simple as possible. If one of the limits is exceeded, it's a sign that you should've designed better. – iBug Aug 19 '20 at 12:24
  • 1
    @iBug of course, but why these exact numbers and not, let's say, 6 arguments and 10 branches? – Jean-Francois T. Aug 20 '20 at 01:33

0 Answers0