Skip to content

Commit

Permalink
Merge pull request #3 from ProtonMail/add-rules-2
Browse files Browse the repository at this point in the history
Add rules, update requirement
  • Loading branch information
BafS committed Oct 23, 2020
2 parents 4c7d47f + 4d7e9d4 commit 2212cd5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Proton/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="15"/>
<property name="absoluteComplexity" value="25"/>
<property name="absoluteComplexity" value="20"/>
</properties>
</rule>

Expand Down Expand Up @@ -141,6 +141,7 @@
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<rule ref="SlevomatCodingStandard.Functions.TrailingCommaInCall" />
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
<!-- <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>-->
Expand All @@ -157,6 +158,12 @@
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments"/>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
<properties>
<property name="allowAboveNonAssignment" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing">
<properties>
<property name="spacesCountAfterOperator" value="0"/>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"require": {
"php": "^7.1",
"slevomat/coding-standard": "^5.0|^6.0",
"slevomat/coding-standard": "^6.4",
"squizlabs/php_codesniffer": "^3.5"
},
"license": "MIT"
Expand Down
18 changes: 17 additions & 1 deletion tests/correct/ClassOk.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,34 @@ public function __construct(array $config)

public function ping(Request $request)
{
$this->foo(
'a',
'b',
);

return $request->query->get('test');
}

/**
* @deprecated This is a message
* @return bool|string
*/
public function foo(string $a, string $b)
{
$a = $a . 'test';

if ($a === $b) {
return true;
}

/** @var string|null $foo */
$foo = $this->foo['a'] ?? null;

if (
$a === 'a'
|| $b === 'b'
) {
return $a;
return $foo;
}

return false;
Expand Down
10 changes: 9 additions & 1 deletion tests/expected_csv.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ Line,Column,Type,Source
1,1,error,SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
8,1,error, found 1."
6,18,error,PSR12.Files.FileHeader.SpacingInsideBlock
41,1,error,PSR2.Files.EndFileNewline.NoneFound
54,1,error,PSR2.Files.EndFileNewline.NoneFound
50,54,error,SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing.WhitespaceBeforeColon
50,52,error,PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeColon
50,20,warning,Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
50,20,error,PSR1.Methods.CamelCapsMethodName.NotCamelCaps
48,8,error,SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration.MissingDescription
43,13,error,SlevomatCodingStandard.Functions.TrailingCommaInCall.MissingTrailingComma
42,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed
41,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed
4,1,error, found 2."
39,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed
38,13,warning,Squiz.PHP.NonExecutableCode.Unreachable
Expand Down
13 changes: 13 additions & 0 deletions tests/wrong/Class1.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,18 @@ private function unused() {
return true;
return true;
}

$this->foo(
'a',
2
);
}

/**
* @deprecated
*/
private static function Foo(string $a, $b, $c) : array
{
return [$a, $b];
}
}

0 comments on commit 2212cd5

Please sign in to comment.