Showing 20 of 20 total issues
File cli.py
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
Command-line interface.
Original source: https://github.com/dmyersturnbull/tyrannosaurus
Copyright 2020–2022 Douglas Myers-Turnbull
Function process
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def process(self, name: str, deps, extras: bool) -> Sequence[str]:
helper = CondaForgeHelper()
lines = [
"# auto-generated by `tyrannosaurus env`",
"name: " + name,
- 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 _fix_docstrings
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def _fix_docstrings(commands):
for f in commands:
if "Args:" in [q.strip() for q in f.__doc__.splitlines()]:
continue
f.__doc__ += "\n" + " " * 8 + "Args:\n"
- 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
Context
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Context:
def __init__(self, path: Union[Path, str], data=None, dry_run: bool = False):
self.path = Path(path).resolve()
if data is None:
data = Toml.read(Path(self.path) / "pyproject.toml")
Function create
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def create(self, path: Path) -> None:
self._checkout(Path(str(path).lower()))
logger.info("Got git checkout. Fixing...")
# remove tyrannosaurus-specific files
Path(path / "poetry.lock").unlink()
- 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 __init__
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function new
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def new(
Function new_versions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def new_versions(self, pkg_versions: Mapping[str, str]) -> Mapping[str, tuple[str, str]]:
logger.warning("Making a best effort to find new versions. Correctness is not guaranteed.")
updated = {}
for pkg, version in pkg_versions.items():
if pkg == "python":
- 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 __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function clean
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, path: Path) -> Sequence[tuple[Path, Optional[Path]]]:
context = Context(path, dry_run=self.dry_run)
logger.info(f"Clearing {context.tmp_path}")
trashed = []
destroyed = context.destroy_tmp()
- 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 _call
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _call(
self,
cmd: list[str],
cwd: Optional[Path] = None,
succeed: Optional[str] = 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 new
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def new(
name: str = typer.Argument(
"project", help="The name of the project, including any dashes or capital letters"
),
license: str = typer.Option(
- 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 _set_tyranno_vr
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def _set_tyranno_vr(self, path: Path):
# if it's None, just leave it as HEAD
if self.tyranno_vr == "latest":
logger.info("Using HEAD for tyrannosaurus template version")
else:
- 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 of
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def of(cls, value: Union[str, License]) -> License:
if isinstance(value, License):
return value
for v in list(License):
if v.spdx == value:
- 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 env
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def env(
Function delete_exact_path
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def delete_exact_path(
self, path: Path, hard_delete: bool
) -> tuple[Optional[Path], Optional[Path]]:
if not path.exists():
return None, 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 get_version
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_version(self, name: str) -> str:
# lowercase 'sphinx' is allowed in pip & poetry, but will not work for the raw URL request
if name == "sphinx":
name = "Sphinx"
pat = re.compile('"package-header__name">[ \n\t]*' + name + " ([0-9a-zA-Z_.-]+)")
- 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
Avoid too many return
statements within this function. Open
return "v" + version
Function add
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add(self, key: str, value: Any):
at = self._dict
if "." in key:
for k in key.split(".")[:-1]:
if k not in at:
- 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 _replace
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _replace(self, line: str, k: Union[str, re.Pattern], v: str) -> Optional[str]:
if isinstance(k, re.Pattern):
try:
if k.fullmatch(line) is not None:
return k.sub(line, v)
- 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"