Showing 18 of 57 total issues
File diff.py
has 406 lines of code (exceeds 250 allowed). Consider refactoring. Open
import logging
import functools
from typing import Optional, Set
import semver # type: ignore
File command.py
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os.path
import argparse
import logging
import subprocess
import sys
Function add_assigns
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def add_assigns(self, object_dump, o, class_def):
attr_assigns = []
remaining = [class_def]
while remaining:
- 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 import_recurse
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def import_recurse(module_name: str):
module = importlib.import_module(module_name)
module_file = getattr(module, "__file__", None) or ""
if os.path.basename(module_file) == "__init__.py":
- 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 diff_positional_args
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def diff_positional_args(self, sym_old, sym_new):
sig_old = sym_old.ob.signature
sig_new = sym_new.ob.signature
old_arg_names = sig_old.positional_args
- 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 diff
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def diff(
api_old: dict, api_new: dict, options: Optional[DiffOptions] = None
) -> DiffResult:
"""Perform a diff between two interfaces.
- 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_version_importlib
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_version_importlib(module) -> Optional[str]:
module_file = module.__file__
if module_file.endswith('.pyc'):
module_file = module_file[:-1]
- 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 log
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def log(self, sym_old, sym_new, old_location, new_location, **kwargs):
Function add_checks
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_checks(arg_values, option_method):
for arg_value in arg_values or []:
for check in re.split(r"[,\n ]+", arg_value or ""):
check = check.strip()
if check:
- 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 egg_for_root
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def egg_for_root(root_name: str):
# FIXME: why are both mypy and pylint getting things wrong here
# for pkg_resources? Something wrong with the setup?
for dist in pkg_resources.working_set: # pylint: disable=not-an-iterable
egg_info = dist.egg_info # type: ignore
- 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 summarize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def summarize(ctx, log, new_version):
LOG.info("")
LOG.info("---------------------------------------------------------------------")
if log.max_change_type == ChangeType.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 dump_object
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def dump_object(self, ref, name, ob):
ref_str = str(id(ob))
ref["name"] = name
ref["ref"] = ref_str
- 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 validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate(instance) -> None:
# jsonschema validation
jsonschema.validate(instance, dump_schema)
# now ensure all object refs are OK
- 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 read_config
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def read_config():
path = os.getcwd()
parser = configparser.ConfigParser(strict=False, allow_no_value=True)
while path != "/":
- 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_enabled
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_enabled(self, code):
enabled = self.options.enabled
disabled = self.options.disabled
for name in (code.errcode, code.errname):
- 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 max_change_allowed
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def max_change_allowed(self):
old_vinfo = self.old_version_info
new_vinfo = self.new_version_info
# default applies if any version is unavailable/incomparable
- 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 diff_named_args
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def diff_named_args(self, sym_old, sym_new):
sig_old = sym_old.ob.signature
sig_new = sym_new.ob.signature
old_arg_names = sig_old.named_kwargs
- 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
Refactor this function to reduce its Cognitive Complexity from 16 to the 15 allowed. Open
def add_assigns(self, object_dump, o, class_def):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.