rjdbcm/Aspidites

View on GitHub

Showing 19 of 50 total issues

File parser.py has 411 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# cython: language_level=3, annotation_typing=True, c_string_encoding=utf-8, boundscheck=False, wraparound=True, initializedcheck=False
# Aspidites
# Copyright (C) 2021 Ross J. Duff

# This program is free software: you can redistribute it and/or modify
Severity: Minor
Found in Aspidites/api/parser.py - About 5 hrs to fix

    File repl.py has 402 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # Aspidites
    # Copyright (C) 2021 Ross J. Duff
    
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    Severity: Minor
    Found in Aspidites/api/repl.py - About 5 hrs to fix

      Function columnize has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          def columnize(self, list, displaywidth=80):
              """Display a list of strings as a compact set of columns.
      
              Each column is only as wide as necessary.
              Columns are separated by two spaces (one was not legible enough).
      Severity: Minor
      Found in Aspidites/api/repl.py - About 4 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 loop has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def loop(self) -> None:
              os.system("cls" if os.name == "nt" else "clear")
              self.stdout.write(self.intro + "\n")
              count = 0
              try:
      Severity: Minor
      Found in Aspidites/api/repl.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

      Undefined has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Undefined:
          """A monad for a failed programmatic unit; like NoneType but hashable.
          Falsy singleton acts as an absorbing element for division."""
      
          __slots__ = ("__weakref__", "__instance__", "_consumed", "func", "args", "kwargs")
      Severity: Minor
      Found in Aspidites/api/math.py - About 2 hrs to fix

        Function __call__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def __call__(self, arg):
                if arg:
                    try:
                        func = getattr(self.parent, "help_" + arg)
                    except AttributeError:
        Severity: Minor
        Found in Aspidites/api/repl.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 __exit__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def __exit__(self, exc_type, exc_val, exc_tb):
                self.part_file.close()
                if exc_type:
                    if self.rm_part_on_exc:
                        try:
        Severity: Minor
        Found in Aspidites/woma/fileutils.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 cvt_arith_expr has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def cvt_arith_expr(s, loc, t):
            expr = "".join((str(i) for i in t))
            substr = ["!", "**", "//", "/", "%", '*' '-', '+']
            handler = {
                lambda x: "!" in x: factorial,
        Severity: Minor
        Found in Aspidites/api/convert.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 input has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def input(self):
                self.stdout.flush()
        
                line = input(START_PROMPT)
                if "))" in line and line.endswith(tuple(Extension.registrar.keys()) + ("*",)):
        Severity: Minor
        Found in Aspidites/api/repl.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 handle_names has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            def handle_names(self):
                prevname = ""
                for name in self.names:
                    if name[:3] == "do_":
                        if name == prevname:
        Severity: Minor
        Found in Aspidites/api/repl.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 SafeExp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        def SafeExp(a, b):
            if (
                (a == 0 and b == 0) or (isinf(a) and b == 0) or (isinf(b) and a == 0)
            ):  # pragma: no cover
                return Undefined(SafeExp, a, b)
        Severity: Minor
        Found in Aspidites/api/math.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 replace has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def replace(src, dst):
                # argument names match stdlib docs, docstring below
                try:
                    # ReplaceFile fails if the dest file does not exist, so
                    # first try to rename it into position
        Severity: Minor
        Found in Aspidites/woma/fileutils.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 maybe_call has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def maybe_call(instance, func, args, kwargs, _warn, warn_undefined):
        Severity: Minor
        Found in Aspidites/api/monads.py - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (
                  (a == 0 and b == 0) or (isinf(a) and b == 0) or (isinf(b) and a == 0)
              ):  # pragma: no cover
                  return Undefined(SafeExp, a, b)
              try:
          Severity: Major
          Found in Aspidites/api/math.py - About 40 mins to fix

            Function _wrap_lines has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def _wrap_lines(text, padchar, width, wrapped_lines, pad):
            Severity: Minor
            Found in Aspidites/api/api.py - About 35 mins to fix

              Function __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def __init__(self, compile_args: CompilerArgs):
                      self.args = compile_args
                      self.file_stack = CheckedFileStack()
                      self.fname = Path(self.args.fname)
                      if str(self.fname).endswith(".py"):
              Severity: Minor
              Found in Aspidites/api/compiler.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 setup_test_env has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def setup_test_env(argv):
                  if len(argv) >= 2 and argv[1] == "--pytest" or argv[1] == "-pt":  # pragma: no cover
                      if not os.getenv("ASPIDITES_DOCKER_BUILD"):
                          argv = [
                              str(Path(__file__).absolute().parent / Path("tests/test_aspidites.py"))
              Severity: Minor
              Found in Aspidites/__main__.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 maybe_call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def maybe_call(instance, func, args, kwargs, _warn, warn_undefined):
                  e: Exception
                  w: str
                  warn_undefined: bool
                  try:
              Severity: Minor
              Found in Aspidites/api/monads.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 get_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_all(type_obj, include_subtypes=True):
                  """Get a list containing all instances of a given type.  This will
                  work for the vast majority of types out there.
              
                  >>> RatKing = type('Ratking', {})
              Severity: Minor
              Found in Aspidites/woma/gcutils.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