Skip to content

Commit 2212cd5

Browse files
authored
Merge pull request #3 from ProtonMail/add-rules-2
Add rules, update requirement
2 parents 4c7d47f + 4d7e9d4 commit 2212cd5

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

Proton/ruleset.xml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<rule ref="Generic.Metrics.CyclomaticComplexity">
9696
<properties>
9797
<property name="complexity" value="15"/>
98-
<property name="absoluteComplexity" value="25"/>
98+
<property name="absoluteComplexity" value="20"/>
9999
</properties>
100100
</rule>
101101

@@ -141,6 +141,7 @@
141141
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
142142
<rule ref="SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable"/>
143143
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
144+
<rule ref="SlevomatCodingStandard.Functions.TrailingCommaInCall" />
144145
<rule ref="SlevomatCodingStandard.Exceptions.DeadCatch"/>
145146
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
146147
<!-- <rule ref="SlevomatCodingStandard.Namespaces.UnusedUses"/>-->
@@ -157,6 +158,12 @@
157158
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/>
158159
<rule ref="SlevomatCodingStandard.Commenting.ForbiddenComments"/>
159160
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration"/>
161+
<rule ref="SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration"/>
162+
<rule ref="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration">
163+
<properties>
164+
<property name="allowAboveNonAssignment" value="true"/>
165+
</properties>
166+
</rule>
160167
<rule ref="SlevomatCodingStandard.Operators.SpreadOperatorSpacing">
161168
<properties>
162169
<property name="spacesCountAfterOperator" value="0"/>

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"require": {
1818
"php": "^7.1",
19-
"slevomat/coding-standard": "^5.0|^6.0",
19+
"slevomat/coding-standard": "^6.4",
2020
"squizlabs/php_codesniffer": "^3.5"
2121
},
2222
"license": "MIT"

tests/correct/ClassOk.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,34 @@ public function __construct(array $config)
2828

2929
public function ping(Request $request)
3030
{
31+
$this->foo(
32+
'a',
33+
'b',
34+
);
35+
3136
return $request->query->get('test');
3237
}
3338

39+
/**
40+
* @deprecated This is a message
41+
* @return bool|string
42+
*/
3443
public function foo(string $a, string $b)
3544
{
3645
$a = $a . 'test';
3746

47+
if ($a === $b) {
48+
return true;
49+
}
50+
51+
/** @var string|null $foo */
52+
$foo = $this->foo['a'] ?? null;
53+
3854
if (
3955
$a === 'a'
4056
|| $b === 'b'
4157
) {
42-
return $a;
58+
return $foo;
4359
}
4460

4561
return false;

tests/expected_csv.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ Line,Column,Type,Source
99
1,1,error,SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
1010
8,1,error, found 1."
1111
6,18,error,PSR12.Files.FileHeader.SpacingInsideBlock
12-
41,1,error,PSR2.Files.EndFileNewline.NoneFound
12+
54,1,error,PSR2.Files.EndFileNewline.NoneFound
13+
50,54,error,SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing.WhitespaceBeforeColon
14+
50,52,error,PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeColon
15+
50,20,warning,Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
16+
50,20,error,PSR1.Methods.CamelCapsMethodName.NotCamelCaps
17+
48,8,error,SlevomatCodingStandard.Commenting.DeprecatedAnnotationDeclaration.MissingDescription
18+
43,13,error,SlevomatCodingStandard.Functions.TrailingCommaInCall.MissingTrailingComma
19+
42,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed
20+
41,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed
1321
4,1,error, found 2."
1422
39,1,error,Generic.WhiteSpace.DisallowTabIndent.TabsUsed
1523
38,13,warning,Squiz.PHP.NonExecutableCode.Unreachable

tests/wrong/Class1.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,18 @@ private function unused() {
3737
return true;
3838
return true;
3939
}
40+
41+
$this->foo(
42+
'a',
43+
2
44+
);
45+
}
46+
47+
/**
48+
* @deprecated
49+
*/
50+
private static function Foo(string $a, $b, $c) : array
51+
{
52+
return [$a, $b];
4053
}
4154
}

0 commit comments

Comments
 (0)