Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15399218
D12090.id30613.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D12090.id30613.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -153,6 +153,8 @@
'ArcanistPhutilXHPASTLinterTestCase' => 'lint/linter/__tests__/ArcanistPhutilXHPASTLinterTestCase.php',
'ArcanistPuppetLintLinter' => 'lint/linter/ArcanistPuppetLintLinter.php',
'ArcanistPuppetLintLinterTestCase' => 'lint/linter/__tests__/ArcanistPuppetLintLinterTestCase.php',
+ 'ArcanistPuppetLinter' => 'lint/linter/ArcanistPuppetLinter.php',
+ 'ArcanistPuppetLinterTestCase' => 'lint/linter/__tests__/ArcanistPuppetLinterTestCase.php',
'ArcanistPyFlakesLinter' => 'lint/linter/ArcanistPyFlakesLinter.php',
'ArcanistPyFlakesLinterTestCase' => 'lint/linter/__tests__/ArcanistPyFlakesLinterTestCase.php',
'ArcanistPyLintLinter' => 'lint/linter/ArcanistPyLintLinter.php',
@@ -340,6 +342,8 @@
'ArcanistPhutilXHPASTLinterTestCase' => 'ArcanistLinterTestCase',
'ArcanistPuppetLintLinter' => 'ArcanistExternalLinter',
'ArcanistPuppetLintLinterTestCase' => 'ArcanistExternalLinterTestCase',
+ 'ArcanistPuppetLinter' => 'ArcanistExternalLinter',
+ 'ArcanistPuppetLinterTestCase' => 'ArcanistExternalLinterTestCase',
'ArcanistPyFlakesLinter' => 'ArcanistExternalLinter',
'ArcanistPyFlakesLinterTestCase' => 'ArcanistExternalLinterTestCase',
'ArcanistPyLintLinter' => 'ArcanistLinter',
diff --git a/src/lint/linter/ArcanistPuppetLinter.php b/src/lint/linter/ArcanistPuppetLinter.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/ArcanistPuppetLinter.php
@@ -0,0 +1,83 @@
+<?php
+
+/**
+ * Runs `puppet parser validate` for Puppet files.
+ */
+final class ArcanistPuppetLinter extends ArcanistExternalLinter {
+
+ public function getInfoName() {
+ return 'Puppet';
+ }
+
+ public function getInfoURI() {
+ return 'https://docs.puppetlabs.com/references/';
+ }
+
+ public function getInfoDescription() {
+ return pht(
+ 'Validates Puppet DSL syntax without compiling a catalog or '.
+ 'syncing any resources.');
+ }
+
+ public function getLinterName() {
+ return 'PUPPET';
+ }
+
+ public function getLinterConfigurationName() {
+ return 'puppet';
+ }
+
+ public function getDefaultBinary() {
+ return 'puppet';
+ }
+
+ protected function getMandatoryFlags() {
+ return array('parser', 'validate');
+ }
+
+ public function getVersion() {
+ list($stdout) = execx('%C --version', $this->getExecutableCommand());
+
+ $matches = array();
+ $regex = '/^(?P<version>\d+\.\d+\.\d+)$/';
+ if (preg_match($regex, $stdout, $matches)) {
+ return $matches['version'];
+ } else {
+ return false;
+ }
+ }
+
+ public function getInstallInstructions() {
+ return pht(
+ 'Install puppet using `%s` or similar.',
+ 'apt-get install puppet');
+ }
+
+ protected function parseLinterOutput($path, $err, $stdout, $stderr) {
+ if (!$err) {
+ return array();
+ }
+
+ $lines = phutil_split_lines($stderr, false);
+ $messages = array();
+
+ foreach ($lines as $line) {
+ $matches = null;
+ $regexp = '/Error: (.*)at (.*):(\d+)/';
+ $match = preg_match($regexp, $line, $matches);
+
+ if ($match) {
+ $message = id(new ArcanistLintMessage())
+ ->setDescription($matches[1])
+ ->setLine($matches[3])
+ ->setPath($matches[2])
+ ->setSeverity($this->getLintMessageSeverity($this->getLinterName()))
+ ->setCode($this->getLinterName())
+ ->setName(pht('Puppet Parser Error'));
+ $messages[] = $message;
+ }
+ }
+
+ return $messages;
+ }
+}
diff --git a/src/lint/linter/__tests__/ArcanistPuppetLinterTestCase.php b/src/lint/linter/__tests__/ArcanistPuppetLinterTestCase.php
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/__tests__/ArcanistPuppetLinterTestCase.php
@@ -0,0 +1,10 @@
+<?php
+
+final class ArcanistPuppetLinterTestCase
+ extends ArcanistExternalLinterTestCase {
+
+ public function testLinter() {
+ $this->executeTestsInDirectory(dirname(__FILE__).'/puppet/');
+ }
+
+}
diff --git a/src/lint/linter/__tests__/puppet/site.lint-test b/src/lint/linter/__tests__/puppet/site.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/__tests__/puppet/site.lint-test
@@ -0,0 +1,6 @@
+notice("Some notice")
+
+node default {
+ include something::base
+}
+~~~~~~~~~~
diff --git a/src/lint/linter/__tests__/puppet/syntax-error.lint-test b/src/lint/linter/__tests__/puppet/syntax-error.lint-test
new file mode 100644
--- /dev/null
+++ b/src/lint/linter/__tests__/puppet/syntax-error.lint-test
@@ -0,0 +1,7 @@
+notice("Some notice")
+
+node default {
+ include something::base
+
+~~~~~~~~~~
+error:6:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 18, 3:24 AM (1 d, 2 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7388780
Default Alt Text
D12090.id30613.diff (4 KB)
Attached To
Mode
D12090: Created ArcanistPuppetLinter
Attached
Detach File
Event Timeline
Log In to Comment