From 50e2ee1d7b55e9b9b6b717281b8cd8a0614b4268 Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 12:41:40 +0200 Subject: [PATCH 01/13] Add implementation of Interface --- .../GithubWorkflowOutputFormatter.php | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/OutputFormatter/GithubWorkflowOutputFormatter.php diff --git a/src/OutputFormatter/GithubWorkflowOutputFormatter.php b/src/OutputFormatter/GithubWorkflowOutputFormatter.php new file mode 100644 index 000000000..dda4d9328 --- /dev/null +++ b/src/OutputFormatter/GithubWorkflowOutputFormatter.php @@ -0,0 +1,40 @@ + Date: Thu, 28 May 2020 12:57:15 +0200 Subject: [PATCH 02/13] Add tests with unimplemented test for 'finish' --- .../GithubWorkflowOutputFormatterTest.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/OutputFormatter/GithubWorkflowOutputFormatterTest.php diff --git a/tests/OutputFormatter/GithubWorkflowOutputFormatterTest.php b/tests/OutputFormatter/GithubWorkflowOutputFormatterTest.php new file mode 100644 index 000000000..5c2a7d990 --- /dev/null +++ b/tests/OutputFormatter/GithubWorkflowOutputFormatterTest.php @@ -0,0 +1,19 @@ +getName()); + } + + public function testFinish() + { + $this->markTestIncomplete('Not Implemented'); + } +} From 833349738a78a4232215fe97c17b1f9c481436ac Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 12:58:25 +0200 Subject: [PATCH 03/13] Rename 'Github Workflow' to 'Github Actions' --- ...OutputFormatter.php => GithubActionsOutputFormatter.php} | 4 ++-- ...rmatterTest.php => GithubActionsOutputFormatterTest.php} | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/OutputFormatter/{GithubWorkflowOutputFormatter.php => GithubActionsOutputFormatter.php} (85%) rename tests/OutputFormatter/{GithubWorkflowOutputFormatterTest.php => GithubActionsOutputFormatterTest.php} (51%) diff --git a/src/OutputFormatter/GithubWorkflowOutputFormatter.php b/src/OutputFormatter/GithubActionsOutputFormatter.php similarity index 85% rename from src/OutputFormatter/GithubWorkflowOutputFormatter.php rename to src/OutputFormatter/GithubActionsOutputFormatter.php index dda4d9328..40d1c841f 100644 --- a/src/OutputFormatter/GithubWorkflowOutputFormatter.php +++ b/src/OutputFormatter/GithubActionsOutputFormatter.php @@ -7,7 +7,7 @@ use SensioLabs\Deptrac\RulesetEngine\Context; use Symfony\Component\Console\Output\OutputInterface; -class GithubWorkflowOutputFormatter implements OutputFormatterInterface +class GithubActionsOutputFormatter implements OutputFormatterInterface { /** @@ -15,7 +15,7 @@ class GithubWorkflowOutputFormatter implements OutputFormatterInterface */ public function getName(): string { - return 'github-workflow'; + return 'github-actions'; } /** diff --git a/tests/OutputFormatter/GithubWorkflowOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php similarity index 51% rename from tests/OutputFormatter/GithubWorkflowOutputFormatterTest.php rename to tests/OutputFormatter/GithubActionsOutputFormatterTest.php index 5c2a7d990..816c75638 100644 --- a/tests/OutputFormatter/GithubWorkflowOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -3,13 +3,13 @@ namespace Tests\SensioLabs\Deptrac\OutputFormatter; use PHPUnit\Framework\TestCase; -use SensioLabs\Deptrac\OutputFormatter\GithubWorkflowOutputFormatter; +use SensioLabs\Deptrac\OutputFormatter\GithubActionsOutputFormatter; -class GithubWorkflowOutputFormatterTest extends TestCase +class GithubActionsOutputFormatterTest extends TestCase { public function testGetName() { - static::assertEquals('github-workflow', (new GithubWorkflowOutputFormatter())->getName()); + static::assertEquals('github-actions', (new GithubActionsOutputFormatter())->getName()); } public function testFinish() From a9d256e5835ef09609a9cefe3bccb157860d37b2 Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 13:07:07 +0200 Subject: [PATCH 04/13] Output empty when no rules are set --- .../GithubActionsOutputFormatterTest.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index 816c75638..06714baed 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -4,6 +4,9 @@ use PHPUnit\Framework\TestCase; use SensioLabs\Deptrac\OutputFormatter\GithubActionsOutputFormatter; +use SensioLabs\Deptrac\OutputFormatter\OutputFormatterInput; +use SensioLabs\Deptrac\RulesetEngine\Context; +use Symfony\Component\Console\Output\BufferedOutput; class GithubActionsOutputFormatterTest extends TestCase { @@ -12,8 +15,24 @@ public function testGetName() static::assertEquals('github-actions', (new GithubActionsOutputFormatter())->getName()); } - public function testFinish() + public function testFinish(): void { - $this->markTestIncomplete('Not Implemented'); + $rules = []; + $expectedOutput = ''; + + $output = new BufferedOutput(); + + $formatter = new GithubActionsOutputFormatter(); + $formatter->finish( + new Context($rules), + $output, + new OutputFormatterInput([]) + ); + + $o = $output->fetch(); + static::assertEquals( + $expectedOutput, + $o + ); } } From 7a9fbc201af536a769f8e44ef9e21aae7563a2e5 Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 13:08:51 +0200 Subject: [PATCH 05/13] Extract test case to data provider --- .../GithubActionsOutputFormatterTest.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index 06714baed..8a9c8f8ca 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -15,11 +15,11 @@ public function testGetName() static::assertEquals('github-actions', (new GithubActionsOutputFormatter())->getName()); } - public function testFinish(): void + /** + * @dataProvider finishProvider + */ + public function testFinish(array $rules, string $expectedOutput): void { - $rules = []; - $expectedOutput = ''; - $output = new BufferedOutput(); $formatter = new GithubActionsOutputFormatter(); @@ -35,4 +35,12 @@ public function testFinish(): void $o ); } + + public function finishProvider() + { + yield 'No Rules, No Output' => [ + [], + '', + ]; + } } From e09fb50b9b94df0ec961a6749700b62f23a7f090 Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 13:43:11 +0200 Subject: [PATCH 06/13] Output for Simple Single Layer Violation --- .../GithubActionsOutputFormatter.php | 12 ++++++++++++ .../GithubActionsOutputFormatterTest.php | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/OutputFormatter/GithubActionsOutputFormatter.php b/src/OutputFormatter/GithubActionsOutputFormatter.php index 40d1c841f..e4f76814e 100644 --- a/src/OutputFormatter/GithubActionsOutputFormatter.php +++ b/src/OutputFormatter/GithubActionsOutputFormatter.php @@ -36,5 +36,17 @@ public function enabledByDefault(): bool */ public function finish(Context $context, OutputInterface $output, OutputFormatterInput $outputFormatterInput): void { + foreach($context->violations() as $rule) { + $dependency = $rule->getDependency(); + $output->writeln(sprintf( + '::error file=%s,line=%s::%s must not depend on %s (%s on %s)', + $dependency->getFileOccurrence()->getFilepath(), + $dependency->getFileOccurrence()->getLine(), + $dependency->getClassLikeNameA()->toString(), + $dependency->getClassLikeNameB()->toString(), + $rule->getLayerA(), + $rule->getLayerB() + )); + } } } diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index 8a9c8f8ca..34a81c6ba 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -3,9 +3,13 @@ namespace Tests\SensioLabs\Deptrac\OutputFormatter; use PHPUnit\Framework\TestCase; +use SensioLabs\Deptrac\AstRunner\AstMap\ClassLikeName; +use SensioLabs\Deptrac\AstRunner\AstMap\FileOccurrence; +use SensioLabs\Deptrac\Dependency\Dependency; use SensioLabs\Deptrac\OutputFormatter\GithubActionsOutputFormatter; use SensioLabs\Deptrac\OutputFormatter\OutputFormatterInput; use SensioLabs\Deptrac\RulesetEngine\Context; +use SensioLabs\Deptrac\RulesetEngine\Violation; use Symfony\Component\Console\Output\BufferedOutput; class GithubActionsOutputFormatterTest extends TestCase @@ -38,9 +42,23 @@ public function testFinish(array $rules, string $expectedOutput): void public function finishProvider() { + $originalA = ClassLikeName::fromFQCN('OriginalA'); + $originalB = ClassLikeName::fromFQCN('OriginalB'); + yield 'No Rules, No Output' => [ [], '', ]; + + yield 'Simple Layer Violation' => [ + [ + new Violation( + new Dependency($originalA, $originalB, FileOccurrence::fromFilepath('originalA.php', 12)), + 'LayerA', + 'LayerB' + ), + ], + "::error file=originalA.php,line=12::OriginalA must not depend on OriginalB (LayerA on LayerB)\n" + ]; } } From d5da18375bae9ca02ee77e3fe5d86536037ca7b6 Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 13:48:00 +0200 Subject: [PATCH 07/13] Run Coding Standards Fixer --- src/OutputFormatter/GithubActionsOutputFormatter.php | 11 ++++------- .../GithubActionsOutputFormatterTest.php | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/OutputFormatter/GithubActionsOutputFormatter.php b/src/OutputFormatter/GithubActionsOutputFormatter.php index e4f76814e..3b6c94602 100644 --- a/src/OutputFormatter/GithubActionsOutputFormatter.php +++ b/src/OutputFormatter/GithubActionsOutputFormatter.php @@ -1,17 +1,14 @@ violations() as $rule) { + foreach ($context->violations() as $rule) { $dependency = $rule->getDependency(); $output->writeln(sprintf( '::error file=%s,line=%s::%s must not depend on %s (%s on %s)', diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index 34a81c6ba..9d1274e64 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -58,7 +58,7 @@ public function finishProvider() 'LayerB' ), ], - "::error file=originalA.php,line=12::OriginalA must not depend on OriginalB (LayerA on LayerB)\n" + "::error file=originalA.php,line=12::OriginalA must not depend on OriginalB (LayerA on LayerB)\n", ]; } } From f885bb56e5f7b8b80de9f4aa560d642781e457cd Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 14:01:05 +0200 Subject: [PATCH 08/13] Ouput for Skipped Violations --- .../GithubActionsOutputFormatter.php | 24 +++++++++++++++++-- .../GithubActionsOutputFormatterTest.php | 14 ++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/OutputFormatter/GithubActionsOutputFormatter.php b/src/OutputFormatter/GithubActionsOutputFormatter.php index 3b6c94602..f9efc9233 100644 --- a/src/OutputFormatter/GithubActionsOutputFormatter.php +++ b/src/OutputFormatter/GithubActionsOutputFormatter.php @@ -3,6 +3,9 @@ namespace SensioLabs\Deptrac\OutputFormatter; use SensioLabs\Deptrac\RulesetEngine\Context; +use SensioLabs\Deptrac\RulesetEngine\Rule; +use SensioLabs\Deptrac\RulesetEngine\SkippedViolation; +use SensioLabs\Deptrac\RulesetEngine\Violation; use Symfony\Component\Console\Output\OutputInterface; class GithubActionsOutputFormatter implements OutputFormatterInterface @@ -33,10 +36,15 @@ public function enabledByDefault(): bool */ public function finish(Context $context, OutputInterface $output, OutputFormatterInput $outputFormatterInput): void { - foreach ($context->violations() as $rule) { + foreach ($context->all() as $rule) { + if (!$rule instanceof Violation && !$rule instanceof SkippedViolation) { + continue; + } + $dependency = $rule->getDependency(); $output->writeln(sprintf( - '::error file=%s,line=%s::%s must not depend on %s (%s on %s)', + '::%s file=%s,line=%s::%s must not depend on %s (%s on %s)', + $this->determineLogLevel($rule), $dependency->getFileOccurrence()->getFilepath(), $dependency->getFileOccurrence()->getLine(), $dependency->getClassLikeNameA()->toString(), @@ -46,4 +54,16 @@ public function finish(Context $context, OutputInterface $output, OutputFormatte )); } } + + public function determineLogLevel(Rule $rule): string + { + switch (get_class($rule)) { + case Violation::class: + return 'error'; + case SkippedViolation::class: + return 'warning'; + default: + return 'debug'; + } + } } diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index 9d1274e64..a208c033a 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -9,6 +9,7 @@ use SensioLabs\Deptrac\OutputFormatter\GithubActionsOutputFormatter; use SensioLabs\Deptrac\OutputFormatter\OutputFormatterInput; use SensioLabs\Deptrac\RulesetEngine\Context; +use SensioLabs\Deptrac\RulesetEngine\SkippedViolation; use SensioLabs\Deptrac\RulesetEngine\Violation; use Symfony\Component\Console\Output\BufferedOutput; @@ -50,7 +51,7 @@ public function finishProvider() '', ]; - yield 'Simple Layer Violation' => [ + yield 'Simple Violation' => [ [ new Violation( new Dependency($originalA, $originalB, FileOccurrence::fromFilepath('originalA.php', 12)), @@ -60,5 +61,16 @@ public function finishProvider() ], "::error file=originalA.php,line=12::OriginalA must not depend on OriginalB (LayerA on LayerB)\n", ]; + + yield 'Skipped Violation' => [ + [ + new SkippedViolation( + new Dependency($originalA, $originalB, FileOccurrence::fromFilepath('originalA.php', 12)), + 'LayerA', + 'LayerB' + ), + ], + "::warning file=originalA.php,line=12::OriginalA must not depend on OriginalB (LayerA on LayerB)\n", + ]; } } From d9bab6441187e66be84d83444da0369bfd80add2 Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 15:50:49 +0200 Subject: [PATCH 09/13] Add '[SKIPPED]' to skipped violations --- src/OutputFormatter/GithubActionsOutputFormatter.php | 3 ++- tests/OutputFormatter/GithubActionsOutputFormatterTest.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OutputFormatter/GithubActionsOutputFormatter.php b/src/OutputFormatter/GithubActionsOutputFormatter.php index f9efc9233..022ad7b8b 100644 --- a/src/OutputFormatter/GithubActionsOutputFormatter.php +++ b/src/OutputFormatter/GithubActionsOutputFormatter.php @@ -43,10 +43,11 @@ public function finish(Context $context, OutputInterface $output, OutputFormatte $dependency = $rule->getDependency(); $output->writeln(sprintf( - '::%s file=%s,line=%s::%s must not depend on %s (%s on %s)', + '::%s file=%s,line=%s::%s%s must not depend on %s (%s on %s)', $this->determineLogLevel($rule), $dependency->getFileOccurrence()->getFilepath(), $dependency->getFileOccurrence()->getLine(), + $rule instanceof SkippedViolation ? '[SKIPPED] ' : '', $dependency->getClassLikeNameA()->toString(), $dependency->getClassLikeNameB()->toString(), $rule->getLayerA(), diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index a208c033a..5f3eaec2e 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -70,7 +70,7 @@ public function finishProvider() 'LayerB' ), ], - "::warning file=originalA.php,line=12::OriginalA must not depend on OriginalB (LayerA on LayerB)\n", + "::warning file=originalA.php,line=12::[SKIPPED] OriginalA must not depend on OriginalB (LayerA on LayerB)\n", ]; } } From 172b21019d44f3212c2108432d5e0d0e4eb1cd1e Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 16:37:12 +0200 Subject: [PATCH 10/13] Integrate GithubActionsOutputFormatter --- config/services.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/services.php b/config/services.php index 945355744..2342bce3d 100644 --- a/config/services.php +++ b/config/services.php @@ -32,6 +32,7 @@ use SensioLabs\Deptrac\DependencyEmitter\InheritanceDependencyEmitter; use SensioLabs\Deptrac\FileResolver; use SensioLabs\Deptrac\OutputFormatter\ConsoleOutputFormatter; +use SensioLabs\Deptrac\OutputFormatter\GithubActionsOutputFormatter; use SensioLabs\Deptrac\OutputFormatter\GraphVizOutputFormatter; use SensioLabs\Deptrac\OutputFormatter\JUnitOutputFormatter; use SensioLabs\Deptrac\OutputFormatter\XMLOutputFormatter; @@ -107,6 +108,9 @@ $services ->set(ConsoleOutputFormatter::class) ->tag('output_formatter'); + $services + ->set(GithubActionsOutputFormatter::class) + ->tag('output_formatter'); $services ->set(GraphVizOutputFormatter::class) ->tag('output_formatter'); From 0782d9ff1b4a4189f8a93698a22a9cb695dcd76f Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 16:44:48 +0200 Subject: [PATCH 11/13] Make FQN expectations explicit in Test --- .../OutputFormatter/GithubActionsOutputFormatterTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index 5f3eaec2e..bcbbc4160 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -43,8 +43,8 @@ public function testFinish(array $rules, string $expectedOutput): void public function finishProvider() { - $originalA = ClassLikeName::fromFQCN('OriginalA'); - $originalB = ClassLikeName::fromFQCN('OriginalB'); + $originalA = ClassLikeName::fromFQCN('\ACME\OriginalA'); + $originalB = ClassLikeName::fromFQCN('\ACME\OriginalB'); yield 'No Rules, No Output' => [ [], @@ -59,7 +59,7 @@ public function finishProvider() 'LayerB' ), ], - "::error file=originalA.php,line=12::OriginalA must not depend on OriginalB (LayerA on LayerB)\n", + "::error file=originalA.php,line=12::ACME\OriginalA must not depend on ACME\OriginalB (LayerA on LayerB)\n", ]; yield 'Skipped Violation' => [ @@ -70,7 +70,7 @@ public function finishProvider() 'LayerB' ), ], - "::warning file=originalA.php,line=12::[SKIPPED] OriginalA must not depend on OriginalB (LayerA on LayerB)\n", + "::warning file=originalA.php,line=12::[SKIPPED] ACME\OriginalA must not depend on ACME\OriginalB (LayerA on LayerB)\n", ]; } } From 844b5b8e1dc26843d1b65e9120d58040d2b6e23e Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 16:50:15 +0200 Subject: [PATCH 12/13] Output only file name instead of absolute path --- src/OutputFormatter/GithubActionsOutputFormatter.php | 2 +- .../GithubActionsOutputFormatterTest.php | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/OutputFormatter/GithubActionsOutputFormatter.php b/src/OutputFormatter/GithubActionsOutputFormatter.php index 022ad7b8b..faf849e9b 100644 --- a/src/OutputFormatter/GithubActionsOutputFormatter.php +++ b/src/OutputFormatter/GithubActionsOutputFormatter.php @@ -45,7 +45,7 @@ public function finish(Context $context, OutputInterface $output, OutputFormatte $output->writeln(sprintf( '::%s file=%s,line=%s::%s%s must not depend on %s (%s on %s)', $this->determineLogLevel($rule), - $dependency->getFileOccurrence()->getFilepath(), + basename($dependency->getFileOccurrence()->getFilepath()), $dependency->getFileOccurrence()->getLine(), $rule instanceof SkippedViolation ? '[SKIPPED] ' : '', $dependency->getClassLikeNameA()->toString(), diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index bcbbc4160..eb23f6774 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -43,18 +43,19 @@ public function testFinish(array $rules, string $expectedOutput): void public function finishProvider() { - $originalA = ClassLikeName::fromFQCN('\ACME\OriginalA'); - $originalB = ClassLikeName::fromFQCN('\ACME\OriginalB'); - yield 'No Rules, No Output' => [ [], '', ]; + $originalA = ClassLikeName::fromFQCN('\ACME\OriginalA'); + $originalB = ClassLikeName::fromFQCN('\ACME\OriginalB'); + $originalAOccurrence = FileOccurrence::fromFilepath('/home/testuser/originalA.php', 12); + yield 'Simple Violation' => [ [ new Violation( - new Dependency($originalA, $originalB, FileOccurrence::fromFilepath('originalA.php', 12)), + new Dependency($originalA, $originalB, $originalAOccurrence), 'LayerA', 'LayerB' ), @@ -65,7 +66,7 @@ public function finishProvider() yield 'Skipped Violation' => [ [ new SkippedViolation( - new Dependency($originalA, $originalB, FileOccurrence::fromFilepath('originalA.php', 12)), + new Dependency($originalA, $originalB, $originalAOccurrence), 'LayerA', 'LayerB' ), From 2c49aefc9b380f2cffd8d5483d555fc7f3cf220f Mon Sep 17 00:00:00 2001 From: Josh Taylor Date: Thu, 28 May 2020 17:47:34 +0200 Subject: [PATCH 13/13] Show full path to file in annotation --- src/OutputFormatter/GithubActionsOutputFormatter.php | 2 +- tests/OutputFormatter/GithubActionsOutputFormatterTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/OutputFormatter/GithubActionsOutputFormatter.php b/src/OutputFormatter/GithubActionsOutputFormatter.php index faf849e9b..022ad7b8b 100644 --- a/src/OutputFormatter/GithubActionsOutputFormatter.php +++ b/src/OutputFormatter/GithubActionsOutputFormatter.php @@ -45,7 +45,7 @@ public function finish(Context $context, OutputInterface $output, OutputFormatte $output->writeln(sprintf( '::%s file=%s,line=%s::%s%s must not depend on %s (%s on %s)', $this->determineLogLevel($rule), - basename($dependency->getFileOccurrence()->getFilepath()), + $dependency->getFileOccurrence()->getFilepath(), $dependency->getFileOccurrence()->getLine(), $rule instanceof SkippedViolation ? '[SKIPPED] ' : '', $dependency->getClassLikeNameA()->toString(), diff --git a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php index eb23f6774..c2f8786ac 100644 --- a/tests/OutputFormatter/GithubActionsOutputFormatterTest.php +++ b/tests/OutputFormatter/GithubActionsOutputFormatterTest.php @@ -60,7 +60,7 @@ public function finishProvider() 'LayerB' ), ], - "::error file=originalA.php,line=12::ACME\OriginalA must not depend on ACME\OriginalB (LayerA on LayerB)\n", + "::error file=/home/testuser/originalA.php,line=12::ACME\OriginalA must not depend on ACME\OriginalB (LayerA on LayerB)\n", ]; yield 'Skipped Violation' => [ @@ -71,7 +71,7 @@ public function finishProvider() 'LayerB' ), ], - "::warning file=originalA.php,line=12::[SKIPPED] ACME\OriginalA must not depend on ACME\OriginalB (LayerA on LayerB)\n", + "::warning file=/home/testuser/originalA.php,line=12::[SKIPPED] ACME\OriginalA must not depend on ACME\OriginalB (LayerA on LayerB)\n", ]; } }