diff --git a/src/Commands/CheckCommand.php b/src/Commands/CheckCommand.php index 18a4cb2..3574d57 100644 --- a/src/Commands/CheckCommand.php +++ b/src/Commands/CheckCommand.php @@ -32,6 +32,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int '--standard=' . $input->getOption('ruleset'), ], $this->helper->wrapPaths($input->getArgument('paths'))); + if ($input->hasOption('ignore')) { + $_SERVER['argv'][] = '--ignore=' . $input->getOption('ignore'); + } + $runner = new Runner(); $exitCode = $runner->runPHPCS(); @@ -52,6 +56,12 @@ protected function configure() InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Enumerate directories or files to check' ) + ->addOption( + 'ignore', + 'i', + InputArgument::OPTIONAL, + 'A comma separated list of patterns to ignore files and directories' + ) ->addOption( 'ruleset', 'r', diff --git a/src/Commands/FixCommand.php b/src/Commands/FixCommand.php index 4517d4e..583c1fc 100644 --- a/src/Commands/FixCommand.php +++ b/src/Commands/FixCommand.php @@ -73,7 +73,7 @@ protected function configure() ->addArgument( 'paths', InputArgument::IS_ARRAY | InputArgument::REQUIRED, - 'Enumerate directories or files to check' + 'Enumerate directories or files to fix' ) ->addOption( 'config', diff --git a/tests/CodeStyle/CodeStyleCheckTest.php b/tests/CodeStyle/CodeStyleCheckTest.php index 2774c32..c0cd637 100644 --- a/tests/CodeStyle/CodeStyleCheckTest.php +++ b/tests/CodeStyle/CodeStyleCheckTest.php @@ -27,7 +27,6 @@ public function testWrongFormattedClass(): void public function testWellFormattedClass(): void { - $out = $this->execCommand([ 'bin/spiral-cs', 'check', @@ -37,4 +36,17 @@ public function testWellFormattedClass(): void $this->assertArrayHasKey(0, $out); $this->assertEquals($out[0], 'No codestyle issues'); } + + public function testIgnoredFilesShouldBeSkipped() + { + $out = $this->execCommand([ + 'bin/spiral-cs', + 'check', + '--ignore=NotFormattedClass.php', + 'tests/fixtures/temp/' + ]); + + $this->assertArrayHasKey(0, $out); + $this->assertEquals($out[0], 'No codestyle issues'); + } }