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

fix(instrumentor): Do not run the arithmetic operator mutator on obvious string concatenations #2648

Merged
merged 4 commits into from Dec 8, 2020

Conversation

Garethp
Copy link
Contributor

@Garethp Garethp commented Dec 7, 2020

As discussed in #2646, this is a shallow "Best-effort" approach to not mutating obvious string concatenations

@Garethp Garethp requested a review from nicojs December 7, 2020 17:15
return false;
}

const stringTypes = ['StringLiteral', 'TemplateLiteral'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On further thought, this should probably be a whitelist not a blacklist. It's a bit weird, but something like:

const log = (thingToLog) => console.log(thingToLog);
const concat = 1 + log;
console.log(concat)

Will result in "1(thingToLog) => console.log(thingToLog)". What do you think @nicojs, should we do a whitelist of things that actually make sense for an ArithmeticOperator, or keep it simple and only make exceptions for strings and template strings?

Copy link
Member

Choose a reason for hiding this comment

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

I think a whitelist can become big and hard(er) to maintain. I personally think this is fine to start with. It's better than what we have now.

@nicojs nicojs changed the title bug(instrumentor): Do not run the arithmetic operator mutator on obvious string concatenations fix(instrumentor): Do not run the arithmetic operator mutator on obvious string concatenations Dec 8, 2020
Copy link
Member

@nicojs nicojs left a comment

Choose a reason for hiding this comment

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

LGTM.

@Garethp Garethp merged commit 896bc7b into stryker-mutator:master Dec 8, 2020
@Garethp Garethp deleted the string-concatenationfix branch December 8, 2020 20:31
nicojs pushed a commit that referenced this pull request Dec 9, 2020
Don't mutate `"a" + "b"` into `"a" - "b"`. This only works for 'obvious'
string concats.
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

2 participants