From 48837fb373dfd516487583c39bd48875091f5d89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Machulda?= Date: Thu, 25 Apr 2024 15:00:16 +0200 Subject: [PATCH] Style: Add internal rules configuration for the project itself --- .gitattributes | 1 + composer.json | 4 ++-- ecs-internal.php | 22 ++++++++++++++++++++++ ecs.php | 5 ++++- 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .gitattributes create mode 100644 ecs-internal.php diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..8751c07 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +ecs-internal.php export-ignore diff --git a/composer.json b/composer.json index 2c54112..3909a6a 100644 --- a/composer.json +++ b/composer.json @@ -55,12 +55,12 @@ "@test" ], "analyze": [ - "vendor/bin/ecs check src/ tests/ ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php --ansi", + "vendor/bin/ecs check --config=ecs-internal.php --ansi", "vendor/bin/phpstan analyze -c phpstan.neon --ansi" ], "fix": [ "@composer normalize", - "vendor/bin/ecs check ./src/ ./tests/ ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php --ansi --fix" + "vendor/bin/ecs check --config=ecs-internal.php --ansi --fix" ], "lint": [ "vendor/bin/parallel-lint -j 10 -e php ./src ./tests ecs.php ecs-8.1.php ecs-8.2.php ecs-8.3.php", diff --git a/ecs-internal.php b/ecs-internal.php new file mode 100644 index 0000000..4a67d8c --- /dev/null +++ b/ecs-internal.php @@ -0,0 +1,22 @@ +withPaths([__DIR__ . '/src', __DIR__ . '/tests']) + ->withRootFiles() + ->withSets( + [ + __DIR__ . '/ecs.php', + ], + ) + ->withConfiguredRule(PhpUnitTestAnnotationFixer::class, ['style' => 'annotation']) + ->withConfiguredRule( + LineLengthFixer::class, + ['line_length' => 120, 'break_long_lines' => true, 'inline_short_lines' => false], + ); diff --git a/ecs.php b/ecs.php index 9c8fb3c..a9e3236 100644 --- a/ecs.php +++ b/ecs.php @@ -461,7 +461,10 @@ ->withConfiguredRule(ArraySyntaxFixer::class, ['syntax' => 'short']) // The body of each structure MUST be enclosed by braces. Braces should be properly placed // @TODO move configuration to BracesPositionFixer after BracesFixer is not included in PSR-12 check anymore - ->withConfiguredRule(BracesFixer::class, ['allow_single_line_closure' => true, 'allow_single_line_anonymous_class_with_empty_body' => true]) + ->withConfiguredRule( + BracesFixer::class, + ['allow_single_line_closure' => true, 'allow_single_line_anonymous_class_with_empty_body' => true], + ) // Class, trait and interface elements must be separated with one or none blank line ->withConfiguredRule(ClassAttributesSeparationFixer::class, ['elements' => ['method' => 'one']]) // Visibility MUST be declared on all properties, methods and class constants