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

Allow users to ignore mutants based on heuristics #3229

Closed
nicojs opened this issue Oct 26, 2021 · 3 comments · Fixed by #4487
Closed

Allow users to ignore mutants based on heuristics #3229

nicojs opened this issue Oct 26, 2021 · 3 comments · Fixed by #4487
Assignees
Labels
🚀 Feature request New feature request hacktoberfest https://hacktoberfest.digitalocean.com/

Comments

@nicojs
Copy link
Member

nicojs commented Oct 26, 2021

Is your feature request related to a problem? Please describe.

We have had a couple of requests in the past to allow to ignore specific mutants:

#2966 #1174 #1470 #1464

Some of these issues have been solved by allowing users to ignore using a comment, however, this isn't always practical.

For large codebases where you want to ignore the same pattern every time. For example: console.log().

Or you want to ignore mutants based on some other data, for example using the result of a git command, like the git checker seems to be doing.

Describe the solution you'd like

I would like to be able to ignore specific mutants based on heuristics (for lack of a better word). It would be run inside the instrumenter on each AST node visitation. It could then decide to ignore the current node with a reason.

The API could look like this

interface Ignorer {
  shouldIgnore(path: NodePath): string | void;  
}

We should document some examples for common use cases, like ignoring console.log statements. Issue #3230 needs to be solved to allow for locally defined plugins.

Describe alternatives you've considered

There are a number of issues linked where users thought of different approaches. However, I think this abstraction makes the most sense. It allows for the most freedom.

Additional context

All current plugin APIs are located inside the @stryker-mutator/api package. I want this to be no exception. However, the NodePath interface comes from @babel/core. I don't want that to be part of the dependencies of the API package. So we might want to mark it as a dev dependency 🤷‍♀️

@nicojs nicojs added 🚀 Feature request New feature request hacktoberfest https://hacktoberfest.digitalocean.com/ labels Oct 26, 2021
@nicojs
Copy link
Member Author

nicojs commented Oct 26, 2021

Note: we currently already have some arbitrary ignore rules configured in the babel-transformer. A good approach might be to abstract those away in Ignore plugins as well. It's a good test for the versatility of this plugin kind.

@stale
Copy link

stale bot commented Nov 7, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the ☠ stale Marked as stale by the stale bot, will be removed after a certain time. label Nov 7, 2022
@stale stale bot closed this as completed Dec 11, 2022
@nicojs nicojs reopened this Feb 17, 2023
@stale stale bot removed the ☠ stale Marked as stale by the stale bot, will be removed after a certain time. label Feb 17, 2023
@odinvanderlinden odinvanderlinden self-assigned this Oct 14, 2023
@nicojs
Copy link
Member Author

nicojs commented Oct 17, 2023

Ignore-plugins are released in StrykerJS 7.3 🎉

https://twitter.com/stryker_mutator/status/1713557660832792870

https://stryker-mutator.io/docs/stryker-js/disable-mutants/#using-an-ignore-plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 Feature request New feature request hacktoberfest https://hacktoberfest.digitalocean.com/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants