Skip to content

Commit

Permalink
Lint php coding standards via CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman authored and chillu committed Jan 31, 2017
1 parent c7214b4 commit a80b8ae
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions .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
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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/
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Expand Up @@ -34,6 +34,9 @@
"dev-master": "4.0.x-dev"
}
},
"scripts": {
"lint": "phpcs -s code/ tests/"
},
"autoload": {
"psr-4": {
"SilverStripe\\CMS\\": "code/"
Expand Down
18 changes: 18 additions & 0 deletions phpcs.xml.dist
@@ -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>

0 comments on commit a80b8ae

Please sign in to comment.