Skip to content

Commit

Permalink
[BUGFIX] Add max_line_length to skip-able rules
Browse files Browse the repository at this point in the history
Resolves: #14
  • Loading branch information
a-r-m-i-n committed May 27, 2023
1 parent 264fb24 commit 3716ae2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/EditorConfig/Rules/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static function getDefinitions(): array
self::INDENT_STYLE,
self::TAB_WIDTH,
self::INSERT_FINAL_NEWLINE,
self::MAX_LINE_LENGTH,
self::TRIM_TRAILING_WHITESPACE,
];
}
Expand Down
11 changes: 9 additions & 2 deletions tests/Functional/EditorConfig/CommandSkippingRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ class CommandSkippingRulesTest extends AbstractTestCase
[*]
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 70
TXT;

protected $files = [
'valid.txt' => <<<TXT
'invalid.txt' => <<<TXT
This file has trailing whitespaces.
But also, this file has a line which is longer, than the rules allow (more than 70 chars)!
TXT,
'invalid2.txt' => 'This file is lacking of a final new line.',
];

public function testSkippingRules()
Expand All @@ -31,11 +34,15 @@ public function testSkippingRules()
$commandTester = new CommandTester($command);
$commandTester->execute(['-d' => $this->workspacePath]);
self::assertSame(2, $commandTester->getStatusCode());
self::assertStringContainsString(DIRECTORY_SEPARATOR . 'invalid.txt [2]', $commandTester->getDisplay());
self::assertStringContainsString('This file has trailing whitespaces', $commandTester->getDisplay());
self::assertStringContainsString('Max line length (70 chars) exceeded by 90 chars', $commandTester->getDisplay());
self::assertStringContainsString(DIRECTORY_SEPARATOR . 'invalid2.txt [1]', $commandTester->getDisplay());
self::assertStringContainsString('This file has no final new line given', $commandTester->getDisplay());

// Test with flag
$commandTester = new CommandTester($command);
$commandTester->execute(['-d' => $this->workspacePath, '-s' => ['trim']]);
$commandTester->execute(['-d' => $this->workspacePath, '-s' => ['trim', 'max_line_length', 'insert_final_newline']]);

self::assertStringContainsString('Skipping rules: trim_trailing_whitespace', $commandTester->getDisplay());
self::assertSame(0, $commandTester->getStatusCode());
Expand Down

0 comments on commit 3716ae2

Please sign in to comment.