Showing 43 of 45 total issues
Function extra_docstrings
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def extra_docstrings(
Function short_variable_name
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def short_variable_name(project_folder, minimum_name_length, valid_short_variable_names, *args, **kwargs):
Function bilingual_readme
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def bilingual_readme(project_folder, readme_filename, min_percent_of_another_language, *args, **kwargs):
Function range_starting_from_zero
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def range_starting_from_zero(project_folder, *args, **kwargs):
for parsed_file in project_folder.get_parsed_py_files():
calls = ast_helpers.get_nodes_of_type(parsed_file.ast_tree, ast.Call)
for call in calls:
if (
- 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
Function string_literal_sum
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def string_literal_sum(project_folder, *args, **kwargs):
for parsed_file in project_folder.get_parsed_py_files():
for node in ast.walk(parsed_file.ast_tree):
if (
isinstance(node, ast.BinOp) and
- 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
Function code_too_nested
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def code_too_nested(project_folder, tab_size, max_indentation_level, deep_nesting_paths_to_ignore, *args, **kwargs):
"""
Looks at the number of spaces in the beginning and decides if the code is
too nested.
- 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
Function get_source_file_contents
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_source_file_contents(self, extension_list, directories_to_skip=None):
file_paths = []
file_contents = []
directories_to_skip = directories_to_skip or []
for dirname, directories_list, filenames in os.walk(self.path, topdown=True):
- 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
Function casts_input_result_to_str
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def casts_input_result_to_str(project_folder, *args, **kwargs):
for parsed_file in project_folder.get_parsed_py_files():
calls = ast_helpers.get_nodes_of_type(parsed_file.ast_tree, ast.Call)
for call in calls:
if ast_helpers.is_str_call_of_input(call):
- 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
Function has_multiple_imports_on_same_line
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def has_multiple_imports_on_same_line(project_folder, *args, **kwargs):
"""Protects against the case
import foo, bar
"""
for parsed_file in project_folder.get_parsed_py_files():
- 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
Function indent_not_multiple_of_tab_size
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def indent_not_multiple_of_tab_size(project_folder, tab_size, *args, **kwargs):
"""
Since there are cases for which col_offset is computed incorrectly,
this validator must be nothing more than a simple warning.
- 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
Function nonpythonic_empty_list_validation
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def nonpythonic_empty_list_validation(project_folder, *args, **kwargs):
for parsed_file in project_folder.get_parsed_py_files():
ifs_compare_tests = [n.test for n in ast.walk(parsed_file.ast_tree) if
isinstance(n, ast.If) and isinstance(n.test, ast.Compare)]
for compare in ifs_compare_tests:
- 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
Function validates_response_status_by_comparing_to_200
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validates_response_status_by_comparing_to_200(project_folder, *args, **kwargs):
for parsed_file in project_folder.get_parsed_py_files():
for compare in ast_helpers.get_nodes_of_type(parsed_file.ast_tree, ast.Compare):
if ast_nodes_validators.is_status_code_compared_to_200(compare):
return parsed_file.get_name_with_line(compare.lineno)
- 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
Function get_all_imported_names_from_tree
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_all_imported_names_from_tree(tree):
imported_names = []
for node in ast.walk(tree):
if not isinstance(node, ast.ImportFrom):
continue
- 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
Function is_nonglobal_item
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_nonglobal_item(node, max_indentation_depth):
current_item = node
# prevents the user from making this loop excessively long
for _ in range(max_indentation_depth):
if (
- 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
Function is_call_has_constants
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_call_has_constants(call, caller_whitelist):
if isinstance(get_closest_definition(call), ast.ClassDef):
return False # for case of id = db.String(256)
attr_to_get_name = 'id' if hasattr(call.func, 'id') else 'attr'
function_name = getattr(call.func, attr_to_get_name, None)
- 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
Function variable_assignment_with_lambda
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def variable_assignment_with_lambda(project_folder, *args, **kwargs):
for parsed_file in project_folder.get_parsed_py_files():
assigns = ast_helpers.get_nodes_of_type(parsed_file.ast_tree, ast.Assign)
for assign in assigns:
if isinstance(assign.value, ast.Lambda):
- 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
Function get_mccabe_violations_for_file
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_mccabe_violations_for_file(filepath, max_complexity):
code = _read(filepath)
tree = compile(code, filepath, "exec", ast.PyCF_ONLY_AST)
visitor = PathGraphingAstVisitor()
visitor.preorder(tree, visitor)
- 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
Function get_file
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_file(self, filename):
for dirname, _, files in os.walk(self.path, topdown=True):
for file in files:
if file == filename:
with open(os.path.join(dirname, file), encoding='utf-8') as file_handler:
- 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
Function run_validator_group
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def run_validator_group(validator_group, validator_arguments, post_error_validator_group=None):
successful_group_names = []
for group_name, group in validator_group.items():
errors = _run_validator_group(group, validator_arguments)
if errors:
- 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
Function mutable_default_arguments
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def mutable_default_arguments(project_folder, *args, **kwargs):
funcdef_types = (ast.FunctionDef, )
mutable_types = (ast.List, ast.Dict)
for parsed_file in project_folder.get_parsed_py_files():
for funcdef in ast_helpers.get_nodes_of_type(parsed_file.ast_tree, funcdef_types):
- 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"