ionelmc/python-hunter

View on GitHub

Showing 67 of 67 total issues

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

    def __init__(
        self,
        frame,
        kind,
        arg,
Severity: Minor
Found in src/hunter/event.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 stop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def stop(self):
        """
        Stop tracing. Reinstalls the :attr:`~hunter.tracer.Tracer.previous` tracer.
        """
        if self._handler is not None:
Severity: Minor
Found in src/hunter/tracer.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 filename has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def filename(self):
        """
        A string with the path to the module's file. May be empty if ``__file__`` attribute is missing.
        May be relative if running scripts.

Severity: Minor
Found in src/hunter/event.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 fullsource has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def fullsource(self):
        """
        A string with the sourcecode for the current statement (from ``linecache`` - failures are ignored).

        May include multiple lines if it's a class/function definition (will include decorators).
Severity: Minor
Found in src/hunter/event.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 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in src/hunter/actions.py - About 1 hr to fix

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

        def __call__(self, event):
            """
            Handles the event.
            """
            if self._origin_depth is None:
    Severity: Minor
    Found in src/hunter/predicates.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 exec_in_env has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def exec_in_env():
        env_path = base_path / '.tox' / 'bootstrap'
        if sys.platform == 'win32':
            bin_path = env_path / 'Scripts'
        else:
    Severity: Minor
    Found in ci/bootstrap.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in src/hunter/event.py - About 50 mins to fix

      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in src/hunter/predicates.py - About 50 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if not isinstance(value, (list, set, tuple)):
                                    raise ValueError(f'Value {value!r} for {key!r} is invalid. Must be a string, list, tuple or set.')
                                value = tuple(value)
        Severity: Major
        Found in src/hunter/predicates.py - About 45 mins to fix

          Function connect_manhole has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def connect_manhole(pid, timeout, signal):
              os.kill(pid, signal)
          
              start = time.time()
              uds_path = f'/tmp/manhole-{pid}'
          Severity: Minor
          Found in src/hunter/remote.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

          Avoid deeply nested control flow statements.
          Open

                                  if not isinstance(value, (list, set, tuple)):
                                      raise ValueError(f'Value {value!r} for {key!r} is invalid. Must be a string, list, tuple or set.')
                                  value = tuple(value)
          Severity: Major
          Found in src/hunter/predicates.py - About 45 mins to fix

            Function yield_lines has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def yield_lines(
            Severity: Minor
            Found in src/hunter/event.py - About 45 mins to fix

              Function flatten has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def flatten(something):
                  if isinstance(something, (list, tuple)):
                      for element in something:
                          for subelement in flatten(element):
                              yield subelement
              Severity: Minor
              Found in src/hunter/util.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

              Avoid deeply nested control flow statements.
              Open

                                      for stack_event in stack_events:
                                          if self._filter is None or self._filter(stack_event):
                                              self.action(stack_event)
                              for backlog_event in self.queue:
              Severity: Major
              Found in src/hunter/predicates.py - About 45 mins to fix

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

                    def __call__(self, frame, kind, arg):
                        """
                        The settrace function.
                
                        .. note::
                Severity: Minor
                Found in src/hunter/tracer.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 stream has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def stream(self, value):
                        if isinstance(value, str):
                            if value in self._stream_cache:
                                value = self._stream_cache[value]
                            else:
                Severity: Minor
                Found in src/hunter/actions.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

                Avoid deeply nested control flow statements.
                Open

                                        while frame and depth_delta < missing_depth:
                                            stack_event = Event(
                                                frame=frame,
                                                kind='call',
                                                arg=None,
                Severity: Major
                Found in src/hunter/predicates.py - About 45 mins to fix

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

                  def main():
                      args = parser.parse_args()
                  
                      sink = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
                      sink_path = f'/tmp/hunter-{os.getpid()}'
                  Severity: Minor
                  Found in src/hunter/remote.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 trace has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def trace(self, predicate):
                          """
                          Starts tracing with the given callable.
                  
                          Args:
                  Severity: Minor
                  Found in src/hunter/tracer.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

                  Severity
                  Category
                  Status
                  Source
                  Language