Skip to content

Commit

Permalink
Merge pull request #634 from JTubex/phpcs-exclude
Browse files Browse the repository at this point in the history
Implement the Phpcs exclude option
  • Loading branch information
Landerstraeten authored May 16, 2019
2 parents 20923ea + 744b8c9 commit d90d5a2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions doc/tasks/phpcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ parameters:
ignore_patterns: []
sniffs: []
triggered_by: [php]
exclude: []

```
Expand Down Expand Up @@ -123,6 +124,12 @@ This is a list of sniffs that need to be executed. Leave this option blank to ru

This is a list of extensions to be sniffed.

**exclude**

*Default: []*

A list of rules that should not be checked. Leave this option blank to run all configured rules for the selected standard.

## Framework presets

### Symfony 2
Expand Down
1 change: 1 addition & 0 deletions spec/Task/PhpcsSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function it_should_have_configurable_options()
$options->getDefinedOptions()->shouldContain('ignore_patterns');
$options->getDefinedOptions()->shouldContain('sniffs');
$options->getDefinedOptions()->shouldContain('triggered_by');
$options->getDefinedOptions()->shouldContain('exclude');
}

function it_should_run_in_git_pre_commit_context(GitPreCommitContext $context)
Expand Down
3 changes: 3 additions & 0 deletions src/Task/Phpcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function getConfigurableOptions(): OptionsResolver
'triggered_by' => ['php'],
'report' => 'full',
'report_width' => null,
'exclude' => [],
]);

$resolver->addAllowedTypes('standard', ['array', 'null', 'string']);
Expand All @@ -50,6 +51,7 @@ public function getConfigurableOptions(): OptionsResolver
$resolver->addAllowedTypes('triggered_by', ['array']);
$resolver->addAllowedTypes('report', ['null', 'string']);
$resolver->addAllowedTypes('report_width', ['null', 'int']);
$resolver->addAllowedTypes('exclude', ['array']);

return $resolver;
}
Expand Down Expand Up @@ -117,6 +119,7 @@ protected function addArgumentsFromConfig(
$arguments->addOptionalIntegerArgument('--warning-severity=%s', $config['warning_severity']);
$arguments->addOptionalCommaSeparatedArgument('--sniffs=%s', $config['sniffs']);
$arguments->addOptionalCommaSeparatedArgument('--ignore=%s', $config['ignore_patterns']);
$arguments->addOptionalCommaSeparatedArgument('--exclude=%s', $config['exclude']);

return $arguments;
}
Expand Down

0 comments on commit d90d5a2

Please sign in to comment.