-
Notifications
You must be signed in to change notification settings - Fork 779
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This uses a relaxed rule set for now, which does not enforce a strict number of indentation spaces but instead check the file is consistently indented. The maximum line lenght rule is also disabled to accomodate the scripts in the gitian descriptors. Test Plan: Should return no error: arc lint --everything Revert the changes to the .travis.yml from this diff then run: arc lint and check the indentation errors are catched by the linter. Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7358
- Loading branch information
Showing
8 changed files
with
110 additions
and
14 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,7 @@ | ||
--- | ||
extends: relaxed | ||
|
||
rules: | ||
# Some YML files embed a script portion, for which the line length rule would | ||
# decrease the readability. | ||
line-length: disable |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,82 @@ | ||
<?php | ||
|
||
/** | ||
* Uses the yamllint tool to lint the YAML files. | ||
*/ | ||
final class YamllintLinter extends ArcanistExternalLinter { | ||
|
||
const YAMLLINT_SEVERITY_MAP = array( | ||
'warning' => ArcanistLintSeverity::SEVERITY_WARNING, | ||
'error' => ArcanistLintSeverity::SEVERITY_ERROR, | ||
); | ||
|
||
public function getInfoName() { | ||
return 'yamllint'; | ||
} | ||
|
||
public function getInfoDescription() { | ||
return pht('Use yamllint for linting YAML files.'); | ||
} | ||
|
||
public function getLinterName() { | ||
return 'YAMLLINT'; | ||
} | ||
|
||
public function getLinterConfigurationName() { | ||
return 'yamllint'; | ||
} | ||
|
||
public function getDefaultBinary() { | ||
return 'yamllint'; | ||
} | ||
|
||
public function getInstallInstructions() { | ||
return pht('Please install yamllint and make sure it is in your $PATH'); | ||
} | ||
|
||
public function shouldExpectCommandErrors() { | ||
return true; | ||
} | ||
|
||
public function getVersion() { | ||
list($stdout) = execx('%C --version', $this->getExecutableCommand()); | ||
|
||
$regex = '/^yamllint (?P<version>\d+\.\d+\.\d+)/m'; | ||
if (preg_match($regex, $stdout, $matches)) { | ||
return $matches['version']; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private function getSeverity($severity) { | ||
if (array_key_exists($severity, self::YAMLLINT_SEVERITY_MAP)) { | ||
return self::YAMLLINT_SEVERITY_MAP[$severity]; | ||
} | ||
|
||
return ArcanistLintSeverity::SEVERITY_ERROR; | ||
} | ||
|
||
protected function parseLinterOutput($path, $err, $stdout, $stderr) { | ||
$messages = array(); | ||
|
||
$pattern = '/(\d+):(\d+)\s+(\w+)\s+(.+) \((.+)\)/'; | ||
if (preg_match_all($pattern, $stdout, $errors, PREG_SET_ORDER)) { | ||
foreach ($errors as $error) { | ||
list(, $line, $char, $severity, $message, $category) = $error; | ||
|
||
$messages[] = id(new ArcanistLintMessage()) | ||
->setGranularity(ArcanistLinter::GRANULARITY_FILE) | ||
->setPath($path) | ||
->setLine(intval($line)) | ||
->setChar(intval($char)) | ||
->setCode($category) | ||
->setSeverity($this->getSeverity($severity)) | ||
->setName('yamllint found an issue:') | ||
->setDescription($message); | ||
} | ||
} | ||
|
||
return $messages; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -66,6 +66,7 @@ PACKAGES=( | |
software-properties-common | ||
tar | ||
wget | ||
yamllint | ||
wine | ||
) | ||
|
||
|
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