Function main
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def main():
x = 0.5
methods = ['complex', 'central', 'backward', 'forward']
# for i, derivative in enumerate([nd.Derivative, nds.Gradient, nda.Derivative]):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Instance of 'Hessian' has no '_get_finite_difference_rule' member Open
cls._get_finite_difference_rule,
- Read upRead up
- Exclude checks
Used when a variable is accessed for a nonexistent member.
Instance of 'Hessian' has no '_apply_fd_rule' member Open
cls._apply_fd_rule,
- Read upRead up
- Exclude checks
Used when a variable is accessed for a nonexistent member.
Instance of 'Hessian' has no '_difference_functions' member Open
cls._difference_functions._central_even]
- Read upRead up
- Exclude checks
Used when a variable is accessed for a nonexistent member.
Unable to import 'numpy' Open
import numpy as np
- Read upRead up
- Exclude checks
Used when pylint has been unable to import a module.
Missing function or method docstring Open
def profile_main():
- Read upRead up
- Exclude checks
Used when a function or method has no docstring. Some special methods like init do not require a docstring.
Import outside toplevel (pstats) Open
import pstats
- Read upRead up
- Exclude checks
Used when an import statement is used anywhere other than the module toplevel. Move this import to the top of the file.
Formatting a regular string which could be a f-string Open
s = pstats.Stats("{}.profile".format(__file__))
- Read upRead up
- Exclude checks
Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6
.
Missing function or method docstring Open
def profile_hessian(n_values=(4, 8, 16, 32, 64, 96)):
- Read upRead up
- Exclude checks
Used when a function or method has no docstring. Some special methods like init do not require a docstring.
Variable name df
doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern) Open
df = derivative(f, method=method)
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Import outside toplevel (cProfile) Open
import cProfile
- Read upRead up
- Exclude checks
Used when an import statement is used anywhere other than the module toplevel. Move this import to the top of the file.
Variable name dm
doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern) Open
dm = 7
- Read upRead up
- Exclude checks
Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).
Formatting a regular string which could be a f-string Open
cProfile.run("main()", "{}.profile".format(__file__))
- Read upRead up
- Exclude checks
Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6
.
Missing function or method docstring Open
def main():
- Read upRead up
- Exclude checks
Used when a function or method has no docstring. Some special methods like init do not require a docstring.