Skip to content

Commit

Permalink
Revert "Adding Line Numbers To Mutator Ignore List (#663)"
Browse files Browse the repository at this point in the history
This reverts commit 334983e.
  • Loading branch information
maks-rafalko committed Mar 25, 2019
1 parent 9fe8bf0 commit 4216c82
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 26 deletions.
7 changes: 0 additions & 7 deletions infection.json.dist
Expand Up @@ -10,12 +10,5 @@
"badge": {
"branch": "master"
}
},
"mutators": {
"MethodCallRemoval": {
"ignore": [
"Infection\\Finder\\SourceFilesFinder::__construct::63"
]
}
}
}
6 changes: 1 addition & 5 deletions src/Mutator/Util/Mutator.php
Expand Up @@ -67,11 +67,7 @@ final public function shouldMutate(Node $node): bool
return true;
}

return !$this->config->isIgnored(
$reflectionClass->getName(),
$node->getAttribute(ReflectionVisitor::FUNCTION_NAME, ''),
$node->getLine()
);
return !$this->config->isIgnored($reflectionClass->getName(), $node->getAttribute(ReflectionVisitor::FUNCTION_NAME, ''));
}

final public static function getName(): string
Expand Down
7 changes: 2 additions & 5 deletions src/Mutator/Util/MutatorConfig.php
Expand Up @@ -56,7 +56,7 @@ public function __construct(array $config)
$this->mutatorSettings = $config['settings'] ?? [];
}

public function isIgnored(string $class, string $method, int $lineNumber = null): bool
public function isIgnored(string $class, string $method): bool
{
if (\in_array($class, $this->ignoreConfig)) {
return true;
Expand All @@ -67,10 +67,7 @@ public function isIgnored(string $class, string $method, int $lineNumber = null)
}

foreach ($this->ignoreConfig as $ignorePattern) {
if (fnmatch($ignorePattern, $class, FNM_NOESCAPE)
|| fnmatch($ignorePattern, $class . '::' . $method, FNM_NOESCAPE)
|| ($lineNumber !== null && fnmatch($ignorePattern, $class . '::' . $method . '::' . $lineNumber, FNM_NOESCAPE))
) {
if (fnmatch($ignorePattern, $class, FNM_NOESCAPE) || fnmatch($ignorePattern, $class . '::' . $method, FNM_NOESCAPE)) {
return true;
}
}
Expand Down
11 changes: 2 additions & 9 deletions tests/Mutator/Util/MutatorConfigTest.php
Expand Up @@ -46,11 +46,11 @@ final class MutatorConfigTest extends TestCase
/**
* @dataProvider providesIgnoredValues
*/
public function test_is_ignored_returns_true_if_there_is_a_match(array $ignored, string $class, string $method, int $lineNumber = null): void
public function test_is_ignored_returns_true_if_there_is_a_match(array $ignored, string $class, string $method): void
{
$config = new MutatorConfig(['ignore' => $ignored]);

$this->assertTrue($config->isIgnored($class, $method, $lineNumber));
$this->assertTrue($config->isIgnored($class, $method));
}

public function providesIgnoredValues(): \Generator
Expand Down Expand Up @@ -90,13 +90,6 @@ public function providesIgnoredValues(): \Generator
'Foo\Bar\Test',
'method',
];

yield 'It ignores a specific line number' => [
['Foo\Bar\Test::method::63'],
'Foo\Bar\Test',
'method',
63,
];
}

/**
Expand Down

0 comments on commit 4216c82

Please sign in to comment.