rohanpm/pidiff

View on GitHub

Showing 57 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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                for x in self.pidiff_args.requirement or []:
                    out.extend(["-r", self._absolutize(x)])
        Severity: Minor
        Found in pidiff/_impl/pipargs.py and 1 other location - About 35 mins to fix
        pidiff/_impl/pipargs.py on lines 42..43

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                for x in self.pidiff_args.constraint or []:
                    out.extend(["-c", self._absolutize(x)])
        Severity: Minor
        Found in pidiff/_impl/pipargs.py and 1 other location - About 35 mins to fix
        pidiff/_impl/pipargs.py on lines 39..40

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 33.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        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

        Line too long (81 > 79 characters)
        Open

            cache_home = os.environ.get("XDG_CACHE_HOME", os.path.expanduser("~/.cache"))
        Severity: Minor
        Found in pidiff/_impl/command.py by pep8

        Limit all lines to a maximum of 79 characters.

        There are still many devices around that are limited to 80 character
        lines; plus, limiting windows to 80 characters makes it possible to
        have several windows side-by-side.  The default wrapping on such
        devices looks ugly.  Therefore, please limit all lines to a maximum
        of 79 characters. For flowing long blocks of text (docstrings or
        comments), limiting the length to 72 characters is recommended.
        
        Reports error E501.
        Severity
        Category
        Status
        Source
        Language