Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the Phpcs exclude option #634

Merged
merged 6 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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