iwarapter / sonar-puppet

SonarQube plugin for Puppet code.
Other
26 stars 10 forks source link
puppet sonarqube sonarqube-plugin

SonarQube Puppet Plugin

Build Status Gitter Coverage Status [GitHub release]() [GitHub license]() Technical debt ratio Quality Gate

Description

This plugin enables analysis of Puppet code. It comes with more than 60 rules spanning from style checks (i.e. All arrows in attribute/value list should be aligned) to detection of potential bugs (i.e. Duplicated parameters should be removed). This is currently written to support the grammar for Puppet 3.8, support for the future parser is not currently available.

Requirements

Getting Started in Less Than Two Minutes

To get started in less than two minutes, you can download the package at https://github.com/racodond/package-test-sonarqube-puppet and follow the instructions in the README file.

Getting Started

To run an analysis of your Puppet project, we recommend to use SonarQube Runner. There are two strategies:

  1. Analyze each of your modules separately
  2. Analyze all your modules at once

Analyze each of your modules separately

It means that one SonarQube project is created for each Puppet module. Let's take the Puppet Labs Apache module at https://github.com/puppetlabs/puppetlabs-apache as an example.

Analyze all your modules at once

It means that one single SonarQube project is created for all the Puppet modules.

Which strategy to choose?

The first strategy easily allows you to automate a SonarQube analysis of a module each time a developer pushes some code to the VCS. By providing a quick feedback to developers, you can ensure that quality flaws are quickly fixed.

The second strategy provides a quality overview of your entire Puppet Code Base and how it evolves overtime. Moreover, analyzing your whole code base at once allows you to benefit from more advanced cross-module checks (such as the autoloader layout rule).

We recommend you to apply both strategies to get all the benefits.

Metrics

The Puppet terms do not always match with the standard SonarQube metrics. Here's the list of slight differences:

Extending Coding Rules using XPath

New coding rules can be added using XPath. See the related documentation. To navigate the AST, download the SSLR Puppet Toolkit.