Changeset View
Changeset View
Standalone View
Standalone View
arcanist/linter/ShellCheckLinter.php
<?php | <?php | ||||
/** | /** | ||||
* Uses the ShellCheck tool to run static analysis on shell scripts | * Uses the ShellCheck tool to run static analysis on shell scripts | ||||
*/ | */ | ||||
final class ShellCheckLinter extends ArcanistExternalLinter { | final class ShellCheckLinter extends ArcanistExternalLinter { | ||||
const SHELLCHECK_EXCLUDED_RULES = array( | const SHELLCHECK_EXCLUDED_RULES = array( | ||||
// phpcs:disable Generic.Files.LineLength.TooLong | // phpcs:disable Generic.Files.LineLength.TooLong | ||||
// phpcs:disable Generic.Files.LineLength.MaxExceeded | // phpcs:disable Generic.Files.LineLength.MaxExceeded | ||||
'SC2001', // See if you can use ${variable//search/replace} instead. | 'SC1117', // Backslash is literal in "\.". Prefer explicit escaping: "\\.". | ||||
'SC2004', // $/${} is unnecessary on arithmetic variables. | |||||
'SC2005', // Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. | |||||
'SC2006', // Use $(..) instead of legacy `..`. | |||||
'SC2016', // Expressions don't expand in single quotes, use double quotes for that. | |||||
'SC2028', // echo won't expand escape sequences. Consider printf. | |||||
'SC2046', // Quote this to prevent word splitting. | 'SC2046', // Quote this to prevent word splitting. | ||||
'SC2048', // Use "$@" (with quotes) to prevent whitespace problems. | |||||
'SC2066', // Since you double quoted this, it will not word split, and the loop will only run once. | |||||
'SC2086', // Double quote to prevent globbing and word splitting. | 'SC2086', // Double quote to prevent globbing and word splitting. | ||||
'SC2116', // Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'. | |||||
'SC2148', // Tips depend on target shell and yours is unknown. Add a shebang. | |||||
'SC2162', // read without -r will mangle backslashes. | 'SC2162', // read without -r will mangle backslashes. | ||||
'SC2166', // Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. | |||||
'SC2166', // Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. | |||||
'SC2181', // Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. | |||||
// phpcs:enable | // phpcs:enable | ||||
); | ); | ||||
const SHELLCHECK_SEVERITY_MAP = array( | const SHELLCHECK_SEVERITY_MAP = array( | ||||
'note' => ArcanistLintSeverity::SEVERITY_ADVICE, | 'note' => ArcanistLintSeverity::SEVERITY_ADVICE, | ||||
'warning' => ArcanistLintSeverity::SEVERITY_WARNING, | 'warning' => ArcanistLintSeverity::SEVERITY_WARNING, | ||||
'error' => ArcanistLintSeverity::SEVERITY_ERROR, | 'error' => ArcanistLintSeverity::SEVERITY_ERROR, | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |