Skip to content

Add tests for RequireSingleLineConditionSniff limits - #1863

Open
MauricioFauth wants to merge 2 commits into
slevomat:masterfrom
MauricioFauth:RequireSingleLineConditionSniff-limits
Open

Add tests for RequireSingleLineConditionSniff limits#1863
MauricioFauth wants to merge 2 commits into
slevomat:masterfrom
MauricioFauth:RequireSingleLineConditionSniff-limits

Conversation

@MauricioFauth

Copy link
Copy Markdown

Improves unit tests of the sniff SlevomatCodingStandard.ControlStructures.RequireSingleLineCondition.

I also added an extra case for a simple condition involving a function call with multiple parameters, to show the extra spaces that are counted for the maximum line length.

The following changes now causes the tests to fail:

--- a/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
+++ b/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
@@ -15,7 +15,7 @@ class RequireSingleLineConditionSniff extends AbstractLineCondition
 
        public const CODE_REQUIRED_SINGLE_LINE_CONDITION = 'RequiredSingleLineCondition';
 
-       public int $maxLineLength = 120;
+       public int $maxLineLength = 121;
 
        public bool $alwaysForSimpleConditions = true;
--- a/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
+++ b/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
@@ -15,7 +15,7 @@ class RequireSingleLineConditionSniff extends AbstractLineCondition
 
        public const CODE_REQUIRED_SINGLE_LINE_CONDITION = 'RequiredSingleLineCondition';
 
-       public int $maxLineLength = 120;
+       public int $maxLineLength = 119;
 
        public bool $alwaysForSimpleConditions = true;
--- a/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
+++ b/SlevomatCodingStandard/Sniffs/ControlStructures/RequireSingleLineConditionSniff.php
@@ -17,7 +17,7 @@ class RequireSingleLineConditionSniff extends AbstractLineCondition
 
        public int $maxLineLength = 120;
 
-       public bool $alwaysForSimpleConditions = true;
+       public bool $alwaysForSimpleConditions = false;
 
        public function process(File $phpcsFile, int $controlStructurePointer): void

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant