Add some more sane Code Sniffs and fix smelling code
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Dec 2014 21:37:55 +0000 (22:37 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Thu, 18 Dec 2014 21:41:43 +0000 (22:41 +0100)
CodeSniff/WCF/ruleset.xml
wcfsetup/install/files/lib/system/io/GZipFile.class.php
wcfsetup/install/files/lib/util/FileReader.class.php
wcfsetup/install/files/lib/util/FileUtil.class.php
wcfsetup/install/files/lib/util/StringStack.class.php

index be86bd9a8133bdf9209a8b11dc46610cfed5a200..4cc053022012aa90287214a3ae7690a3aadf16cf 100644 (file)
@@ -5,6 +5,9 @@
        <exclude-pattern>*/CodeSniff/*</exclude-pattern>
        
        <rule ref="Generic.Classes.DuplicateClassName" />
+       <rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
+       <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall" />
+       <rule ref="Generic.CodeAnalysis.UnconditionalIfStatement" />
        <rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
        <rule ref="Generic.Files.ByteOrderMark" />
        <rule ref="Generic.Files.EndFileNewline" />
@@ -16,6 +19,7 @@
        <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag" />
        <rule ref="Generic.PHP.DisallowShortOpenTag" />
        <rule ref="Generic.PHP.LowerCaseConstant" />
+       <rule ref="Generic.PHP.LowerCaseKeyword" />
        <rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
        <rule ref="Squiz.Arrays.ArrayBracketSpacing" />
        <rule ref="Squiz.Classes.LowercaseClassKeywords" />
        <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
        <rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
        <rule ref="Squiz.ControlStructures.LowercaseDeclaration" />
+       <rule ref="Squiz.Operators.IncrementDecrementUsage" />
        <rule ref="Squiz.Operators.ValidLogicalOperators" />
        <rule ref="Squiz.PHP.ForbiddenFunctions" />
        <rule ref="Squiz.Scope.MethodScope" />
+       <rule ref="Squiz.Strings.EchoedStrings" />
+       <rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace" />
+       <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing" />
        <rule ref="WCF.Classes.ClassFileName" />
        <rule ref="WCF.ControlStructures.ControlSignature" />
        <rule ref="WCF.Functions.OpeningFunctionBraceKernighanRitchie" />
index d92b170ec107721388d1b1210e7454609d666d85..3589a4cc411bc2df118a1dc1673e7a4ea5805773 100644 (file)
@@ -69,7 +69,7 @@ class GZipFile extends File {
                        $eof += $byteBlock * ($this->seek($eof) ? -1 : 1);
                }
                
-               if ($this->seek($eof) == -1) $eof -= 1;
+               if ($this->seek($eof) == -1) $eof--;
                                
                $this->rewind();
                return $eof - $correction;
index 8f007eff0adee269967e7ef85fec2c38043e3648..14625bd9ae62b2407e0381a89752205af6972e08 100644 (file)
@@ -233,6 +233,5 @@ class FileReader {
         */
        public function removeHeader($name) {
                unset($this->headers[$name]);
-               return;
        }
 }
index 6fb3d322c847e795ef74e66ba74c2d8a1502b04c..cc7e8a010b2ff62abf5c9a9e7fc060def1ed4326 100644 (file)
@@ -169,9 +169,7 @@ final class FileUtil {
                                                unset($target[$j]);
                                        }
                                        $relPath .= str_repeat('../', count($current) - $i).implode('/', $target).'/';
-                                       for ($j = $i + 1; $j < count($current); $j++) {
-                                               unset($current[$j]);
-                                       }
+                                       
                                        break;
                                }
                        }       
index 4d07c12bf5375889790cd08c36a8be6d71649e58..a816afeab2ff22f80c1189415a829e9b6d8d9e87 100644 (file)
@@ -32,7 +32,8 @@ final class StringStack {
         * @return      string          $hash
         */
        public static function pushToStringStack($string, $type = 'default', $delimiter = '@@') {
-               $hash = $delimiter.StringUtil::getHash(self::$i++ . uniqid(microtime()) . $string).$delimiter;
+               self::$i++;
+               $hash = $delimiter.StringUtil::getHash(self::$i.uniqid(microtime()).$string).$delimiter;
                
                if (!isset(self::$stringStack[$type])) {
                        self::$stringStack[$type] = array();