Skip to content

Introduce BugChecker for implicit var usage#1763

Open
dskop wants to merge 3 commits intomasterfrom
dskop/WS-6666-no-vars
Open

Introduce BugChecker for implicit var usage#1763
dskop wants to merge 3 commits intomasterfrom
dskop/WS-6666-no-vars

Conversation

@dskop
Copy link
Copy Markdown

@dskop dskop commented Jul 16, 2025

This PR introduces an error-prone pattern to check for implicit var keyword usage.
Examples:

var a = getList(); // should be flagged

var a = "string literal"; // should NOT be flagged because the expression includes literal
var a = (List) getList(); // should NOT be flagged because the expression includes type cast
var a = new Object(); // should NOT be flagged because the expression includes `new` operation
var a = getForType(List.class); // should NOT be flagged because the expression includes .class literal
var a = getList().map(String::new).findAny(); // should NOT be flagged because the expression includes constructor reference
var a = ImmutableList.of(42) // should NOT be flagged because the expression includes static constructor method

@github-actions
Copy link
Copy Markdown

  • Surviving mutants in this change: 7
  • Killed mutants in this change: 23
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ImplicitVarUsage 7 23

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

@dskop dskop force-pushed the dskop/WS-6666-no-vars branch from a27cc02 to bacf7af Compare July 16, 2025 09:19
@rickie
Copy link
Copy Markdown
Member

rickie commented Jul 16, 2025

Nice work @dskop, by running ./apply-error-prone-suggestions.sh we can resolve most of the errors that are pointed out!

Make sure to read the README on how to make sure you can run that :). If you're stuck with it, feel free to DM me on Slack.

@rickie rickie changed the title WS-6666 Implement BugChecker for implicit var usage Introduce BugChecker for implicit var usage Jul 16, 2025
@github-actions
Copy link
Copy Markdown

  • Surviving mutants in this change: 7
  • Killed mutants in this change: 23
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ImplicitVarUsage 7 23

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

@dskop dskop force-pushed the dskop/WS-6666-no-vars branch from 961d22a to 3c567a9 Compare July 16, 2025 09:55
@github-actions
Copy link
Copy Markdown

  • Surviving mutants in this change: 7
  • Killed mutants in this change: 23
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ImplicitVarUsage 7 23

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

@dskop dskop force-pushed the dskop/WS-6666-no-vars branch from 3c567a9 to 879af39 Compare July 16, 2025 11:54
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

  • Surviving mutants in this change: 12
  • Killed mutants in this change: 30
class surviving killed
🧟tech.picnic.errorprone.bugpatterns.ImplicitVarUsage 12 30

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

@rickie
Copy link
Copy Markdown
Member

rickie commented Jul 18, 2025

/integration-test

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.

2 participants