mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12117)
* Apply fixes from StyleCI * Disable style check
This commit is contained in:
@@ -205,13 +205,18 @@ class CiHelper
|
||||
*/
|
||||
public function checkStyle()
|
||||
{
|
||||
|
||||
// Disabled in favor of styleci
|
||||
echo "Style check disabled.\n";
|
||||
return 0;
|
||||
|
||||
$cs_cmd = [
|
||||
$this->checkPhpExec('phpcs'),
|
||||
'-n',
|
||||
'-p',
|
||||
'--colors',
|
||||
'--extensions=php',
|
||||
'--standard=misc/phpcs_librenms.xml'
|
||||
'--standard=misc/phpcs_librenms.xml',
|
||||
];
|
||||
|
||||
$files = $this->flags['full'] ? ['./'] : $this->changed['php'];
|
||||
@@ -222,8 +227,9 @@ class CiHelper
|
||||
|
||||
public function checkWeb()
|
||||
{
|
||||
if (!$this->flags['ci']) {
|
||||
if (! $this->flags['ci']) {
|
||||
echo "Warning: dusk may erase your primary database, do not use yet\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -262,7 +268,7 @@ class CiHelper
|
||||
public function checkLint()
|
||||
{
|
||||
$return = 0;
|
||||
if (!$this->flags['lint_skip_php']) {
|
||||
if (! $this->flags['lint_skip_php']) {
|
||||
$php_lint_cmd = [$this->checkPhpExec('parallel-lint')];
|
||||
|
||||
// matches a substring of the relative path, leading / is treated as absolute path
|
||||
@@ -274,7 +280,7 @@ class CiHelper
|
||||
$return += $this->execute('PHP lint', $php_lint_cmd);
|
||||
}
|
||||
|
||||
if (!$this->flags['lint_skip_python']) {
|
||||
if (! $this->flags['lint_skip_python']) {
|
||||
$py_lint_cmd = [$this->checkPythonExec('pylint'), '-E', '-j', '0'];
|
||||
|
||||
$files = $this->flags['full']
|
||||
@@ -285,7 +291,7 @@ class CiHelper
|
||||
$return += $this->execute('Python lint', $py_lint_cmd);
|
||||
}
|
||||
|
||||
if (!$this->flags['lint_skip_bash']) {
|
||||
if (! $this->flags['lint_skip_bash']) {
|
||||
$files = $this->flags['full']
|
||||
? explode(PHP_EOL, rtrim(shell_exec("find . -name '*.sh' -not -path './node_modules/*' -not -path './vendor/*'")))
|
||||
: $this->changed['bash'];
|
||||
@@ -309,12 +315,14 @@ class CiHelper
|
||||
if ($method = $this->canCheck($type)) {
|
||||
$ret = $this->$method();
|
||||
$this->completedChecks[$type] = true;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
if ($this->flags["{$type}_enable"] && $this->flags["{$type}_skip"]) {
|
||||
echo ucfirst($type) . " check skipped.\n";
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -357,10 +365,11 @@ class CiHelper
|
||||
}
|
||||
|
||||
echo $prefix . $proc->getCommandLine() . PHP_EOL;
|
||||
|
||||
return 250;
|
||||
}
|
||||
|
||||
if (!$silence) {
|
||||
if (! $silence) {
|
||||
echo "Running $name check... ";
|
||||
}
|
||||
|
||||
@@ -369,7 +378,7 @@ class CiHelper
|
||||
$quiet = ($this->flags['ci'] && isset($this->ciDefaults['quiet'][$type])) ? $this->ciDefaults['quiet'][$type] : $this->flags['quiet'];
|
||||
|
||||
$proc->setTimeout(3600)->setIdleTimeout(3600);
|
||||
if (!($silence || $quiet)) {
|
||||
if (! ($silence || $quiet)) {
|
||||
echo PHP_EOL;
|
||||
$proc->setTty(Process::isTtySupported());
|
||||
}
|
||||
@@ -378,21 +387,20 @@ class CiHelper
|
||||
|
||||
$duration = sprintf('%.2fs', microtime(true) - $start);
|
||||
if ($proc->getExitCode() > 0) {
|
||||
if (!$silence) {
|
||||
if (! $silence) {
|
||||
echo "failed ($duration)\n";
|
||||
}
|
||||
if ($quiet || $silence) {
|
||||
echo $proc->getOutput() . PHP_EOL;
|
||||
echo $proc->getErrorOutput() . PHP_EOL;
|
||||
}
|
||||
} elseif (!$silence) {
|
||||
} elseif (! $silence) {
|
||||
echo "success ($duration)\n";
|
||||
}
|
||||
|
||||
return $proc->getExitCode();
|
||||
}
|
||||
|
||||
|
||||
public function checkEnvSkips()
|
||||
{
|
||||
$this->flags['unit_skip'] = $this->flags['unit_skip'] || getenv('SKIP_UNIT_CHECK');
|
||||
@@ -415,8 +423,9 @@ class CiHelper
|
||||
|
||||
private function parseChangedFiles()
|
||||
{
|
||||
if ($this->flags['full'] || !empty($this->changed['full-checks'])) {
|
||||
if ($this->flags['full'] || ! empty($this->changed['full-checks'])) {
|
||||
$this->flags['full'] = true; // make sure full is set and skip changed file parsing
|
||||
|
||||
return;
|
||||
}
|
||||
$this->os = $this->os ?: $this->changed['os'];
|
||||
@@ -425,14 +434,14 @@ class CiHelper
|
||||
'lint_skip_php' => empty($this->changed['php']),
|
||||
'lint_skip_python' => empty($this->changed['python']),
|
||||
'lint_skip_bash' => empty($this->changed['bash']),
|
||||
'unit_os' => $this->getFlag('unit_os') || (!empty($this->changed['os']) && empty(array_diff($this->changed['php'], $this->changed['os-files']))),
|
||||
'unit_docs' => !empty($this->changed['docs']) && empty($this->changed['php']),
|
||||
'unit_svg' => !empty($this->changed['svg']) && empty($this->changed['php']),
|
||||
'docs_changed' => !empty($this->changed['docs']),
|
||||
'unit_os' => $this->getFlag('unit_os') || (! empty($this->changed['os']) && empty(array_diff($this->changed['php'], $this->changed['os-files']))),
|
||||
'unit_docs' => ! empty($this->changed['docs']) && empty($this->changed['php']),
|
||||
'unit_svg' => ! empty($this->changed['svg']) && empty($this->changed['php']),
|
||||
'docs_changed' => ! empty($this->changed['docs']),
|
||||
]);
|
||||
|
||||
$this->setFlags([
|
||||
'unit_skip' => empty($this->changed['php']) && !array_sum(Arr::only($this->getFlags(), ['unit_os', 'unit_docs', 'unit_svg', 'unit_modules', 'docs_changed'])),
|
||||
'unit_skip' => empty($this->changed['php']) && ! array_sum(Arr::only($this->getFlags(), ['unit_os', 'unit_docs', 'unit_svg', 'unit_modules', 'docs_changed'])),
|
||||
'lint_skip' => array_sum(Arr::only($this->getFlags(), ['lint_skip_php', 'lint_skip_python', 'lint_skip_bash'])) === 3,
|
||||
'style_skip' => empty($this->changed['php']),
|
||||
'web_skip' => empty($this->changed['php']) && empty($this->changed['resources']),
|
||||
|
Reference in New Issue
Block a user