tobi-wan-kenobi/bumblebee-status

View on GitHub

Showing 266 of 266 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def __init__(self, config, theme):
super().__init__(config, theme, [])
 
self.__layout = self.parameter(
"layout", "cpu3.maxfreq cpu3.cpuload cpu3.coresload cpu3.temp cpu3.fanspeed"
Severity: Major
Found in bumblebee_status/modules/contrib/cpu3.py and 1 other location - About 3 days to fix
bumblebee_status/modules/contrib/cpu2.py on lines 47..81

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def __init__(self, config, theme):
super().__init__(config, theme, [])
 
self.__layout = self.parameter(
"layout", "cpu2.maxfreq cpu2.cpuload cpu2.coresload cpu2.temp cpu2.fanspeed"
Severity: Major
Found in bumblebee_status/modules/contrib/cpu2.py and 1 other location - About 3 days to fix
bumblebee_status/modules/contrib/cpu3.py on lines 53..87

Function __create_widgets has a Cognitive Complexity of 95 (exceeds 5 allowed). Consider refactoring.
Open

def __create_widgets(self):
show_temp = util.format.asbool(self.parameter("showtemp", True))
show_fan = util.format.asbool(self.parameter("showfan", True))
show_other = util.format.asbool(self.parameter("showother", False))
include_chip = tuple(
Severity: Minor
Found in bumblebee_status/modules/core/sensors2.py - About 1 day to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if charge == "Discharging":
state.append(
"discharging-{}".format(
min([10, 25, 50, 80, 100], key=lambda i: abs(i - capacity))
)
Severity: Major
Found in bumblebee_status/modules/contrib/battery-upower.py and 1 other location - About 1 day to fix
bumblebee_status/modules/contrib/battery.py on lines 192..208

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if charge == "Discharging":
state.append(
"discharging-{}".format(
min([10, 25, 50, 80, 100], key=lambda i: abs(i - capacity))
)
Severity: Major
Found in bumblebee_status/modules/contrib/battery.py and 1 other location - About 1 day to fix
bumblebee_status/modules/contrib/battery-upower.py on lines 322..338

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def update(self):
if "cpu2.maxfreq" in self.__widget_names:
self.__maxfreq = psutil.cpu_freq().max / 1000
if "cpu2.cpuload" in self.__widget_names:
self.__cpuload = round(psutil.cpu_percent(percpu=False))
Severity: Major
Found in bumblebee_status/modules/contrib/cpu2.py and 1 other location - About 1 day to fix
bumblebee_status/modules/contrib/cpu3.py on lines 143..151

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def update(self):
if "cpu3.maxfreq" in self.__widget_names:
self.__maxfreq = psutil.cpu_freq().max / 1000
if "cpu3.cpuload" in self.__widget_names:
self.__cpuload = round(psutil.cpu_percent(percpu=False))
Severity: Major
Found in bumblebee_status/modules/contrib/cpu3.py and 1 other location - About 1 day to fix
bumblebee_status/modules/contrib/cpu2.py on lines 139..147

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def add_color(self, bar):
"""add color as pango markup to a bar"""
if bar in ["▁", "▂"]:
color = self.theme.color("green", "green")
elif bar in ["▃", "▄"]:
Severity: Major
Found in bumblebee_status/modules/contrib/cpu3.py and 1 other location - About 1 day to fix
bumblebee_status/modules/contrib/cpu2.py on lines 89..100

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def add_color(self, bar):
"""add color as pango markup to a bar"""
if bar in ["▁", "▂"]:
color = self.theme.color("green", "green")
elif bar in ["▃", "▄"]:
Severity: Major
Found in bumblebee_status/modules/contrib/cpu2.py and 1 other location - About 1 day to fix
bumblebee_status/modules/contrib/cpu3.py on lines 95..106

Similar blocks of code found in 2 locations. Consider refactoring.
Open

if (
capacity < int(self.parameter("critical", 10))
and self.power.get_state(self.device) == "Discharging"
):
state.append("critical")
Severity: Major
Found in bumblebee_status/modules/contrib/battery-upower.py and 1 other location - About 6 hrs to fix
bumblebee_status/modules/contrib/battery.py on lines 210..219

Similar blocks of code found in 2 locations. Consider refactoring.
Open

if (
capacity < int(self.parameter("critical", 10))
and self.__manager.charge_any(self._batteries) == "Discharging"
):
state.append("critical")
Severity: Major
Found in bumblebee_status/modules/contrib/battery.py and 1 other location - About 6 hrs to fix
bumblebee_status/modules/contrib/battery-upower.py on lines 339..348

Function update has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

def update(self):
widget = self.widget()
res = util.cli.execute("dnf updateinfo summary", ignore_errors=True)
 
security = 0
Severity: Minor
Found in bumblebee_status/modules/contrib/dnf.py - About 5 hrs to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

for state in tuple(
filter(len, util.format.aslist(self.parameter("states", "")))
):
if state[0] == "^":
self._states["exclude"].append(state[1:])
Severity: Major
Found in bumblebee_status/modules/core/nic.py and 1 other location - About 5 hrs to fix
bumblebee_status/modules/contrib/traffic.py on lines 51..57

Identical blocks of code found in 2 locations. Consider refactoring.
Open

for state in tuple(
filter(len, util.format.aslist(self.parameter("states", "")))
):
if state[0] == "^":
self._states["exclude"].append(state[1:])
Severity: Major
Found in bumblebee_status/modules/contrib/traffic.py and 1 other location - About 5 hrs to fix
bumblebee_status/modules/core/nic.py on lines 46..52

Cyclomatic complexity is too high in method __create_widgets. (40)
Open

def __create_widgets(self):
show_temp = util.format.asbool(self.parameter("showtemp", True))
show_fan = util.format.asbool(self.parameter("showfan", True))
show_other = util.format.asbool(self.parameter("showother", False))
include_chip = tuple(

Function _update_widgets has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

def _update_widgets(self):
interfaces = [
i for i in netifaces.interfaces() if not i.startswith(self._exclude)
]
 
 
Severity: Minor
Found in bumblebee_status/modules/contrib/traffic.py - About 4 hrs to fix

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def get_addresses(self, intf):
retval = []
try:
for ip in netifaces.ifaddresses(intf).get(netifaces.AF_INET, []):
if ip.get("addr", "") != "":
Severity: Major
Found in bumblebee_status/modules/contrib/traffic.py and 1 other location - About 4 hrs to fix
bumblebee_status/modules/core/nic.py on lines 101..109

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def get_addresses(self, intf):
retval = []
try:
for ip in netifaces.ifaddresses(intf).get(netifaces.AF_INET, []):
if ip.get("addr", "") != "":
Severity: Major
Found in bumblebee_status/modules/core/nic.py and 1 other location - About 4 hrs to fix
bumblebee_status/modules/contrib/traffic.py on lines 85..93

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def coresload(self, _):
mono_bars = [util.graph.hbar(x) for x in self.__coresload]
if not self.__colored:
return "".join(mono_bars)
colored_bars = [self.add_color(x) for x in mono_bars]
Severity: Major
Found in bumblebee_status/modules/contrib/cpu3.py and 1 other location - About 4 hrs to fix
bumblebee_status/modules/contrib/cpu2.py on lines 102..107

Identical blocks of code found in 2 locations. Consider refactoring.
Open

def coresload(self, _):
mono_bars = [util.graph.hbar(x) for x in self.__coresload]
if not self.__colored:
return "".join(mono_bars)
colored_bars = [self.add_color(x) for x in mono_bars]
Severity: Major
Found in bumblebee_status/modules/contrib/cpu2.py and 1 other location - About 4 hrs to fix
bumblebee_status/modules/contrib/cpu3.py on lines 108..113
Severity
Category
Status
Source
Language