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

Force Mutators to include remedies #1907

Closed

Conversation

ttomdewit
Copy link

This PR:

In order to improve the developer experience this PR forces Mutators to include remedies in their definitions.

In order to improve the developer experience this PR
forces Mutators to include remedies in their definitions.
Copy link
Member

@theofidry theofidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the infection team that was not part of the Discord conversation: the goal is to document the remedies which can later be used to point the user how to address some escaped mutations. To avoid pushing all remedies at once out of fear to end up with "low quality ones just for the sake of having it", this PR can introduce the requirement, and the remedies be fixed over time in separate PRs.

tests/phpunit/Mutator/DefinitionTest.php Outdated Show resolved Hide resolved
tests/phpunit/Mutator/DefinitionTest.php Outdated Show resolved Hide resolved

public function mutatorsProvider(): iterable
{
$mutatorFactory = SingletonContainer::getContainer()->getMutatorFactory();
Copy link
Author

@ttomdewit ttomdewit Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this inline call to the container is because providers run before setUp methods, in which case a call to something like $this->mutatorFactory would be null.

@theofidry
Copy link
Member

@infection/core are you fine with the idea? If so I would rebase it

@maks-rafalko
Copy link
Member

maks-rafalko commented Apr 8, 2024

If the idea is to ultimately have all the remedies, then absolutely yes.

Just today I was discussing with @Wirone this ticket (in context of his question about not always understanding how to kill mutants). Is it a coinsidence? :)

Also, as a followup for this ticket: we can add links (or inline explanations) on how to kill mutant to our GitHub annotations, so contributor will better understand what to fix when mutant is escaped. I like how Psalm adds short links to the output with found issues, and you can open it and read explanations. This is something I would like to have for Infection too (probably integrated with Playground to show "killing tests" there).

@Wirone
Copy link

Wirone commented Apr 8, 2024

Just today I was discussing with @Wirone this ticket (in context of his question about not always understanding how to kill mutants). Is it a coinsidence? :)

No, it's not a coincidence, after our conversation I asked @ttomdewit what's the state of this, it seems like it sparked some reaction 🙂.

@ttomdewit
Copy link
Author

Just today I was discussing with @Wirone this ticket (in context of his question about not always understanding how to kill mutants). Is it a coinsidence? :)

No, it's not a coincidence, after our conversation I asked @ttomdewit what's the state of this, it seems like it sparked some reaction 🙂.

It did indeed! @theofidry and I chatted a bit in DM over Discord!

Let me know if I need to do anything to get this in, and probably no sooner than June I will look into documenting mutants one PR at a time (no promises at the moment, not doing very well mentally).

@theofidry
Copy link
Member

theofidry commented Apr 8, 2024

I like how Psalm adds short links to the output with found issues, and you can open it and read explanations. This is something I would like to have for Infection too (probably integrated with Playground to show "killing tests" there).

From seeing fast evolving docs from Rector, that did that approach, I have mixed feelings about it.

Ideally, this would be done with the links bound to the released version, and the doc is versioned too. For example if you had the following code:

<<<REMEMDY

Short explanation.

See more at https://docs.infection.com/remedies/<mutant-name>

REMEDY;

When building infection, you would have the shipped code updated to point to a specific version:

<<<REMEMDY

Short explanation.

See more at https://docs.infection.com/v0.18/remedies/<mutant-name>

REMEDY;

And when accessing the docs you could easily jump from a version to another. Also note that the version the code is bound to would be the matching minor version to allow us to update the docs still.

But I think this would be quite a lot of work... So meanwhile I guess even if the remedy description is a bit lengthy it is fine. Or we have to live with the fact that it points to the latest updated doc which will be updated hence if using an old version of infection it may have dead links.

theofidry added a commit that referenced this pull request Apr 12, 2024
This PR is a rebased version of #1907.

It currently skips all but one mutator to set a baseline. Existing mutators should no longer be skipped in the future and this check ensures that new mutators will require a remedy to be documented.

There is more to do with remedies to, for example some ideas of #1907 (comment), but I think it is vastly out of scope of this PR and should be considered at a later time.

Closes #1907.

---------

Co-authored-by: Tom de Wit <tdewit@gainsight.com>
@ttomdewit ttomdewit deleted the force-mutators-to-include-remedies branch April 12, 2024 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants