Function get_inserts
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Confirmed
def get_inserts(self, data, inserts):
'''Returns a list containing the inserts for the color codes relative to
data. An insert is a list containing a position (index relative to data),
the code to be inserted, a boolean indicating if its a reset code or not,
and The color type which corresponds to COLOR_TYPES or `None` if it's a
- 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 decode_sgr
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Wontfix
def decode_sgr(source_color_code, is_reset=False):
'''Decodes an SGR, splitting it into a list of colors, each being a list
containing color code (bytes), is reset (bool), and color type (bytes)
which corresponds to `COLOR_TYPES`.
- 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 color
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Wontfix
def color(self, value):
if not isinstance(value, str):
raise TypeError('color must be a string')
color = value = value.lower().strip()
- 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 highlight
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Confirmed
def highlight(self, data):
'''Returns a highlighted bytes of `data`. The matches from the rules
are gathered prior to inserting any color codes, making it so the rules
can match without the color codes interfering.
- 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 get_insert_index
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Wontfix
def get_insert_index(start, end, inserts):
'''Returns a tuple containing the start and end indices for where they
should be inserted into the inserts list in order to maintain the
position-based descending (reverse) order.
- 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 get_matches
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Wontfix
def get_matches(self, data):
'''Returns a list of tuples, each of which containing a start index, an
end index, and the `Color` object for that match. The tuples of the
latter rules are towards the end of the list.
- 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. Confirmed
if insert[3] is None:
end_insert[1:4] = insert[1:4]
Function set_color
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Wontfix
def set_color(self, color, group=0):
'''Sets a color to be used when highlighting. The group can be used to
limit the parts of the match which are highlighted. Group 0 (the default)
will highlight the entire match. If a color already exists for the group,
it is overwritten. If `color` is None, the color of `group` is cleared.
- 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 get_matches
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
def get_matches(self, data):
'''Returns a list of tuples, each containing a start index, an end index,
and the `Color` object for that match.
Args:
- 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 add_color
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Wontfix
def add_color(self, name, value):
'''Adds a color to the palette.
Args:
name (str): The color name to be referenced. Accepts `[a-z0-9-_]+`.
- 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"