HansBug/hbutils

View on GitHub

Showing 71 of 71 total issues

File model.py has 610 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Overview:
    Color model, include rgb, hsv, hls color system.
    
    More color system will be supported soon.
Severity: Major
Found in hbutils/color/model.py - About 1 day to fix

    Function isolated_entry_points has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

    def isolated_entry_points(group: str, fakes: Union[List, Dict[str, Any], None] = None,
                              auto_import: bool = True, clear: bool = False):
        """
        Overview:
            Isolation for :func:`pkg_resources.iter_entry_points` function.
    Severity: Minor
    Found in hbutils/testing/isolated/entry_point.py - About 1 day 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 cases has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

        def cases(self) -> Iterator[Mapping[str, object]]:
            """
            Get the cases in this AETG model.
    
            Examples::
    Severity: Minor
    Found in hbutils/testing/generator/aetg.py - About 6 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

    File inflection.py has 396 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Overview:
        Useful utilities for word inflections.
    
        Extended based on `jpvanhal/inflection <https://github.com/jpvanhal/inflection>`_.
    Severity: Minor
    Found in hbutils/string/inflection.py - About 5 hrs to fix

      File func.py has 384 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """
      Overview:
          Useful functions for processing python functions.
      """
      import warnings
      Severity: Minor
      Found in hbutils/reflection/func.py - About 5 hrs to fix

        File clazz.py has 361 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Overview:
            Useful functions for build class models.
        """
        import os
        Severity: Minor
        Found in hbutils/model/clazz.py - About 4 hrs to fix

          Function iter_import_objects has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          def iter_import_objects(full_pattern: str, predicate: Optional[Callable] = None) \
                  -> Iterator[Tuple[Any, str, str]]:
              """
              Overview:
                  Quickly dynamically import all objects with full name pattern.
          Severity: Minor
          Found in hbutils/reflection/imports.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 visual has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
          Open

          def visual(items: Optional[Iterable] = None, show_id: bool = False):
              """
              Overview:
                  Decorate class to be visible by `repr`.
          
          
          Severity: Minor
          Found in hbutils/model/clazz.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 _eq_compare_message has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

              def _eq_compare_message(expect: List[str], actual: List[str], max_diff: int = 3, max_extra: int = 5):
                  if expect == actual:  # pragma: no cover
                      return 'No difference found.'
                  else:
                      with io.StringIO() as sf:
          Severity: Minor
          Found in hbutils/testing/compare/text.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 _rmtree has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

                  def _rmtree(cls, name, ignore_errors=False):
                      def onerror(func, path, exc_info):
                          if issubclass(exc_info[0], PermissionError):
                              def resetperms(path):
                                  try:
          Severity: Minor
          Found in hbutils/system/filesystem/tempfile.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

          File context.py has 317 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
          Overview:
              Utilities for building context variables on thread level.
          
              This is useful when implementing a with-block-based syntax.
          Severity: Minor
          Found in hbutils/reflection/context.py - About 3 hrs to fix

            Function tmatrix has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            def tmatrix(ranges: Mapping[Union[str, Tuple[str, ...]], List],
                        mode='aetg', seed: Optional[int] = 0, level: int = 2) -> Tuple[List[str], List[Tuple]]:
                """
                Overview:
                    Test matrix generator, which can be used in ``pytest.mark.parameterize``.
            Severity: Minor
            Found in hbutils/testing/generator/func.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 freduce has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
            Open

            def freduce(init=NO_INITIAL, pass_kwargs: bool = True):
                """
                Overview:
                    Make binary function be reducible.
            
            
            Severity: Minor
            Found in hbutils/reflection/func.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 _yield_from_units has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            def _yield_from_units(fes, auto_import: bool = True) -> Iterator[Tuple[str, Any]]:
                if isinstance(fes, (list, tuple)):
                    for item in fes:
                        if isinstance(item, tuple) and len(item) == 2:
                            name, dist = item
            Severity: Minor
            Found in hbutils/testing/isolated/entry_point.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 cases has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

                def cases(self) -> Iterator[Mapping[str, Any]]:
                    """
                    Get the cases in this matrix.
            
                    Examples::
            Severity: Minor
            Found in hbutils/testing/generator/matrix.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 _yield_reqs_to_install has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            def _yield_reqs_to_install(req: Requirement, current_extra: str = ''):
                if req.marker and not req.marker.evaluate({'extra': current_extra}):
                    return
            
                try:
            Severity: Minor
            Found in hbutils/system/python/package.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 accessor has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
            Open

            def accessor(items: Optional[Iterable] = None, readonly: bool = False):
                """
                Overview:
                    Decorate class to be accessible by the accessors.
            
            
            Severity: Minor
            Found in hbutils/model/clazz.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

            Color has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Color:
                """
                Overview:
                    Color utility object.
            
            
            Severity: Minor
            Found in hbutils/color/model.py - About 2 hrs to fix

              Function get_repr_info has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_repr_info(cls: type, args: List[Tuple]) -> str:
                  """
                  Overview:
                      Get representation information for object.
                      Can be used in ``__repr__`` method for class.
              Severity: Minor
              Found in hbutils/model/repr.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

              File text.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import io
              import os
              import textwrap
              from typing import List, Union
              
              
              Severity: Minor
              Found in hbutils/testing/compare/text.py - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language