Page MenuHomePhabricator

Created ArcanistPuppetLinter
Needs RevisionPublic

Authored by Pawka on Mar 16 2015, 2:43 PM.
Referenced Files
Unknown Object (File)
Wed, Nov 20, 3:20 AM
Unknown Object (File)
Sat, Nov 16, 7:46 AM
Unknown Object (File)
Thu, Nov 14, 10:08 PM
Unknown Object (File)
Mon, Nov 11, 7:47 PM
Unknown Object (File)
Fri, Nov 8, 5:46 PM
Unknown Object (File)
Fri, Nov 8, 4:56 PM
Unknown Object (File)
Fri, Nov 8, 4:31 PM
Unknown Object (File)
Thu, Nov 7, 6:58 PM

Details

Summary

Run puppet parser validate on *.pp files.

Test Plan

Add following code to your .arclint linters section:

"puppet": {
  "type": "puppet",
  "include": "(\\.pp$)"
}

Create puppet (*.pp) file with syntax error and run arc lint on it. Expect error.

Diff Detail

Repository
rARC Arcanist
Branch
puppet_linter
Lint
Lint Passed
Unit
Test Failures
Build Status
Buildable 4902
Build 4920: [Placeholder Plan] Wait for 30 Seconds

Unit TestsFailed

TimeTest
910 msArcanistFlake8LinterTestCase::testLinter
211 msArcanistChmodLinterTestCase::testLinter
119 msArcanistClosureLinterTestCase::testVersion
204 msArcanistCommitLinterTestCase::testLinter
120 msArcanistCpplintLinterTestCase::testVersion
View Full Test Results (1 Failed · 35 Passed · 20 Skipped)

Event Timeline

Pawka retitled this revision from to Created ArcanistPuppetLinter.
Pawka updated this object.
Pawka edited the test plan for this revision. (Show Details)

To clarify, this is a completely different linter than the existing PuppetLintLinter? Why are there two different Puppet linters -- aren't puppet files basically configuration files? What advantages does this linter have over puppet-lint?

puppet-lint is a third party tool which aims to check that Puppet code adheres to the official style guide. pupppet parser validate is more of a syntax check. Because it is a built-in tool, you can use it to check against specific versions, whereas puppet-lint aims to be version-agnostic.

Yes, @joshuaspence mentioned everything what was needed. Actually we are using both because each of them catching different errors.

joshuaspence edited edge metadata.
joshuaspence added inline comments.
src/lint/linter/ArcanistPuppetLinter.php
4

Change this to Runs `puppet parser validate` for Puppet files..

11

I think that Puppet is a more reasonable name for this linter.

20

Missing space after "or"

22

This isn't correct, there is no %s in the string.

54

Prefer to write this as pht('Install puppet using `%s` or similar.', 'apt-get install puppet')

59

Kill this blank line.

77

Prefer to use getLintMessageSeverity so that the severity is configurable.

79

This should be translatable, so pht('Puppet Error'). Also, perhaps "Puppet Parser Error" would be more clear.

This revision now requires changes to proceed.May 5 2015, 8:50 AM
Pawka edited edge metadata.

Updated code regarding comments.

joshuaspence edited edge metadata.

Some minor inlines, otherwise looks good.

src/lint/linter/ArcanistPuppetLinter.php
9

Unused variable, just remove this.

54

The first argument should be on a newline.

59

Kill this blank line.

69

Try to be a bit more restrictive with the regular expression... I think /^Error: (.*)at (.*):(\d+)$/ would be better.

77–78

Not quite, the argument should be the linter code, so $this->getLintMessageSeverity($this->getLinterName())

Some minor inlines, otherwise looks good.

Pawka edited edge metadata.

Few more updates.

src/lint/linter/ArcanistPuppetLinter.php
69

Puppet output is with color codes. Code will look more complex if I'll try cleaning them. In other case puppet parser validate always returns only the first error.

src/lint/linter/ArcanistPuppetLinter.php
69

Ah OK. In that case, you should add --color false to the command to disable colored output.

Updated error matching regexp.

LGTM. FWIW, I'm looking forward to this change.

Does this require any input from me (as I can not land the diff)?
/cc @epriestley

epriestley edited edge metadata.

The handling of codes and severities is not correct, and means that severity and severity.rules will not be respected in .arclint. See discussion in D12034 for a specific example and how to resolve this issue. See D11657 for general discussion.

src/lint/linter/ArcanistPuppetLinter.php
75–76

This is not correct, see discussion.

This revision now requires changes to proceed.May 19 2015, 3:16 PM