From a80b8aef60bd4489b0838c4ac6857cf9b53a543d Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 26 Jan 2017 10:01:58 +1300 Subject: [PATCH] Lint php coding standards via CI --- .editorconfig | 2 +- .gitattributes | 5 +++-- .travis.yml | 4 +++- composer.json | 3 +++ phpcs.xml.dist | 18 ++++++++++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 phpcs.xml.dist diff --git a/.editorconfig b/.editorconfig index b063122c39..56a43d3324 100644 --- a/.editorconfig +++ b/.editorconfig @@ -6,7 +6,7 @@ charset = utf-8 end_of_line = lf indent_size = 4 -indent_style = tab +indent_style = space insert_final_newline = true trim_trailing_whitespace = true diff --git a/.gitattributes b/.gitattributes index daddf541f4..20ad9a100a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,7 @@ docs/ export-ignore -javascript/src/ export ignore -behat.yml export ignore +javascript/src/ export-ignore +behat.yml export-ignore +*.dist export-ignore # Hide diffs javascript/dist/ -diff diff --git a/.travis.yml b/.travis.yml index 828a795981..38268f2096 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ matrix: - php: 5.5 env: DB=SQLITE PHPUNIT_TEST=1 - php: 5.6 - env: DB=MYSQL PDO=1 PHPUNIT_TEST=1 + env: DB=MYSQL PDO=1 PHPUNIT_TEST=1 PHPCS_TEST=1 - php: 5.6 env: DB=MYSQL BEHAT_TEST=1 - php: 5.6 @@ -36,6 +36,7 @@ matrix: before_script: - composer self-update || true + - "if [ \"$PHPCS_TEST\" = \"1\" ]; then pyrus install pear/PHP_CodeSniffer; fi" - phpenv rehash - phpenv config-rm xdebug.ini - echo 'memory_limit = 2G' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini @@ -59,6 +60,7 @@ script: - "if [ \"$NPM_TEST\" = \"1\" ]; then (nvm use $TRAVIS_NODE_VERSION && npm run lint); fi" - "if [ \"$PHPUNIT_COVERAGE_TEST\" = \"1\" ]; then phpdbg -qrr vendor/bin/phpunit tests flush=1 --coverage-clover=coverage.xml; fi" - "if [ \"$PHPUNIT_COVERAGE_TEST\" = \"1\" ]; then bash <(curl -s https://codecov.io/bash) -f coverage.xml; fi" + - "if [ \"$PHPCS_TEST\" = \"1\" ]; then composer run-script lint; fi" after_failure: - php ~/travis-support/travis_upload_artifacts.php --if-env BEHAT_TEST,ARTIFACTS_KEY --target-path $TRAVIS_REPO_SLUG/$TRAVIS_BUILD_ID/$TRAVIS_JOB_ID --artifacts-base-url https://s3.amazonaws.com/$ARTIFACTS_BUCKET/ diff --git a/composer.json b/composer.json index 03806e2f8e..4324beb532 100644 --- a/composer.json +++ b/composer.json @@ -34,6 +34,9 @@ "dev-master": "4.0.x-dev" } }, + "scripts": { + "lint": "phpcs -s code/ tests/" + }, "autoload": { "psr-4": { "SilverStripe\\CMS\\": "code/" diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000000..7ea013abd4 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,18 @@ + + + CodeSniffer ruleset for SilverStripe coding conventions. + + + + + + + + + + + + + + +