Codeq. Code quality as a service
codeq.io
codeq.io
Compare the output of a "real" static analysis tool that finds logic bugs[0]
https://www.dropbox.com/s/md35ca9mjrny4o1/Screen%20Shot%2020...
With their whitespace recommendations
https://codeq.io/github/tianyang-li/rna-seq-len-est-0/master...
Which seem to mostly be a wrapper around autopep8: https://github.com/hhatto/autopep8.
Even Pylint / Pyflakes would be more "static analyzer" than this tool, although it's a stretch.
[0] In this case it trips an assert, so the bug can't "really" happen. Still, it's pretty impressive stuff.
- calling non-existent members (including class hierarchy analysis)
- reading non-existent variables
See the Exxxx messages http://pylint-messages.wikidot.com/all-messages
Why is it a stretch to say that Pylint does static analysis? This is exactly what Pylint does.
When I think of code quality, I consider things like:
- consistent memory management practices
- consistent use of accessor methods vs. direct ivar access
- descriptive method, function, and variable names
- commentary to describe caveats and tricky functionality
Those first two (as well as formatting concerns) can be handled by tools while the next two are very "human" and subjective.Here's a sample of the output: https://codeq.io/github/yakxxx/memek/master/crawler/tests/te...
> Trailing whitespace (1, 29, 34)
Missing optional whitespace around operator (6, 48)
Blank line contains whitespace (11, 15, 19, 23—25, 33, 44—45, 53—55)
Continuation line under-indented for visual indent (17, 21)
No spaces around keyword / parameter equals (17, 21, 48)
Line too long (100 > 79 characters) (21)
Too many blank lines (3) (26)
Continuation line over-indented for hanging indent (29, 34)
Missing whitespace after ':' (30—31, 35—36)
Line too long (81 > 79 characters) (30, 35)
Continuation line indentation is not a multiple of four (30, 35)
Line too long (80 > 79 characters) (31, 36)
Closing bracket does not match indentation of opening bracket's line (38)
Too many blank lines (2) (46)
Line too long (91 > 79 characters) (47)
Blank line at end of file (55)
Not to mention that it's quite simple to have your CI server perform these kinds of checks already.So it's basically pep8 as a service.
This is your second thing you think of when you think of code quality? I think we're right back at "formatted the way this tool's author believes is correct." Your other 3 points are good though, and I'd also add
- uses generic code only where required, and uses exceptional code only when neededSave yourself the money and run pep8 (better, forget about pep8 and run autopep8) and PyLint. Tune their output to your taste
Code style is important but it can be borderline pedantic sometimes.
Also, more than 80 chars fit in my screen
Not to mention that static code analysis can go so far
This isn't the argument, and you know it. I can split an editor window three ways on my MBP and still have all the code look fine if everyone keeps their code to 80 character lines.
Most of the editors do automatic line wrapping, and it looks good regardless of the width picked for the window.
I'm not advocating we start doing very long lines, I'm just saying a hard limit of 80 chars is debatable.
- As others pointed out, the error/reporting needs to be better. Ideally it should gives insight that a normal pep8 parser wouldn't give. I.e. I don't mind that much for the whitespaces.. but if you help me avoid a real bug, that's a huge deal.
Not everything has to be wrapped "as a service".
The same way CLANG works with OBJ-C in Xcode.