Showing 52 of 52 total issues
Function _rfc2231_and_continuation_params
has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring. Open
def _rfc2231_and_continuation_params(cls, params: Iterator[Any]) -> Iterator[Tuple[bytes, str]]: # TODO: complexity
count = set()
continuations = dict()
for key, value, quoted in params:
if key in count:
- 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
Body
has 33 functions (exceeds 20 allowed). Consider refactoring. Open
class Body(with_metaclass(HTTPSemantic, IFile)):
u"""A HTTP message body.
This class is capable of handling HTTP Transfer-Encoding
and Content-Encoding as defined in RFC 2616.
File messaging.py
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
# TODO: Via, Server, User-Agent can contain comments → parse them
import re
from typing import Any, List, Optional
File element.py
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
"""HTTP header elements.
.. seealso:: :rfc:`2616#section-2.2`
File uri.py
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
# -*- coding: utf-8 -*-
"""Uniform Resource Identifier.
.. seealso:: :rfc:`3986`
"""
Function __call__
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def __call__(self, application: Callable) -> Iterator[Any]:
def write(data):
if not self.headers_set:
raise RuntimeError("write() before start_response()")
elif not self.headers_sent:
- 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
URI
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
class URI(with_metaclass(URIType)):
u"""Uniform Resource Identifier."""
__slots__ = ('scheme', 'username', 'password', 'host', '_port', 'path', 'query_string', 'fragment')
slots = __slots__
Function parse
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def parse(cls, elementstr: bytes) -> "Range":
bytesunit, __, byteranges = elementstr.partition(b'=')
byteranges = super(Range, cls).split(byteranges)
ranges = set()
for brange in byteranges:
- 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
StateMachine
has 26 functions (exceeds 20 allowed). Consider refactoring. Open
class StateMachine(object):
u"""A protocol state machine which supports pipelining and
parses HTTP messages by turning them into appropriate objects.
"""
HeaderElement
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class HeaderElement(with_metaclass(HeaderType)):
u"""An element (with parameters) from an HTTP header's element list."""
priority = None
is_request_header = False
Function get_links
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def get_links(self, relation: str, name: None=None) -> Iterator[Dict[str, Union[None, bool, str]]]:
links = self['_links'].get(relation)
if links is None:
return
if isinstance(links, dict):
- 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 _unquote_host
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def _unquote_host(self, host: bytes) -> str:
# IPv6 / IPvFuture
if host.startswith(b'[') and host.endswith(b']'):
host = host[1:-1]
try:
- 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 _parse
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def _parse(self) -> Iterator[Union[None, Response, Tuple[Request, Response]]]:
while self.buffer:
if self.message is None:
yield self.on_message_started()
state = self.state
- 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
Status
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class Status(with_metaclass(HTTPSemantic)):
u"""A HTTP Status.
:rfc:`2616#section-6.2`
"""
Function prepare
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def prepare(self) -> None:
u"""prepares the response for being ready for transmitting."""
response = self.response
status = int(response.status)
- 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 __setattr__
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __setattr__(self, name: str, value: Any) -> None:
if name.startswith('_'):
return super(URI, self).__setattr__(name, value)
if name == 'scheme' and value:
- 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 parse
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def parse(self, uri: bytes) -> None:
r"""Parses a well formed absolute or relative URI.
foo://example.com:8042/over/there?name=ferret#nose
\_/ \______________/\_________/ \_________/ \__/
- 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 prepare
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def prepare(self) -> None:
if self.message.method.safe:
self.message.body = None
self.chunked = False
- 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 parse
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def parse(cls, elementstr: bytes) -> "ContentRange":
value, start, end, complete_length = None, None, None, None
try:
value, content_range = elementstr.split(None, 1)
if value != b'bytes':
- 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 set
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def set(self, content: Any) -> None:
if isinstance(content, Body):
self.mimetype = content.mimetype
self.data = content.data
self.chunked = content.chunked
- 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"