Add phpcs ruleset and fix violations

This commit is contained in:
Robbie Averill 2017-07-20 09:57:02 +12:00
parent ba51a8e8e1
commit 563e33c772
5 changed files with 24 additions and 6 deletions

22
phpcs.xml.dist Normal file
View File

@ -0,0 +1,22 @@
<?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="PSR1.Files.SideEffects.FoundWithSymbols" />
<exclude name="PSR2.Classes.PropertyDeclaration" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration" /> <!-- causes php notice while linting -->
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenercase" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.WrongOpenerdefault" />
<exclude name="PSR2.ControlStructures.SwitchDeclaration.TerminatingComment" />
<exclude name="PSR2.Methods.MethodDeclaration.Underscore" />
<exclude name="Squiz.Scope.MethodScope" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Generic.Files.LineLength.TooLong" />
<exclude name="PEAR.Functions.ValidDefaultValue.NotAtEnd" />
</rule>
</ruleset>

View File

@ -6,7 +6,6 @@ use SilverStripe\Blog\Model\BlogPost;
use SilverStripe\Lumberjack\Forms\GridFieldSiteTreeState;
use SilverStripe\View\Requirements;
/**
* Provides a component to the {@link GridField} which tells the user whether or not a blog post
* has been published and when.

View File

@ -221,7 +221,7 @@ class BlogController extends PageController
if ($tag) {
$this->blogPosts = $tag->BlogPosts();
if($this->isRSS()) {
if ($this->isRSS()) {
return $this->rssFeed($this->blogPosts, $tag->getLink());
} else {
return $this->render();
@ -265,7 +265,7 @@ class BlogController extends PageController
if ($category) {
$this->blogPosts = $category->BlogPosts();
if($this->isRSS()) {
if ($this->isRSS()) {
return $this->rssFeed($this->blogPosts, $category->getLink());
} else {
return $this->render();

View File

@ -123,5 +123,3 @@ class BlogCategoriesWidget extends Widget
return $query;
}
}

View File

@ -215,5 +215,4 @@ class BlogTagTest extends FunctionalTest
$tag->write();
$this->assertEquals($tag->URLSegment, "another-test");
}
}