refactor: Use custom phpcs ruleset for LibreNMS (#8418)

* Use custom phpcs ruleset for LibreNMS
PSR2 with exclusions

* Don't check line length

* Restore build_excludes()
Drop influxdb lib exclusion

* Fix whitespace
This commit is contained in:
Tony Murray 2018-03-20 06:32:52 -05:00 committed by Neil Lathwood
parent a9e31dca0e
commit 8c94ccf4d6
2 changed files with 18 additions and 13 deletions

16
misc/phpcs_librenms.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0"?>
<ruleset name="librenms">
<description>The PSR2 coding standard with LibreNMS exceptions.</description>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/storage/*</exclude-pattern>
<exclude-pattern>/lib/*</exclude-pattern>
<exclude-pattern>/html/plugins/*</exclude-pattern>
<exclude-pattern>/config.php</exclude-pattern>
<rule ref="PSR2" >
<exclude name="Generic.Files.LineLength"/>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>/database/seeds/*</exclude-pattern>
<exclude-pattern>/database/migrations/*</exclude-pattern>
</rule>
</ruleset>

View File

@ -145,9 +145,7 @@ function check_lint($passthru = false, $command_only = false)
// matches a substring of the relative path, leading / is treated as absolute path
$lint_excludes = array('vendor/');
if (defined('HHVM_VERSION') || version_compare(PHP_VERSION, '5.6', '<')) {
$lint_excludes[] = 'lib/influxdb-php/';
}
$lint_exclude = build_excludes('--exclude ', $lint_excludes);
$lint_cmd = "$parallel_lint_bin $lint_exclude ./";
@ -186,16 +184,7 @@ function check_style($passthru = false, $command_only = false)
{
$phpcs_bin = check_exec('phpcs');
// matches a substring of the full path
$cs_excludes = array(
'/vendor/',
'/lib/',
'/html/plugins/',
'/config.php',
);
$cs_exclude = build_excludes('--ignore=', $cs_excludes);
$cs_cmd = "$phpcs_bin -n -p --colors --extensions=php --standard=PSR2 $cs_exclude ./";
$cs_cmd = "$phpcs_bin -n -p --colors --extensions=php --standard=misc/phpcs_librenms.xml ./";
if ($command_only) {
echo $cs_cmd . PHP_EOL;