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 ExplicitArgumentEnumeration check #985

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Stephan202
Copy link
Member

@Stephan202 Stephan202 commented Jan 21, 2024

Suggested commit message:

Introduce `ExplicitArgumentEnumeration` check (#985)

I found this on an old branch from early last year. Extended it a bit and now putting it up for review. Perhaps we can find a better name. Likely this code should also be tested against the internal code base before landing. But it's certainly ready for review.

@Stephan202 Stephan202 added this to the 0.15.0 milestone Jan 21, 2024
Copy link

  • Surviving mutants in this change: 9
  • Killed mutants in this change: 37
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 9 37

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link

  • Surviving mutants in this change: 10
  • Killed mutants in this change: 38
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 10 38

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Member Author

@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.

(I see there a more mutants to be handled; will review in the ~coming days.)

Comment on lines 196 to 199
// XXX: Once we target JDK 14+, drop this method in favour of `Symbol#isPublic()`.
private static boolean isPublic(Symbol symbol) {
return symbol.getModifiers().contains(Modifier.PUBLIC);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Also present in #972, but a separate utility method doesn't seem worth it. (Or we can just drop JDK 11 support 🙃.)

@rickie rickie modified the milestones: 0.15.0, 0.16.0 Feb 10, 2024
@Stephan202 Stephan202 force-pushed the sschroevers/prefer-varargs-alternatives branch from d3877c5 to a74fd35 Compare February 10, 2024 15:29
Copy link

  • Surviving mutants in this change: 10
  • Killed mutants in this change: 38
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 10 38

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 force-pushed the sschroevers/prefer-varargs-alternatives branch from a74fd35 to 9e7ac68 Compare February 11, 2024 15:15
Copy link

  • Surviving mutants in this change: 10
  • Killed mutants in this change: 38
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 10 38

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@Stephan202 Stephan202 force-pushed the sschroevers/prefer-varargs-alternatives branch from 9e7ac68 to 714713b Compare February 11, 2024 20:15
Copy link
Member Author

@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.

Rebased and added a commit with some improvements. I think this is now properly ready for review.

Comment on lines 104 to 109
if (tree.getArguments().size() != 1) {
return Description.NO_MATCH;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Pitest reports that this if-statement can be mutated away. That's correct: it's a performance optimization. While we haven't done so in the past, it may be good to start documenting such cases. Will do for this case.

Comment on lines +125 to +132
private static boolean isUnaryIterableAcceptingMethod(MethodSymbol method, VisitorState state) {
List<VarSymbol> params = method.params();
return !method.isVarArgs()
&& params.size() == 1
&& ASTHelpers.isSubtype(params.get(0).type, state.getSymtab().iterableType, state);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Pitest flags that the params.size() == 1 can be mutated away. This is true thanks to the initial tree.getArguments().size() != 1 check, but it doesn't seem right to drop this condition; it makes the code less clear, IMHO.

Copy link

sonarcloud bot commented Feb 11, 2024

Copy link

  • Surviving mutants in this change: 2
  • Killed mutants in this change: 39
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 2 39

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie modified the milestones: 0.16.0, 0.17.0 Mar 8, 2024
@Stephan202 Stephan202 force-pushed the sschroevers/prefer-varargs-alternatives branch from 714713b to 6ae584f Compare March 17, 2024 10:00
Copy link

sonarcloud bot commented Mar 17, 2024

Copy link

  • Surviving mutants in this change: 2
  • Killed mutants in this change: 39
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 2 39

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

1 similar comment
Copy link

  • Surviving mutants in this change: 2
  • Killed mutants in this change: 39
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ExplicitArgumentEnumeration 2 39

Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants