23
loading...
This website collects cookies to deliver better user experience
Each person has their own, unique style
Code quality issue | Java group | C++ group |
---|---|---|
Line too long | 3.59 | 1.44 |
Invalid name | 1.43 | 1.52 |
Wrong import order | — | 1.83 |
Ungrouped imports | 0.16 | 0.14 |
Bad whitespace | — | 0.38 |
Unnecessary semicolon | 4.42 | 20.62 |
Redefining built-in names | 0.57 | — |
Bad indentation | 3.39 | 3.28 |
Redefining outer name | 1.68 | 2.21 |
Undefined loop variable | — | 3.28 |
Unused import | 0.63 | 0.81 |
Unused variable | 1.56 | 2.25 |
Complex method/function | 0.84 | 1.48 |
Too many public methods | 0.26 | 0.46 |
Too few public methods | 0.34 | 0.58 |
No else return | — | 1.52 |
Undefined variable | — | 1.55 |
Assignment from no return | 28.27 | — |
Line too long: Python lines should not be longer than 80 characters. C++ and Java developers tend write lines that are longer than that.
Invalid name: Class names in Python should be CamelCased, while method and field names should be snake_cased. Programmers from the other two languages regularly violate these naming conventions.
Wrong import order: Module imports should be ordered such that standard libraries are imported first, followed by third-party libraries, and finally local imports. C++ developers violate this convention a lot more often, but Java developers seem to do the same thing as Python developers.
Ungrouped imports: Multiple imports from the same package should be grouped together. Java and C++ developers do this way more often than Python developers.
Bad whitespace: C++ and Java developers are less likely to miss or add too much whitespace around operators, brackets, and blocks than Python developers.
Unnecessary semicolon: Python doesn’t need semicolons at the end of lines, but (especially) C++ and Java developers tend to add them anyway.
Redefining built-in names: Developers may accidentally use variable names which are already used for existing names (e.g. input
and str
). This may cause unexpected or confusing errors. Java developers do this less often than Python developers, despite being less familiar with the language. This is probably because they use IDEs (which would point out such mistakes) rather than simple text editors.
Bad indentation: Whitespace is important in Python, so it helps if tabs and spaces are used consistently. Java and C++ developers aren’t as good at this as Python developers.
Redefining outer name: Shadowing names from outer scopes is discouraged in Python, but both Java and C++ developers do this more often than Python developers.
Undefined loop variable: Using loop variables outside the loop can be useful in some situations, but only when the loop was actually executed. C++ developers are 3 times more likely to write code with potentially undefined variables.
Unused import: Both Java and C++ developers are less likely to have unused imports in their files.
Unused variable: On the other hand, Java and C++ developers are more likely to forget about previously defined variables.
Complex method/function: C++ developers are more likely to write methods or functions with a cyclomatic complexity above 10.
Too many public methods: Java and C++ developers tend to make smaller classes and thus don’t run into this issue as often.
Too few public methods: The opposite, where classes are merely used as glorified data structures without any behaviour of their own, also occurs less often with Java and C++ developers.
No else return: Having an else
statement after an if
is considered bad style. C++ developers use this more often than Python developers.
Undefined variable: Undefined variables are often not reachable right now, but might become reachable when the code is modified in the future and thus cause errors later. C++ developers are more likely to write code with undefined variables.
Assignment from no return: Java developers are more likely to use “void” functions in assignments or as expressions, possibly because these would have been checked in Java during compilation – but not in Python.