Code Analysis

Run static code analysis.

Run Analysis on a Single File

Static code analyzer (Pylint) can identify errors, warnings or code that can be refactored without running the python file.

  1. Open a Python file.
  2. Click the Run Linter button to start the analysis.
    If prompted, click OK to save the file. Code analysis runs only in saved files.
    Figure 1. Run Linter Button
    Run analysis on single file

Run Analysis on a All Files

Run an analysis on all Python files in a folder.

  1. Click the Run Linter on all files in folder button to start the analysis.
    Figure 2. Run Linter on All Files in Folder Button
    Run analysis on single file
  2. Select a folder that contains Python files.

Code Analysis Browser

The results of the analysis are displayed in the Code Analysis Browser.

Figure 3. Code Analysis Browser

Code Analysis Browser
Each line represents a potential issue in the code and contains the following details:
Column Name Description
Type Category of issue
Code Issue code
Line# Line where the issue occurred
Column# (initially hidden) Column where the issue occurred
Message Short description of the issue
File Relative path of the file that was analyzed
Language (initially hidden) Coding language (Python is the only language currently supported)

The types of reported issues are:

Icon Type Name Description
Fatal Serious problems that prevent Pylint from analyzing the file.
Error Issues that are very likely to result in runtime failures.
Warning Potential problems that may not break the code but could lead to bugs or unintended behavior.
Convention Violations of coding standards and style guidelines.
Refactor Suggested improvements to the code structure to enhance readability, maintainability, or efficiency.
Info Additional informational messages that highlight useful details but do not necessarily indicate a problem.

Select or deselect the icons on the left side of the browser to show or hide categories of issues to display in the Code Analysis Browser.

Double-click on a row in the browser to navigate to the file and line that the reported issue occurred.

Linter Configuration Dialog

The Linter Configuration dialog displays all available issues that Pylint can report.

Figure 4. Linter Configuration Dialog

Linter Configuration dialog

Hover over a message to see a detailed description of the issue.

You can deselect messages that you want to hide in the Code Analysis browser. This selection of messages is saved for future sessions.

Note: Warning W0311 ("Bad indentation") is reported if the indentation in a file is not the same as the indentation set under Preferences (File > Preferences > Compose > PYTHON > Editor > Tabs). To change the indentation of the whole file at once and fix the warnings, select the Tools > Advanced > Tab to Space or Space to Tab options.