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

Add phpcpd names-exclude option #277

Merged
merged 2 commits into from
Jan 18, 2017
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/phpcpd.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ parameters:
phpcpd:
directory: '.'
exclude: ['vendor']
names_exclude: []
fuzzy: false
min_lines: 5
min_tokens: 70
Expand All @@ -28,6 +29,12 @@ With this parameter you can define which directory you want to run `phpcpd` in (

With this parameter you will be able to exclude one or multiple directories from code analysis (must be relative to `directory`).

**names_exclude**

*Default: []*

With this parameter you will be able to exclude one or multiple files from code analysis (must be relative to `directory`).

**fuzzy**

*Default: false*
Expand Down
1 change: 1 addition & 0 deletions spec/GrumPHP/Task/PhpCpdSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ function it_should_have_configurable_options()
$options->shouldBeAnInstanceOf(OptionsResolver::class);
$options->getDefinedOptions()->shouldContain('directory');
$options->getDefinedOptions()->shouldContain('exclude');
$options->getDefinedOptions()->shouldContain('names_exclude');
$options->getDefinedOptions()->shouldContain('fuzzy');
$options->getDefinedOptions()->shouldContain('min_lines');
$options->getDefinedOptions()->shouldContain('min_tokens');
Expand Down
3 changes: 3 additions & 0 deletions src/GrumPHP/Task/PhpCpd.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function getConfigurableOptions()
$resolver->setDefaults([
'directory' => '.',
'exclude' => ['vendor'],
'names_exclude' => [],
'fuzzy' => false,
'min_lines' => 5,
'min_tokens' => 70,
Expand All @@ -38,6 +39,7 @@ public function getConfigurableOptions()

$resolver->addAllowedTypes('directory', ['string']);
$resolver->addAllowedTypes('exclude', ['array']);
$resolver->addAllowedTypes('names_exclude', ['array']);
$resolver->addAllowedTypes('fuzzy', ['bool']);
$resolver->addAllowedTypes('min_lines', ['int']);
$resolver->addAllowedTypes('min_tokens', ['int']);
Expand Down Expand Up @@ -72,6 +74,7 @@ public function run(ContextInterface $context)
}, $config['triggered_by']);

$arguments->addArgumentArray('--exclude=%s', $config['exclude']);
$arguments->addArgumentArray('--names-exclude=%s', $config['names_exclude']);
$arguments->addRequiredArgument('--min-lines=%u', $config['min_lines']);
$arguments->addRequiredArgument('--min-tokens=%u', $config['min_tokens']);
$arguments->addOptionalCommaSeparatedArgument('--names=%s', $extensions);
Expand Down