rohanpm/pidiff

View on GitHub

Showing 17 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
Severity: Minor
Found in pidiff/_impl/diff/diff.py - About 5 hrs to fix

    File command.py has 330 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import os.path
    import argparse
    import logging
    import subprocess
    import sys
    Severity: Minor
    Found in pidiff/_impl/command.py - About 3 hrs to fix

      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:
      Severity: Minor
      Found in pidiff/_impl/dump/ast_enrich.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

      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":
      Severity: Minor
      Found in pidiff/_impl/dump/dump.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 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
      Severity: Minor
      Found in pidiff/_impl/diff/diff.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 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.
      
      
      Severity: Minor
      Found in pidiff/_impl/diff/diff.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 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]
      
      
      Severity: Minor
      Found in pidiff/_impl/dump/dump.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 log has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def log(self, sym_old, sym_new, old_location, new_location, **kwargs):
      Severity: Minor
      Found in pidiff/_impl/diff/codes.py - About 35 mins to fix

        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
        Severity: Minor
        Found in pidiff/_impl/schema.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 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:
        Severity: Minor
        Found in pidiff/_impl/diff/diff.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 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
        
        
        Severity: Minor
        Found in pidiff/_impl/dump/dump.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 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:
        Severity: Minor
        Found in pidiff/_impl/config.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 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
        Severity: Minor
        Found in pidiff/_impl/dump/dump.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 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
        Severity: Minor
        Found in pidiff/_impl/diff/diff.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 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 != "/":
        Severity: Minor
        Found in pidiff/_impl/config.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 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
        Severity: Minor
        Found in pidiff/_impl/diff/diff.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 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):
        Severity: Minor
        Found in pidiff/_impl/diff/diff.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