Module: check_mk
Branch: master
Commit: 410750a0b0990a22c22bc5b0ed41b811e96d6196
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=410750a0b0990a…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jul 26 09:35:00 2018 +0200
Fixed and enabled consider-using-enumerate warning.
Change-Id: I0ab5ef4dd7a56e5dadef41ded5dcebbe93a326ec
---
checks/alcatel_temp | 11 ++++-------
checks/etherbox2_temp | 4 ++--
checks/genua_state_correlation | 6 +++---
cmk/gui/bi.py | 4 ++--
tests/pylint/pylintrc | 1 -
5 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/checks/alcatel_temp b/checks/alcatel_temp
index 3bb02c3..1b1f176 100644
--- a/checks/alcatel_temp
+++ b/checks/alcatel_temp
@@ -29,15 +29,12 @@ factory_settings['alcatel_temp'] = {
}
def inventory_alcatel_temp(info):
- with_slot = True
- if len(info) == 1:
- with_slot = False
- for index in range(len(info)):
- slot = index + 1
+ with_slot = len(info) != 1
+ for index, row in enumerate(info):
for oid, name in enumerate(["Board", "CPU"]):
- if info[index][oid] != '0':
+ if row[oid] != '0':
if with_slot:
- yield "Slot %s %s" % (slot, name), {}
+ yield "Slot %s %s" % (index + 1, name), {}
else:
yield name, {}
diff --git a/checks/etherbox2_temp b/checks/etherbox2_temp
index 92a8817..01b94ce 100644
--- a/checks/etherbox2_temp
+++ b/checks/etherbox2_temp
@@ -56,11 +56,11 @@ def parse_etherbox2_temp(info):
# because the temperature can drop below 0.
parsed = {}
sensor_indicators, sensors = info
- for sensor_index in range(0, len(sensors)):
+ for sensor_index, sensor in enumerate(sensors):
indicator_index = 2 * sensor_index
if
float((sensor_indicators[indicator_index][0].split("Volt")[0]).strip()) > 4
and \
float((sensor_indicators[indicator_index +
1][0].split("Volt")[0]).strip()) > 1:
- parsed["Sensor %s" % sensors[sensor_index][0]] =
float(sensors[sensor_index][1]) / 10
+ parsed["Sensor %s" % sensor[0]] = float(sensor[1]) / 10
return parsed
diff --git a/checks/genua_state_correlation b/checks/genua_state_correlation
index 5a03836..8feb3f9 100644
--- a/checks/genua_state_correlation
+++ b/checks/genua_state_correlation
@@ -76,9 +76,9 @@ def check_genua_state(item, _no_params, info):
# critical if the carp interfaces dont have the same state
carp_states = [ 0, 0, 0 ]
- for i in range (0, len(carp_info)):
- carp_states[int(carp_info[i][4])] += 1
- if carp_info[0][4] != carp_info[i][4]:
+ for i, elem in enumerate(carp_info):
+ carp_states[int(elem[4])] += 1
+ if carp_info[0][4] != elem[4]:
state = 2
output = "Number of carp IFs in states "
diff --git a/cmk/gui/bi.py b/cmk/gui/bi.py
index fd6f45f..680ae8c 100644
--- a/cmk/gui/bi.py
+++ b/cmk/gui/bi.py
@@ -1924,8 +1924,8 @@ def remove_empty_nodes(node):
else:
subnodes = node["nodes"]
# loop all subnodes recursing down to the lowest level
- for i in range(0, len(subnodes)):
- remove_empty_nodes(subnodes[i])
+ for subnode in subnodes:
+ remove_empty_nodes(subnode)
# remove all subnode rules which have no subnodes
for i in range(0, len(subnodes))[::-1]:
if node_is_empty(subnodes[i]):
diff --git a/tests/pylint/pylintrc b/tests/pylint/pylintrc
index afae56e..3f9ff2d 100644
--- a/tests/pylint/pylintrc
+++ b/tests/pylint/pylintrc
@@ -14,7 +14,6 @@ extension-pkg-whitelist=rrdtool,_ldap,netifaces,pymssql
disable=
cell-var-from-loop,
consider-iterating-dictionary,
- consider-using-enumerate,
inconsistent-return-statements,
logging-not-lazy,
missing-docstring,