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

[FR] Error-prone check for detecting destructive Conjure builder methods being called in a loop #1862

Open
viktornordling opened this issue Aug 6, 2021 · 0 comments

Comments

@viktornordling
Copy link

viktornordling commented Aug 6, 2021

What happened?

Imagine you have this code:

MyConjureThing.Builder builder = MyConjureThing.builder();
Set<String> myValues = getValues();
for (String myValue : myValues) {
    Map<String, Integer> myMapping = calculateMap(myValue);
    builder.mapping(myMapping);
}
MyConjureThing thing = builder.build();

What this is going to do is leave you with only the myMapping from the last iteration, because instead of:

builder.mapping(myMapping);

you should have written:

builder.putAllMappings(myMapping);

It would be great if we could have an error-prone check to catch this.

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

No branches or pull requests

1 participant