Showing 9 of 12 total issues
File updater.py
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
import os
import subprocess
import sys
import requests
import shutil
Function get_http_proxy
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_http_proxy():
default_proxy = os.environ.get(proxy_env)
no_proxy = os.environ.get(no_proxy_env)
if default_proxy and no_proxy:
return default_proxy, no_proxy
- 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 colored
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def colored(text, color=None, on_color=None, attrs=None):
"""Colorize text.
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
- 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 pretty_print_group
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def pretty_print_group(key, aliases, highlight=None, only_groupname=False):
if len(aliases) == 0:
return
group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
- 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
for div in divergence.split(', '):
if 'ahead' in div:
ahead = int(div[len('ahead '):].strip())
elif 'behind' in div:
behind = int(div[len('behind '):].strip())
Function cprint
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, message, returncode, stage, stdout, stderr):
Function cheatsheet
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def cheatsheet(lines):
exps = [ parse(line) for line in lines ]
exps.sort(key=lambda exp:exp[2])
cheatsheet = {'_default': []}
for key, group in itertools.groupby(exps, lambda exp:exp[2]):
- 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 pretty_print
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
sorted_key = sorted(cheatsheet.keys())
for key in sorted_key:
if group_list and key not in group_list:
continue
- 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"