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

Introduce MapGetOrDefault Refaster rule #439

Conversation

benhalasi
Copy link
Contributor

adds rules to fix #431.

Added Rules:

  • prefer map.getOrDefault(k, defaultValue) over requireNonNullElse(map.get(k), defaultValue)

Wrote test inputs and outputs.

Could be a problem that when defaultValue is null, Objects#requireNonNullElse throws a NPE while Map#getOrDefault does not.

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@benhalasi benhalasi changed the title Introduce Map#getOrDefault Refaster rules Introduce Map#getOrDefault Refaster rules (#431) Jan 4, 2023
Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

Tnx for your contribution!

Suggested commit message:

Introduce `MapGetOrDefault` Refaster rule (#439)

Fixes #431.

@github-actions
Copy link

github-actions bot commented Jan 4, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie changed the title Introduce Map#getOrDefault Refaster rules (#431) Introduce Map#getOrDefault Refaster rules Jan 4, 2023
@rickie rickie self-requested a review January 4, 2023 12:44
@benhalasi benhalasi force-pushed the benhalasi/introduce-map_get_or_default-refaster-rules branch from 6415c17 to 7229ade Compare January 5, 2023 13:15
@github-actions
Copy link

github-actions bot commented Jan 5, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie modified the milestones: 0.7.0, 0.8.0 Jan 5, 2023
@rickie rickie force-pushed the benhalasi/introduce-map_get_or_default-refaster-rules branch from 7229ade to 06a7d46 Compare January 5, 2023 16:46
Copy link
Member

@rickie rickie left a comment

Choose a reason for hiding this comment

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

Added a commit and rebased.
Made a tweak to the suggested commit message :).

I'm afraid we should wait a bit more with merging this one. I already started testing the current master on downstream repositories, so would probably be better to include this in next release :).

Thanks for another contribution @benhalasi 🚀 !

@github-actions
Copy link

github-actions bot commented Jan 5, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

1 similar comment
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie force-pushed the benhalasi/introduce-map_get_or_default-refaster-rules branch from 060863e to 6852705 Compare January 6, 2023 13:37
@github-actions
Copy link

github-actions bot commented Jan 6, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie changed the title Introduce Map#getOrDefault Refaster rules Introduce MapGetOrDefault Refaster rule Jan 6, 2023
@rickie rickie merged commit feb9abf into PicnicSupermarket:master Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Rewrite requireNonNullElse(map.get(k), defaultValue) -> map.getOrDefault(k, defaultValue)
3 participants