Skip to content

Commit

Permalink
Merge pull request #4 from butschster/feature/custom-config
Browse files Browse the repository at this point in the history
Added ability to ignore patch to check CS
  • Loading branch information
butschster committed Jan 30, 2023
2 parents d6bb1f7 + ffedce6 commit d8bd32e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/Commands/CheckCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/FixCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 13 additions & 1 deletion tests/CodeStyle/CodeStyleCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function testWrongFormattedClass(): void

public function testWellFormattedClass(): void
{

$out = $this->execCommand([
'bin/spiral-cs',
'check',
Expand All @@ -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');
}
}

0 comments on commit d8bd32e

Please sign in to comment.