From 8c94ccf4d6be351575f3f85eb7f20a7286b2e1a2 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 20 Mar 2018 06:32:52 -0500 Subject: [PATCH] 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 --- misc/phpcs_librenms.xml | 16 ++++++++++++++++ scripts/pre-commit.php | 15 ++------------- 2 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 misc/phpcs_librenms.xml diff --git a/misc/phpcs_librenms.xml b/misc/phpcs_librenms.xml new file mode 100644 index 0000000000..44b3cc27c0 --- /dev/null +++ b/misc/phpcs_librenms.xml @@ -0,0 +1,16 @@ + + + The PSR2 coding standard with LibreNMS exceptions. + /vendor/* + /storage/* + /lib/* + /html/plugins/* + /config.php + + + + + /database/seeds/* + /database/migrations/* + + diff --git a/scripts/pre-commit.php b/scripts/pre-commit.php index fb54d295cc..cb56e03447 100755 --- a/scripts/pre-commit.php +++ b/scripts/pre-commit.php @@ -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;