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

Feature: Mutant filters #4463

Open
nicojs opened this issue Oct 3, 2023 · 0 comments
Open

Feature: Mutant filters #4463

nicojs opened this issue Oct 3, 2023 · 0 comments
Labels
🚀 Feature request New feature request hacktoberfest https://hacktoberfest.digitalocean.com/

Comments

@nicojs
Copy link
Member

nicojs commented Oct 3, 2023

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

We want to add a mutator that removes statements or expressions. I.e. #3916

-resource.dispose();
+ // 👽

However, this would result in many additional mutants without real value since another mutant already covered the statement. For example, we wouldn't want to remove this statement:

- const result = foo + bar;
+ const result = foo - bar; // 👽

Describe the solution you'd like

We would like to be able to filter mutants using a MutantFilter, like is implemented in Stryker.NET: https://github.com/stryker-mutator/stryker-net/blob/master/src/Stryker.Core/Stryker.Core/MutantFilters/IgnoreBlockMutantFilter.cs#L10

Note: we shouldn't mark filtered-out mutants as 'ignored'; they should not exist in your report.

A valid approach might be to add an optional filter method on the mutator API, that, when implemented, indicated whether or not the mutant is valid.

export interface NodeMutator {
  mutate(path: NodePath): Iterable<types.Node>;
+ filter?(mutableInScope: Mutable[]): boolean;
  readonly name: string;
}

Describe alternatives you've considered

Keep like it is now, with a lot of noise when implementing the statement mutator.

Additional context

0

@nicojs nicojs added the 🚀 Feature request New feature request label Oct 3, 2023
@nicojs nicojs added the hacktoberfest https://hacktoberfest.digitalocean.com/ label Oct 3, 2023
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

No branches or pull requests

1 participant