Skip to content

Commit edbb48c

Browse files
committed
Fix pylint unnecessary-list-index-lookup
Prospector 1.7.7 pulls in a newer pylint which give an unnecessary-list-index-lookup error for new PRs. This commit fixes the issue by accessing the value directly when iterating over an enumeration instead of accessing the value by index lookup. Signed-off-by: Rose Judge <[email protected]>
1 parent 43fd06f commit edbb48c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tern/formats/html/generator.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,28 +197,28 @@ def origins_handler(list_obj, indent):
197197
def list_handler(list_obj, indent):
198198
'''Write html code for lists in report dictionary'''
199199
html_string = ''
200-
for i, _ in enumerate(list_obj):
201-
if isinstance(list_obj[i], dict):
202-
if "name" in list_obj[i].keys():
200+
for i, lo in enumerate(list_obj):
201+
if isinstance(lo, dict):
202+
if "name" in lo.keys():
203203
html_string = html_string + ' '*indent + \
204-
'<li><span class="caret">' + str(list_obj[i]["name"]) + \
204+
'<li><span class="caret">' + str(lo["name"]) + \
205205
' : ' + '</span> \n '
206206
else:
207207
html_string = html_string + ' '*indent + \
208208
'<li><span class="caret">' + str(i) + ' : ' + '</span> \n '
209-
html_string = html_string + dict_handler(list_obj[i], indent+1)
209+
html_string = html_string + dict_handler(lo, indent+1)
210210
html_string = html_string + ' '*indent + '</li> \n '
211-
elif isinstance(list_obj[i], list):
211+
elif isinstance(lo, list):
212212
html_string = html_string + ' '*indent + \
213213
'<li><span class="caret">' + str(i) + ' : ' + '</span> \n '
214214
html_string = html_string + ' '*indent + \
215215
'<ul class ="nested"> \n '
216-
html_string = html_string + list_handler(list_obj[i], indent+1)
216+
html_string = html_string + list_handler(lo, indent+1)
217217
html_string = html_string + ' '*indent + '</ul> \n ' + \
218218
' '*indent + '</li>\n '
219219
else:
220220
html_string = html_string + ' '*indent + '<li>' + \
221-
'<span class="text-c">' + str(list_obj[i]) + \
221+
'<span class="text-c">' + str(lo) + \
222222
'</span>\n</li> \n '
223223
return html_string
224224

0 commit comments

Comments
 (0)