Showing 17 of 37 total issues
Function highlight_hunk
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def highlight_hunk(new, new_lo, new_hi, old, old_lo, old_hi):
# derived from difflib.py (Python stdlib) Differ#_fancy_replace()
best_ratio, cutoff = 0.59, 0.60
cruncher = SequenceMatcher(None)
- 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 arrange_indented_hunks
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def arrange_indented_hunks(lines):
result = []
def typeof(line):
return line[0][0][0:1] # +, - or other
- 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 is_mergeable
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def is_mergeable(new, old, i):
chars = '[a-zA-Z0-9_.]'
startswith_word = lambda s: re.match('^%s' % chars, s[0])
endswith_word = lambda s: re.search('%s$' % chars, s[0])
is_word = lambda s: re.match('^(%s+|\s+)$' % chars, s[0])
- 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_main
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def highlight_main():
try:
new, old = [], []
in_header = True
for rawline in sys.stdin:
- 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 flush_hunk
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def flush_hunk(self):
if self.hunk is None: # not initialized yet
return
hunk = [(ret[0].decode('utf-8'), ret[1]) for ret in self.hunk]
- 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_pair
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def highlight_pair(cruncher, newline, oldline):
new = [[newline[0], INSERTED, False]]
old = [[oldline[0], DELETED, False]]
cruncher.set_seqs(newline[1:], oldline[1:])
- 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 show_hunk
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def show_hunk(new, old):
for string, style, highlighted, in pprint_hunk(new, 0, len(new),
old, 0, len(old)):
if style == INSERTED:
- 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_hunk_helper
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def highlight_hunk_helper(new, new_lo, new_hi, old, old_lo, old_hi):
# derived from difflib.py (Python stdlib) Differ#_fancy_helper()
if new_lo < new_hi:
if old_lo < old_hi:
for hunk in highlight_hunk(new, new_lo, new_hi, old, old_lo, old_hi):
- 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 write
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def write(self, *args, **opts):
label = opts.get('label')
if label in (INSERT_NORM, DELETE_NORM):
if self.tab is not None:
change = self.hunk.pop()
- 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 uisetup
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def uisetup(ui):
if ui.plain():
return
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 highlight_hunk
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def highlight_hunk(new, new_lo, new_hi, old, old_lo, old_hi):
Function highlight_hunk_helper
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def highlight_hunk_helper(new, new_lo, new_hi, old, old_lo, old_hi):
Function pprint_hunk
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def pprint_hunk(new, new_lo, new_hi, old, old_lo, old_hi):
Consider simplifying this complex logical expression. Open
if (inserted[0][0] == "+" and re.match('^\s*$', inserted[1][0]) and len(inserted) == 4 and
deleted[0][0] == "-" and re.match('^\s*$', deleted[1][0]) and len(deleted) == 4):
return True
else:
return False
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return False
Function write
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def write(string, color=None, highlight=False):
if color:
sys.stdout.write("\x1b[%dm" % colortable[color])
if highlight:
- 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"