Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 31 Next »


Description / Features

This plugin enables the analysis of Python projects.

Current feature list:

  • Recognition of basic program entities:
    • Python modules
    • Python packages
  • Provides basic size metrics:
    • files (number of)
    • lines
    • lines of comments
    • lines of code
  • Static code checking via pylint (covering as well code style as code defects aspects)
  • Provides cyclomatic complexity metrics including:
    • Complexity per function/method
    • Complexity per module
    • Complexity distributions
  • Recognition of code duplication
  • Basic highlighting mode for Python in Sonar UI


This plugin has following dependencies:

  • For complexity analysis the Python interpreter is needed, anything >=2.5 will do.
  • Pylint is used for the rules compliance analysis.


  1. Copy the jar-archive into <sonar home>/extensions/plugins/ directory
  2. Restart the Sonar web server


Python plugin uses the following properties during analysis. See here for the ways how to pass them to the plugin.







Path to the pylint executable to use in pylint analysis. Set to empty to use the default one.


Path to the pylint configuration file (relative to project root) to use in pylint analysis. Set to empty to use the default.


Comma separated list of paths relative to project root to add to PYTHONPATH when executing pylint.


You can analyze your projects using the usual means (see this page for all available). Just make sure to set a couple of properties. See below how to do it for maven and sonar-runner.

Analyzing with maven

  • Add your source directories to the build and the language-property to the properties section of your pom. Syntax: 

      <sourceDirectory> path </sourceDirectdory>
  • Make sure the dynamic analysis is not switched of. Syntax: 

  • Make sure sonar-server is running
  • Start the analysis with "mvn sonar:sonar"

See here for general information about analyzing via maven.

Analyzing with sonar-runner

  • Add a to the root directory of your project
  • Set sonar.language to py. Syntax:


  • Make sure your sonar-server is running
  • run sonar-runner in the directory containing the

See here for general information about analyzing via sonar-runner.

Sample Project

... is available here.



Version 0.1 (5 issues)


  • No labels