Question: Flake 8's equivalence to ESLint max-statements


Flake 8's equivalence to ESLint max-statements

Answers 1
Added at 2016-12-04 07:12

max-statements in Javascript ESLint offers a really good enforcement for small, modualized and readable functions. I was hoping to find something similar in Python Flake8 lint but so far I've had no luck. Is there a way of configuring Flake8 to encourage small functions?

Answers to

Flake 8's equivalence to ESLint max-statements

nr: #1 dodano: 2016-12-04 18:12

To expand on @kindall's comment,

Flake8 does not provide a statement checker, but it does have two ways of calculating cyclomatic complexity of functions and methods.

Cyclomatic complexity uses statements and branches to determine the complexity of a function so this will likely result in even simpler functions than what you might see in JavaScript. This is because if/elif/else structures will add to the complexity, as will for and while loops.

To enable the "built-in" cyclomatic complexity enforcement, you can use --max-complexity. There are, however, alternatives to the mccabe project. For example, if you pip install radon that adds it's own cyclomatic complexity checking to Flake8 and will run when you run Flake8.

Source Show
◀ Wstecz