Open bkabrda opened 7 years ago
Hi, @bkabrda . Many thanks for the comprehensive code review. Can you please share who asked you to do it? The thing is that I came to the project a while ago, and did the same, and I'm aware of all the issues you wrote here as well as mtf as a single command, no need for makefiles, etc and etc, and working on them, just never reported all of those as an issue here, but in words to the other project members. Yeah, my bad, I should. And also, are you just reporting or also going to fix those? I just want to avoid further work duplication
@alexxa sure, @phracek asked me to do it :) Since I'm pretty occupied otherwise, I won't be working towards fixing these.
I actually initiated the work of doing complete review of mtf. The reason behind it is very simple: if we are suppose to use mtf to test modules and containers, I wanna make sure that mtf has high-quality code with polished workflows and is doing the right things.
Edit: looking in trello, I second Slavek: code review was initiated by Petr, not me.
@bkabrda @TomasTomecek thanks. It seems we have a communication issue with @phracek =( @TomasTomecek +1 on remark about enhancing MTF code quality.
@bkabrda @TomasTomecek @alexxa This is a bit longer issue. I would split it into more issues. What do you think?
I would probably turn original Slavek's post into checklist and just mark which items are already solved,
Hi, so I was asked to do a detailed code review for MTF, so here's the first issue - code style and statically checked warnings errors.
Since the outputs that I got from running pylint/pyflakes are quite sizable, I'll just comment on some general points. You can install these tools yourselves (
pip install --user pylint pyflakes
) and run them on the code (pylint moduleframework/
,pyflakes moduleframework/
) to see what's wrong. So here's some general comments from my code observations and pylint/pyflakes output:__init__
method in the child's__init__
. Occurs in multiple places, e.g.moduleframework.mtf_generator:TestGenerator.__init__
should callsuper(TestGenerator, self).__init__()
.moduleframework.setup
, there are some methods whose names begin in capital letters, some functions inmoduleframework.common
andmoduleframework.dockerlinter
use snakecase etc. I recommend choosing one naming scheme and applying it everywhere. The same applies to variable naming.moduleframework.module_framework
, line 1400-1404. While Python 2 can generally guess what you meant with e.g. 3 spaces, Python 3 will report this as syntax error, so I'd recommend fixing these.from compose_info import ..
, usefrom moduleframework.compose_info import ...
(this appears throughout the codebase).from foo import *
). These pose a danger of polluting your namespace and overriding methods with generic names that you import from elsewhere. You should always import exactly what you need (this appears throughout the codebase).=
, soself.__addModuleDependency(url=latesturl, name = dep, ...
is wrong,self.__addModuleDependency(url=latesturl, name=dep, ..
is correct. This occurs in multiple places. Also, exactly one space is required after comma that separates arguments.moduleframework.module_framework
, line 316 has wrong mode foropen
(rw
doesn't exist in Python). Judging from the code, you probably wanted to use justr
. Also, the file isn't closed anywhere.Exception
" in quite a lot of places. While this is occasionally ok to do, I'd recommend narrowing it down to a subclass if possible.pass
statements, these can be safely removed.x
,a
,b
, etc.foo
is not a great name either. While this is sometimes ok, I'd recommend considering using more descriptive names.__init__
, mostly inmoduleframework.pdc_data
. While this may sometimes make sense, I'd highly recommend initializing them toNone
or similar values inside__init__
.I'd highly recommend registering at some CI and adding runs of pylint/pyflakes to
make check
in order to keep code quality high.[1] https://www.python.org/dev/peps/pep-0008/#indentation [2] https://docs.python.org/2/library/re.html#module-re