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

Supply suggestions to ignored directives referencing unknown Mutators #3844

Closed
Giovds opened this issue Nov 5, 2022 · 2 comments
Closed
Labels
🚀 Feature request New feature request

Comments

@Giovds
Copy link
Contributor

Giovds commented Nov 5, 2022

Is your feature request related to a problem? Please describe.
As pointed out in #3812 it would be cool if we could get a suggestion if an unused directive with a unknown Mutator has a close match to an existing Mutator.

Describe the solution you'd like
Let's keep the same example as in the original issue.

const compare = (a, b) => {
  // Stryker disable next-line Equality: Wrong Mutator name
  return a - b >= 0 ? 1 : -1;
}

module.exports = { compare };

Perhaps we can check if the unknown Mutator partly matches with an existing one and/or implement some sort of fuzziness when typo's are made. This way we can create suggestions for the user, instead of just warning them what directives where not used.

Example for the CLI:

[Ignored] Equality
sum.js:2:1
- // Stryker disable next-line Equality: Hard to test
+ // Stryker disable next-line EqualityOperator: Hard to test

Or use a ~ and/or make the addition another colour (yellow e.g.), since we are not entirely sure this suggestion is correct.

This way the HTML view, and other reporters, can also benefit from this and show the same suggestions. You might even be able to share code between mutation-testing-elements (or mutation-testing-metrics) and Stryker.

Html could show something like this when you click on the ignored mutator:

image
(I've just edited the HTML on a local page for example purposes)

Describe alternatives you've considered
-

Additional context
Might depend on #3813

@Giovds Giovds added the 🚀 Feature request New feature request label Nov 5, 2022
@nicojs
Copy link
Member

nicojs commented Nov 9, 2022

I'm sorry for the misunderstanding, but I thought it would be cool to enable bg coloring for mutant diffs, the way the HTML report does it. I did some experiments, and this was the best result I got:

image

Code:

import chalk from 'chalk';

console.log('[NoCoverage] StringLiteral');
console.log(`${chalk.cyanBright('src/platform.ts')}:${chalk.yellowBright(8)}:${chalk.yellowBright(32)}`);
console.log(`${chalk.red.dim("-       return process.platform != ")}${chalk.bgRed.dim.redBright("'win32'")}${chalk.red.dim('")')}`);
console.log(`${chalk.green.dim('+       return process.platform != ')}${chalk.bgGreen.dim.greenBright('""')}${chalk.green.dim(';')}`);

Not better readable so perhaps not 🤷‍♀️.

I don't feel much for adding these to the HTML report and console reporter ATM. I think the warning you're implementing in #3842 will be sufficient.

@Giovds
Copy link
Contributor Author

Giovds commented Nov 9, 2022

Ah that was a misunderstanding indeed :). Seems cool though! In that case this feature request is invalid.

@Giovds Giovds closed this as completed Feb 22, 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
Projects
None yet
Development

No branches or pull requests

2 participants