-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
db8a2de
commit ee34cdc
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from coalib.bearlib.abstractions.Linter import linter | ||
from coalib.bears.requirements.GemRequirement import GemRequirement | ||
|
||
|
||
@linter(executable='puppet-lint', | ||
output_format='regex', | ||
output_regex=r'(?P<line>\d+):(?P<column>\d+):' | ||
r'(?P<severity>warning|error):(?P<message>.+)') | ||
class PuppetLintBear: | ||
''' | ||
Check and correct puppet configuration files using ``puppet-lint``. | ||
See <http://puppet-lint.com/> for details about the tool. | ||
''' | ||
|
||
LANGUAGES = {"Puppet"} | ||
REQUIREMENTS = {GemRequirement('puppet-lint', '2')} | ||
AUTHORS = {'The coala developers'} | ||
AUTHORS_EMAILS = {'[email protected]'} | ||
LICENSE = 'AGPL-3.0' | ||
CAN_FIX = {'Syntax'} | ||
|
||
@staticmethod | ||
def create_arguments(filename, file, config_file): | ||
return ('--log-format', "%{line}:%{column}:%{kind}:%{message}", | ||
filename) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from bears.configfiles.PuppetLintBear import PuppetLintBear | ||
from tests.LocalBearTestHelper import verify_local_bear | ||
|
||
good_file = """ | ||
file { '/some.conf': | ||
ensure => present, | ||
} | ||
""" | ||
|
||
bad_file = """ | ||
# foo | ||
class test::foo { } | ||
""" | ||
|
||
PuppetLintBearTest = verify_local_bear(PuppetLintBear, | ||
valid_files=(good_file,), | ||
invalid_files=(bad_file,)) |