Skip to content

Commit ee34cdc

Browse files
committed
bears.configfile: Add new bear - PuppetLintBear
The PuppetLintBear runs the `puppet-lint` utility on files give by coala and gives results based on this. Closes #46
1 parent db8a2de commit ee34cdc

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ gem "rubocop"
55
gem "sqlint"
66
gem 'scss_lint', require: false# require flag is necessary https://github.com/brigade/scss-lint#installation
77
gem "reek"
8+
gem "puppet-lint"

bears/configfiles/PuppetLintBear.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from coalib.bearlib.abstractions.Linter import linter
2+
from coalib.bears.requirements.GemRequirement import GemRequirement
3+
4+
5+
@linter(executable='puppet-lint',
6+
output_format='regex',
7+
output_regex=r'(?P<line>\d+):(?P<column>\d+):'
8+
r'(?P<severity>warning|error):(?P<message>.+)')
9+
class PuppetLintBear:
10+
'''
11+
Check and correct puppet configuration files using ``puppet-lint``.
12+
13+
See <http://puppet-lint.com/> for details about the tool.
14+
'''
15+
16+
LANGUAGES = {"Puppet"}
17+
REQUIREMENTS = {GemRequirement('puppet-lint', '2')}
18+
AUTHORS = {'The coala developers'}
19+
AUTHORS_EMAILS = {'coala-devel@googlegroups.com'}
20+
LICENSE = 'AGPL-3.0'
21+
CAN_FIX = {'Syntax'}
22+
23+
@staticmethod
24+
def create_arguments(filename, file, config_file):
25+
return ('--log-format', "%{line}:%{column}:%{kind}:%{message}",
26+
filename)
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from bears.configfiles.PuppetLintBear import PuppetLintBear
2+
from tests.LocalBearTestHelper import verify_local_bear
3+
4+
good_file = """
5+
file { '/some.conf':
6+
ensure => present,
7+
}
8+
"""
9+
10+
bad_file = """
11+
# foo
12+
class test::foo { }
13+
"""
14+
15+
PuppetLintBearTest = verify_local_bear(PuppetLintBear,
16+
valid_files=(good_file,),
17+
invalid_files=(bad_file,))

0 commit comments

Comments
 (0)