Showing 9 of 18 total issues
Function select_content_type
has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring. Open
def select_content_type(
requested: abc.Sequence[datastructures.ContentType],
available: abc.Sequence[datastructures.ContentType]
) -> tuple[datastructures.ContentType, datastructures.ContentType]:
"""Selects the best content type.
- 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_accept
has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring. Open
def parse_accept(header_value: str,
strict: bool = False) -> list[datastructures.ContentType]:
"""Parse an HTTP accept-like header.
:param header_value: the header value to parse
- 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_link
has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring. Open
def parse_link(header_value: str,
strict: bool = True) -> list[datastructures.LinkHeader]:
"""
Parse a HTTP Link header.
- 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
Avoid deeply nested control flow statements. Open
if extract_quality(pattern) == 0.0:
raise errors.NoMatch # quality of 0 means NO
return candidate, pattern
Function _parse_parameter_list
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring. Open
def _parse_parameter_list(
parameter_list: abc.Iterable[str],
normalize_parameter_names: bool = False,
normalize_parameter_values: bool = True,
strip_interior_whitespace: bool = False) -> list[tuple[str, str]]:
- 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
Avoid too many return
statements within this function. Open
return 1
Avoid too many return
statements within this function. Open
return self.content_type < other.content_type
Avoid too many return
statements within this function. Open
return self.content_subtype < other.content_subtype
Function parse_cache_control
has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring. Open
def parse_cache_control(
header_value: str) -> dict[str, str | int | bool | None]:
"""
Parse a `Cache-Control`_ header, returning a dictionary of key-value pairs.
- 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"