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

False positive: not covered mutant for arrow function #1747

Closed
Bilge opened this issue Nov 2, 2022 · 3 comments
Closed

False positive: not covered mutant for arrow function #1747

Bilge opened this issue Nov 2, 2022 · 3 comments

Comments

@Bilge
Copy link
Contributor

Bilge commented Nov 2, 2022

Question Answer
Infection version 0.26.16
Test Framework version PHPUnit 9.5.26
PHP version PHP 8.1.3
Platform Windows
Github Repo https://github.com/ScriptFUSION/Porter

The following code will generate a not covered mutant.

        $this->clearTransformers()->addTransformers(array_map(
            static fn ($transformer) => clone $transformer,
            $transformers
        ));
Not Covered mutants:
====================

1) C:\Users\Bilge\Documents\PhpstormProjects\Porter\src\Specification\Specification.php:48    [M] CloneRemoval

--- Original
+++ New
@@ @@
     {
         $this->resource = clone $this->resource;
         $transformers = $this->transformers;
-        $this->clearTransformers()->addTransformers(array_map(static fn($transformer) => clone $transformer, $transformers));
+        $this->clearTransformers()->addTransformers(array_map(static fn($transformer) => $transformer, $transformers));
         \is_object($this->context) && ($this->context = clone $this->context);
         isset($this->recoverableExceptionHandler) && ($this->recoverableExceptionHandler = clone $this->recoverableExceptionHandler);

However, this code will not generate a not covered mutant. Note that it is the same code, just expressed with a long-form lambda function instead of a single-line arrow function.

        $this->clearTransformers()->addTransformers(array_map(
            static function ($transformer) {
                return clone $transformer;
            },
            $transformers
        ));

Suffice it to say, removing the clone keyword as claimed by the Infection output to be an not covered mutant, causes the tests to fail in both cases.

@sanmai
Copy link
Member

sanmai commented Nov 3, 2022

Suspected duplicate of #1736

Infection uses coverage reports provided by a testing framework such as PHPUnit. If a report says a certain line isn't covered, that's what we have.

@sanmai
Copy link
Member

sanmai commented Nov 9, 2022

Related to #1750.

@maks-rafalko
Copy link
Member

This should have been fixed in #1750. If not please reopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants