Showing 22 of 47 total issues

File mock.py has 636 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import re
import functools
from furl import furl
from inspect import isfunction, ismethod

Severity: Major
Found in pook/mock.py - About 1 day to fix

    Mock has 42 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Mock(object):
        """
        Mock is used to declare and compose the HTTP request/response mock
        definition and matching expectations, which provides fluent API DSL.
    
    
    Severity: Minor
    Found in pook/mock.py - About 5 hrs to fix

      File api.py has 379 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import functools
      import re
      from contextlib import contextmanager
      from inspect import isfunction
      
      
      Severity: Minor
      Found in pook/api.py - About 5 hrs to fix

        File engine.py has 320 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from functools import partial
        from inspect import isfunction
        from .mock import Mock
        from .regex import isregex
        from .mock_engine import MockEngine
        Severity: Minor
        Found in pook/engine.py - About 3 hrs to fix

          Engine has 30 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Engine(object):
              """
              Engine represents the mock interceptor and matcher engine responsible
              of triggering interceptors and match outgoing HTTP traffic.
          
          
          Severity: Minor
          Found in pook/engine.py - About 3 hrs to fix

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

                def match(self, request):
                    """
                    Matches a given Request instance contract against the registered mocks.
            
                    If a mock passes all the matchers, its response will be returned.
            Severity: Minor
            Found in pook/engine.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

            HTTPHeaderDict has 23 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class HTTPHeaderDict(MutableMapping):
                """
                :param headers:
                    An iterable of field-value pairs. Must not contain multiple field names
                    when compared case-insensitively.
            Severity: Minor
            Found in pook/headers.py - About 2 hrs to fix

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

                  def extend(self, *args, **kwargs):
                      """
                      Generic import function for any type of header-like object.
                      Adapted version of MutableMapping.update in order to insert items
                      with self.add instead of self.__setitem__
              Severity: Minor
              Found in pook/headers.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 trigger_methods has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def trigger_methods(instance, args):
                  """"
                  Triggers specific class methods using a simple reflection
                  mechanism based on the given input dictionary params.
              
              
              Severity: Minor
              Found in pook/helpers.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 match has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def match(self, request):
                      """
                      Matches an outgoing HTTP request against the current mock matchers.
              
                      This method acts like a delegator to `pook.MatcherEngine`.
              Severity: Minor
              Found in pook/mock.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 _on_request has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def _on_request(self, urlopen, path, pool, method, url,
              Severity: Major
              Found in pook/interceptors/urllib3.py - About 1 hr to fix

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

                    def _on_request(self, _request, conn, method, url,
                Severity: Major
                Found in pook/interceptors/http.py - About 50 mins to fix

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

                      def _on_request(self, _request, session, method, url,
                  Severity: Major
                  Found in pook/interceptors/aiohttp.py - About 50 mins to fix

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

                        def url(self, url):
                            if isregex(url):
                                self._url = url
                            else:
                                if not protoregex.match(url):
                    Severity: Minor
                    Found in pook/request.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 compare has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def compare(expr, value, regex_expr=False):
                        """
                        Compares an string or regular expression againast a given value.
                    
                        Arguments:
                    Severity: Minor
                    Found in pook/compare.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 _on_request has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def _on_request(self, _request, session, method, url,
                                        data=None, headers=None, **kw):
                            # Create request contract based on incoming params
                            req = Request(method)
                            req.headers = headers or {}
                    Severity: Minor
                    Found in pook/interceptors/aiohttp.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 __call__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def __call__(self, fn):
                            """
                            Overload Mock instance as callable object in order to be used
                            as decorator definition syntax.
                    
                    
                    Severity: Minor
                    Found in pook/mock.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 handler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                            def handler(conn, method, url, body=None, headers=None, **kw):
                    Severity: Minor
                    Found in pook/interceptors/urllib3.py - About 35 mins to fix

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

                              def handler(conn, method, url, body=None, headers=None, **kw):
                      Severity: Minor
                      Found in pook/interceptors/http.py - About 35 mins to fix

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

                                def handler(session, method, url, data=None, headers=None, **kw):
                        Severity: Minor
                        Found in pook/interceptors/aiohttp.py - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language