Lint php coding standards via CI

This commit is contained in:
Damian Mooyman 2017-01-26 10:01:58 +13:00 committed by Ingo Schommer
parent c7214b4dcd
commit a80b8aef60
5 changed files with 28 additions and 4 deletions

View File

@ -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

5
.gitattributes vendored
View File

@ -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

View File

@ -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/

View File

@ -34,6 +34,9 @@
"dev-master": "4.0.x-dev"
}
},
"scripts": {
"lint": "phpcs -s code/ tests/"
},
"autoload": {
"psr-4": {
"SilverStripe\\CMS\\": "code/"

18
phpcs.xml.dist Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="SilverStripe">
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description>
<!-- base rules are PSR-2 -->
<rule ref="PSR2" >
<!-- Current exclusions -->
<exclude name="PSR1.Methods.CamelCapsMethodName" />
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.Files.LineLength.TooLong" />
<!-- CMS specific exclusions (high priority to fix) -->
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<exclude name="PSR1.Classes.ClassDeclaration.MultipleClasses" />
</rule>
</ruleset>