Hello Python developers,
Dead Code Detection
Python analysis goes a step further and can detect dead code issues which can be at the origin of unexpected behaviors of your application:
- S1763: All code should be reachable. (Bug)
- S1751: Loops with at most one iteration should be refactored. (Bug)
- S3626: Jump statements should not be redundant. (Code Smell)
Here are examples of these rules in action:
- S1763: All code should be reachable
- S1751: A loop with at most one iteration is equivalent to the use of an if statement to conditionally execute one piece of code.
- S3626: Jump statements, such as return, break and continue let you change the default flow of program execution, but jump statements that direct the control flow to the original direction are just a waste of keystrokes.
To make issues easy to understand, we enabled what we are calling Symbol Highlighting. Each time you click on a variable, all the use of this variable are highlighted. This feature was missing for Python and will help to investigate issues.
In this example, I clicked on
args and all the use of
args in the function
transform are highlighted with a blue background:
For more information you can read the changelog.
You can already enjoy these new features on SonarCloud. As for SonarQube, this will be built-in the next version (8.1), and meanwhile you can get it by installing v1.17 of the Python analysis engine.
All feedback is welcome.