Low commit activity in last 3 years
No release in over a year
Lint and syntax validation for onceover
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.4
~> 13.0
~> 3.12

Runtime

 Project Readme

Onceover::CodeQuality

This is the Code Quality plugin for Onceover, The gateway drug to automated infrastructure testing with Puppet

What does it do?

The plugin checks your control repository for:

  • Linting
  • Syntax

And then generates documentation using Puppet Strings

For sure you can hack around with rake/make and hack something up each time but aint nobody got time for that!

Installation

Install the onceover-codequality gem by adding it to your Gemfile or by running the following command:

$ gem install onceover-codequality

Usage

Installing the codequality gem creates a new item within onceover's run command: codequality. See onceover run codequality --help for all available options.

The command will return 1 to the system if any tests fail, otherwise 0, which makes it perfect to include in build pipelines.

Check all code in the control repository for Lint and Syntax errors

$ onceover run codequality

Skip Lint check

$onceover run codequality --no_lint

Skip Puppet syntax check

$ onceover run codequality --no_syntax

Skip Puppetfile syntax check

$ onceover run codequality --no_puppetfile

Skip documentation generation

$ onceover run codequality --no_docs

Use custom lint settings Create a file puppet-lint.rc in the directory you run onceover codequality from and it will be automatically used by Puppet Lint. If missing, the built-in defaults from lib/onceover/codequality/lint.rb will be used.

Sample output

All clear

$ onceover run codequality
INFO   -> Checking for lint...
INFO   -> checking manifests
INFO   -> checking site/role
INFO   -> Checking syntax...
---> syntax:manifests
---> syntax:templates
---> syntax:hiera:yaml
INFO   -> Code Quality tests passed, have a nice day

Lint and syntax errors

$ onceover run codequality
INFO   -> Checking for lint...
INFO   -> checking manifests
INFO   -> checking site/role
./manifests/example.pp - WARNING: class not documented on line 1
./manifests/webserver.pp - WARNING: class not documented on line 1
./manifests/database_server.pp - WARNING: class not documented on line 1
ERROR  -> Lint test failed, see previous errors
INFO   -> Checking syntax...
---> syntax:manifests
Could not parse for environment *root*: Syntax error at 'ensure' at /home/geoff/crud/control-repo/manifests/bogus.pp:2:3
ERROR  -> Syntax test failed, see previous errors
ERROR  -> Code Quality tests failed, see previous error
$ echo $?
1

FAQ

WARN: Unresolved specs during Gem::Specification.reset?

I get these errors when I run onceover run codequality but everything seems to work, what gives?:

WARN: Unresolved specs during Gem::Specification.reset:
      rake (>= 0)
      hiera (< 4, >= 2.0)
      gettext (>= 3.0.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.

Beats me - something to do with rubygems. The best way to beat this message is to use bundler which basically you should already be doing anyway (for your own sanity):

$ bundle exec onceover run codequality

What are you using under-the-hood?

Development

Writing your own onceover plugins

Have a look at helloworld plugin if you want to have a go at writing a plugin of your own.

How to run tests

bundle exec rake spec

How to build gem

gem build onceover-codequality.gemspec

How to upload to rubygems.org

gem push XXX.gem

Contributing