Static code analysis is the process of detecting flaws in software source code. The static analysis tools are useful to detect common coding mistakes; here are some benefits from using them:
- Make the code source more readable and maintainable.
- Prevent unexpected behavior at runtime.
- Optimize the execution.
- Make the code more secure.
In the Python world PyLint is the most popular tool to detect the issues in your python code base. Several ways exist to explore the result of PyLint
• Text format: Text files could be generated from PyLint, and it can be used to create a customized text report or used by another tool to explore the analysis result.
• HTML format: HTML report is a very suitable way to present the PyLint issues; it can be stored in a server and shared by the team.
• IDE Plugins: Many PyLint plugins exist to explore the issues from the IDE ( VsCode, PyCharm,…).
Let’s discover another way to explore and uses PyLint issues. It’s by using the Scanyp tool which is free for students and OSS contributors. For that let’s analyze the TensorFlow library with Scanyp.
1) Query the issues with CQlinq
CQLinq permits us to query issues like a database. For example, you can get all the PyLint issues:

Or get the most recurrent issues:

Bad indentation issues are the most reported by PyLint. However, having thousands of issues is not interesting for developers. Sometimes, it’s preferable to ignore not priority issues like the bad indentation one.
Moreover, it’s interesting also to identify the classes having most issues:

The previous query is interesting, but it does not give us exactly the classes with lack of quality, another useful metric to take into account is the NBLinesOfCode. We can modify the previous request to calculate the ratio between the Issues count and the NBLinesofCode.

We can also search for the most used methods having issues. Bugs in such methods must have a high priority to resolve.

2) Generate Issues Trend
Having issues in a project is not an exception; any project could have many problems to resolve. However, we have to check the quality trend of the project. Indeed it’s a bad indicator if the number of issues grows after changes and evolution. Scanyp provides the Trend Monitoring feature to create trend charts.
Trend charts are made of trend metrics values logged over time at analysis time. More than 50 trend metrics are available per default and it is easy to create your own trend metrics.
With this trend chart we can monitor the evolution of the PyLint issues:

3- Generate custom HTML report
Scanyp makes possible appending extra report sections in the HTML report that lists some CQLinq queries.
In the CQLinq Query Explorer panel, a particular CQLinq reported group is bordered with an orange rectangle.

And in the HTML report these added sections are accessible from the menu:

4- Integrate PyLint into the build process
A Quality Gate is a check on a code quality fact that must be enforced before releasing and eventually, before committing to source control. A Quality Gate can be seen as a PASS/FAIL criterion for software quality.
Quality Gates can be used to fail the build when certain criteria are not-verified.
Quality Gate is a LINQ Query that can be easily created, edited, and customized. For example, if you wish to enforce a certain amount of code coverage through a Quality Gate, you can just write:

A dozen default Quality Gates are proposed by Scanyp related to measures like technical debt amount, code coverage or amount of issues with particular severity.
At Build Process time, when a quality gate fail the process Scanyp.Console.exe returns a non-zero exit code. This behavior can be used to break the Build Process if a critical rule is violated.
Summary
Scanyp is open to other static analysis tools, and you can also plug your customized tool easily. This way you can use all the Scanyp features to explore better the result from the known python static analysis tools.