mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
committed by
Neil Lathwood
parent
a9e31dca0e
commit
8c94ccf4d6
16
misc/phpcs_librenms.xml
Normal file
16
misc/phpcs_librenms.xml
Normal 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>
|
@ -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;
|
||||
|
Reference in New Issue
Block a user