From 7d8f86c6146f2aa80bea912a014aa4d9c3de22f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 17:51:13 +0200 Subject: [PATCH 1/4] Create .stickler.yml --- .stickler.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .stickler.yml diff --git a/.stickler.yml b/.stickler.yml new file mode 100644 index 00000000000..af0cb290035 --- /dev/null +++ b/.stickler.yml @@ -0,0 +1,7 @@ +--- +linters: + phpcs: + standard: 'dev/setup/codesniffer/ruleset.xml' + extensions: 'php' + tab_width: 4 + fixer: true From c08c3b5c9c101a6aadc4f836ef3ce8c915415117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Mon, 26 Aug 2019 21:33:46 +0200 Subject: [PATCH 2/4] Enable fixer to auto-fix code style issues --- .stickler.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.stickler.yml b/.stickler.yml index af0cb290035..b68804448b2 100644 --- a/.stickler.yml +++ b/.stickler.yml @@ -5,3 +5,6 @@ linters: extensions: 'php' tab_width: 4 fixer: true + +fixers: + enable: true From 0702ef4e0ffc71e74066374b62708355a4b8e3e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= Date: Tue, 27 Aug 2019 08:43:58 +0200 Subject: [PATCH 3/4] Fix CI (code style) --- htdocs/core/class/commoninvoice.class.php | 2 +- htdocs/core/class/discount.class.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 86ef739d63e..259014cf691 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -201,7 +201,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumFromThisCreditNotesNotUsed($multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($multicurrency = 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index cb2ad44b90c..5cf7e8cdb7a 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -636,7 +636,7 @@ class DiscountAbsolute * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency=0) + public function getSumFromThisCreditNotesNotUsed($invoice, $multicurrency = 0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); @@ -646,7 +646,7 @@ class DiscountAbsolute $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; $sql.= ' WHERE rc.fk_facture IS NULL AND rc.fk_facture_source = '.$invoice->id; } - else if ($invoice->element == 'invoice_supplier') + elseif ($invoice->element == 'invoice_supplier') { $sql = 'SELECT sum(rc.amount_ttc) as amount, sum(rc.multicurrency_amount_ttc) as multicurrency_amount'; $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; From 9ca85b8e19cc23fa5c92d871309f91b9fbb01b78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean=20Traull=C3=A9?= <613615+jtraulle@users.noreply.github.com> Date: Tue, 27 Aug 2019 09:30:42 +0200 Subject: [PATCH 4/4] Disabling coding style checks for Pull Requests Because coding style would have been checked by SticklerCI, we can safely skip this in Travis-CI when in Pull Request context. It will increase build speed by about 50%. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1521035578b..7c1552bb2a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -293,12 +293,12 @@ script: echo - | - echo "Checking coding style" + echo "Checking coding style (excluding Pull Requests builds)" # Ensure we catch errors set -e # Exclusions are defined in the ruleset.xml file #phpcs -s -n -p -d memory_limit=-1 --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 . - phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true . + if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then phpcs -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true .; fi set +e echo