Showing 18 of 37 total issues
File mock.py
has 674 lines of code (exceeds 250 allowed). Consider refactoring. Open
import functools
from furl import furl
from inspect import isfunction, ismethod
from .response import Response
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.
File api.py
has 400 lines of code (exceeds 250 allowed). Consider refactoring. Open
import functools
import re
from contextlib import contextmanager
from inspect import isfunction
File engine.py
has 321 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
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.
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.
- Read upRead up
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 22 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.
Function trigger_methods
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def trigger_methods(instance, args, key_order=None):
"""
Triggers specific class methods using a simple reflection
mechanism based on the given input dictionary params.
- Read upRead up
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 extend
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def extend(self, mapping, **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__
- Read upRead up
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`.
- Read upRead up
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(
Function _on_request
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def _on_request(self, _request, conn, method, url, body=None, headers=None, **kw):
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):
- Read upRead up
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:
- Read upRead up
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, urlopen, path, pool, method, url, body=None, headers=None, **kw
):
# Remove bypass headers
real_headers = dict(headers or {})
- Read upRead up
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.
- Read upRead up
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):
Function handler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def handler(conn, method, url, body=None, headers=None, **kw):