dmyersturnbull/tyrannosaurus

View on GitHub

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
Severity: Minor
Found in tyrannosaurus/cli.py - About 5 hrs to fix

    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,
    Severity: Minor
    Found in tyrannosaurus/helpers.py - About 3 hrs to fix

    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"
    Severity: Minor
    Found in tyrannosaurus/cli.py - About 2 hrs to fix

    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")
    Severity: Minor
    Found in tyrannosaurus/context.py - About 2 hrs to fix

      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()
      Severity: Minor
      Found in tyrannosaurus/new.py - About 1 hr to fix

      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__(
      Severity: Major
      Found in tyrannosaurus/new.py - About 1 hr to fix

        Function new has 12 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def new(
        Severity: Major
        Found in tyrannosaurus/cli.py - About 1 hr to fix

          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":
          Severity: Minor
          Found in tyrannosaurus/helpers.py - About 1 hr to fix

          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__(
          Severity: Major
          Found in tyrannosaurus/parser.py - About 1 hr to fix

            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()
            Severity: Minor
            Found in tyrannosaurus/clean.py - About 1 hr to fix

            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,
            Severity: Minor
            Found in tyrannosaurus/new.py - About 55 mins to fix

            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(
            Severity: Minor
            Found in tyrannosaurus/cli.py - About 55 mins to fix

            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:
            Severity: Minor
            Found in tyrannosaurus/new.py - About 45 mins to fix

            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:
            Severity: Minor
            Found in tyrannosaurus/enums.py - About 45 mins to fix

            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(
            Severity: Minor
            Found in tyrannosaurus/cli.py - About 35 mins to fix

              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
              Severity: Minor
              Found in tyrannosaurus/context.py - About 35 mins to fix

              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_.-]+)")
              Severity: Minor
              Found in tyrannosaurus/helpers.py - About 35 mins to fix

              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
              Severity: Major
              Found in tyrannosaurus/new.py - About 30 mins to fix

                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:
                Severity: Minor
                Found in tyrannosaurus/enums.py - About 25 mins to fix

                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)
                Severity: Minor
                Found in tyrannosaurus/sync.py - About 25 mins to fix

                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

                Severity
                Category
                Status
                Source
                Language