From 3412fdfac19fadbb6eabca4c53ee0651d6c0684d Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Sun, 17 Sep 2017 09:25:13 +0200 Subject: [PATCH 1/8] Enable PHP CodeSniffer in travis testing --- .travis.yml | 3 +-- phpcs.xml | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 phpcs.xml diff --git a/.travis.yml b/.travis.yml index cb5087ec8..cdb7055fe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,6 +42,5 @@ before_script: script: # also see: modules/test/application/clicommands/PhpCommand.php - # phpcs is disabled until fixed... - # - php phpcs.phar -p --standard=icingaweb2.ruleset.xml --extensions=php --encoding=utf-8 application/ library/Icinga modules/ test/ + - php phpcs.phar - php phpunit.phar -c modules/test/phpunit.xml --verbose diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 000000000..e04ad72f8 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,23 @@ + + + Sniff our code a while + + application/ + library/Icinga + modules/ + test/ + + vendor/* + application/fonts/fontello-ifont/* + + + + + + + + + + + + From cf4c83011f906887d6b165e5b5b5ec4d5539bd50 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 19 Sep 2017 14:39:56 +0200 Subject: [PATCH 2/8] travis: Update phpcs to 3.0.2 And install phpcbf --- test/setup_vendor.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/setup_vendor.sh b/test/setup_vendor.sh index 17ef47533..663db8000 100755 --- a/test/setup_vendor.sh +++ b/test/setup_vendor.sh @@ -4,7 +4,7 @@ set -ex ICINGAWEB_HOME=${ICINGAWEB_HOME:="$(dirname "$(readlink -f $(dirname "$0"))")"} PHP_VERSION="$(php -r 'echo phpversion();')" -PHPCS_VERSION=${PHPCS_VERSION:=2.9.1} +PHPCS_VERSION=${PHPCS_VERSION:=3.0.2} MOCKERY_VERSION=${MOCKERY_VERSION:=0.9.9} HAMCREST_VERSION=${HAMCREST_VERSION:=2.0.0} @@ -32,6 +32,12 @@ if [ ! -e "${phpcs_path}".phar ]; then https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcs.phar fi ln -svf "${phpcs_path}".phar phpcs.phar +phpcbf_path="vendor/phpcbf-${PHPCS_VERSION}" +if [ ! -e "${phpcbf_path}".phar ]; then + wget -O "${phpcbf_path}".phar \ + https://github.com/squizlabs/PHP_CodeSniffer/releases/download/${PHPCS_VERSION}/phpcbf.phar +fi +ln -svf "${phpcbf_path}".phar phpcbf.phar # mockery mockery_path="vendor/mockery-${MOCKERY_VERSION}" From 4bffcf1ba5c094c4362c6adb75868066149e3d7e Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 19 Sep 2017 14:43:09 +0200 Subject: [PATCH 3/8] style: Update icingaweb2.ruleset.xml So allow common style in our code base. --- icingaweb2.ruleset.xml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/icingaweb2.ruleset.xml b/icingaweb2.ruleset.xml index 020f26c26..6e1b31e4e 100644 --- a/icingaweb2.ruleset.xml +++ b/icingaweb2.ruleset.xml @@ -3,8 +3,27 @@ The default PSR-2 standard with specifically excluded non-critical sniffs - + + + 0 + + + 0 + + + 0 + + + library/Icinga/Application/Cli.php + library/Icinga/Application/EmbeddedWeb.php + library/Icinga/Application/functions.php + library/Icinga/Application/LegacyWeb.php + library/Icinga/Application/Web.php + library/Icinga/File/Pdf.php + modules/doc/library/Doc/Renderer/DocSectionRenderer.php + modules/monitoring/library/Monitoring/Plugin.php + */test/php/* @@ -25,5 +44,6 @@ */modules/monitoring/library/Monitoring/Backend/Ido/Query/* + */modules/monitoring/library/Monitoring/Backend/Livestatus/Query/* From c3ef50978a2eead5ef1647937e36c306570f4b0a Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Tue, 19 Sep 2017 14:41:10 +0200 Subject: [PATCH 4/8] style: Fix minor styleguide issues for PHPCS --- .../Icinga/Exception/Http/BaseHttpException.php | 1 - .../Exception/Http/HttpExceptionInterface.php | 1 - library/Icinga/Util/Json.php | 2 +- library/Icinga/Web/Form.php | 3 ++- library/Icinga/Web/Widget/Chart/InlinePie.php | 7 ++++--- library/Icinga/Web/Widget/Tabs.php | 4 +++- .../Migrate/Config/UserDomainMigration.php | 1 - .../forms/Config/TransportConfigForm.php | 4 +++- .../Command/Transport/ApiCommandTransport.php | 15 ++++++++++++--- .../application/clicommands/ConfigCommand.php | 11 ++++++++--- 10 files changed, 33 insertions(+), 16 deletions(-) diff --git a/library/Icinga/Exception/Http/BaseHttpException.php b/library/Icinga/Exception/Http/BaseHttpException.php index 781fa906d..cad41c622 100644 --- a/library/Icinga/Exception/Http/BaseHttpException.php +++ b/library/Icinga/Exception/Http/BaseHttpException.php @@ -5,7 +5,6 @@ namespace Icinga\Exception\Http; use Icinga\Exception\IcingaException; - /** * Base class for HTTP exceptions */ diff --git a/library/Icinga/Exception/Http/HttpExceptionInterface.php b/library/Icinga/Exception/Http/HttpExceptionInterface.php index 559b1d27a..c5e0cc749 100644 --- a/library/Icinga/Exception/Http/HttpExceptionInterface.php +++ b/library/Icinga/Exception/Http/HttpExceptionInterface.php @@ -3,7 +3,6 @@ namespace Icinga\Exception\Http; - interface HttpExceptionInterface { /** diff --git a/library/Icinga/Util/Json.php b/library/Icinga/Util/Json.php index 0f757c745..b41da82d5 100644 --- a/library/Icinga/Util/Json.php +++ b/library/Icinga/Util/Json.php @@ -25,7 +25,7 @@ class Json { if (version_compare(phpversion(), '5.4.0', '<')) { $encoded = json_encode($value); - } else if (version_compare(phpversion(), '5.5.0', '<')) { + } elseif (version_compare(phpversion(), '5.5.0', '<')) { $encoded = json_encode($value, $options); } else { $encoded = json_encode($value, $options, $depth); diff --git a/library/Icinga/Web/Form.php b/library/Icinga/Web/Form.php index 08b66f933..9d0d5d707 100644 --- a/library/Icinga/Web/Form.php +++ b/library/Icinga/Web/Form.php @@ -772,7 +772,8 @@ class Form extends Zend_Form $action = $action->without(array_keys($this->getElements())); } - // TODO(el): Re-evalute this necessity. JavaScript could use the container's URL if there's no action set. + // TODO(el): Re-evalute this necessity. + // JavaScript could use the container'sURL if there's no action set. // We MUST set an action as JS gets confused otherwise, if // this form is being displayed in an additional column $this->setAction($action); diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index aa0046d35..a88fc8a12 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -74,14 +74,15 @@ class InlinePie extends AbstractWidget * @var string */ private $template =<<<'EOD' - - + {noscript} EOD; private $noscript =<<<'EOD' EOD; diff --git a/library/Icinga/Web/Widget/Tabs.php b/library/Icinga/Web/Widget/Tabs.php index 2bc296939..979b5ef0a 100644 --- a/library/Icinga/Web/Widget/Tabs.php +++ b/library/Icinga/Web/Widget/Tabs.php @@ -36,7 +36,9 @@ EOT; */ private $dropdownTpl = <<< 'EOT'