avocado-framework / inspektor

Inspektor code checker
Other
11 stars 17 forks source link

Fix inspektor LinterStats no attribute get issue #41

Closed chunfuwen closed 2 years ago

chunfuwen commented 2 years ago

Linterstats should be a list

Signed-off-by: chunfuwen chwen@redhat.com

chunfuwen commented 2 years ago

Issue log:https://github.com/autotest/tp-libvirt/runs/4330091467?check_suite_focus=true


Run inspekt checkall --disable-style E501,E265,W601,W605,E402,E722,E741 --no-license-check inspekt checkall --disable-style E501,E265,W601,W605,E402,E722,E741 --no-license-check shell: /usr/bin/bash -e {0} env: pythonLocation: /opt/hostedtoolcache/Python/3.6.15/x64 LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.6.15/x64/lib PEP8 disabled: E501,E265,W601,W605,E402,E722,E741 Pylint disabled: W,R,C,E1002,E1101,E1103,E1120,F0401,I0011 Pylint enabled : W0611 License check: disabled 'LinterStats' object has no attribute 'get' Error: Process completed with exit code 1.


chunfuwen commented 2 years ago

After change, and test local environment , the issue is fixed:

(testinspec) [root@hp-dl360g9-16 tp-libvirt]# inspekt checkall --disable-style E501,E265,W601,W605,E402,E722,E741 --no-license-check PEP8 disabled: E501,E265,W601,W605,E402,E722,E741 Pylint disabled: W,R,C,E1002,E1101,E1103,E1120,F0401,I0011 Pylint enabled : W0611 License check: disabled Global check PASS

iccaszhulili commented 2 years ago

LGTM

chunfuwen commented 2 years ago

@clebergnu could you please take a look since it is urgent? thanks.

Yingshun commented 2 years ago

@chunfuwen It works in my environment with pylint 2.11.1, so it might be a pylint issue I think... Please see(https://github.com/autotest/tp-libvirt/pull/3894)

DanielNoord commented 2 years ago

Contributor to pylint here. Sorry about this bug. We did not consider this part of our API to be public.

Please see @ldoktor's suggestion and ignore mine!

While removing this particular piece of code makes the code backwards compatible, an actual fix for this bug which retains the previous functionality would be:

           for module, status in runner.linter.stats.by_module.items():
                 if any(status.values()):
                     self.log.debug('Lint: %s FAIL', module)
                 else:
                     self.log.debug('Lint: %s PASS', module)

However, this would require to update the dependency on pylint to 2.12+. If this is indeed desired @chunfuwen would need to update the PR as I can't make a suggestion on removed code.

clebergnu commented 2 years ago

Hi @chunfuwen, looks like @ldoktor suggestion combines the best of both worlds. Please consider that suggestion. Thanks.

chunfuwen commented 2 years ago

@clebergnu @ldoktor Codes are updated accordingly as per above mentioned comments

chunfuwen commented 2 years ago

@ldoktor Thank you for merging this PR. Do you have plan to sync up with https://pypi.org/project/inspektor/ and release new tag: 0.5.3?