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

[BEAM-4303] Enforce ErrorProne analysis in examples project #5521

Merged
merged 1 commit into from Jun 1, 2018

Conversation

cademarkegard
Copy link
Contributor

  • Enforces the ErrorProne analysis on examples project
  • Fixes the issues in order to enable failOnWarning

@iemejia iemejia self-requested a review May 31, 2018 07:53
@iemejia
Copy link
Member

iemejia commented May 31, 2018

R: @swegner @iemejia

@iemejia
Copy link
Member

iemejia commented May 31, 2018

@swegner is there a way to mark ignores at the module level ?
I think we should use that only in this case StringSplitter

We should not expose guava's Splitter in the most basic examples, e.g. Wordcount/WindowedWordcount (because those are commonly copy pasted) and using the @SuppressWarnings("StringSplitter") also does not seem natural for a baginner example too so better do it at the module level.

@cademarkegard
Copy link
Contributor Author

Great point. I can update the string splits to have a limit of -1 instead and that will pass ErrorProne then.

@swegner
Copy link
Contributor

swegner commented May 31, 2018

@iemejia currently we have a global set of excludes in the build_rules.gradle applyJavaNature() block. We could add a parameter to the JavaNatureConfiguration such that modules can add their own, but my preference is to avoid that until we really need it.

I agree with making examples simple and avoiding a Guava dependency, but also note that examples tend to get copy-pasted many times, so we should try to avoid known anti-patterns if possible. As @cademarkegard points out, the StringSplitter ErrorProne page also suggests using String.split(String, int) with a limit of -1.

@cademarkegard cademarkegard force-pushed the beam4303/errorprone-examples branch 3 times, most recently from f81bac3 to a450231 Compare May 31, 2018 17:17
if ("timestamp".equals(laneInfo[0])) {
// Header row
return;
}
if (laneInfo.length < 48) {
if (laneInfo.length < 50) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you elaborate on what this change is for? I'm not sure what this magic number represents. If you are familiar, perhaps extract it out as a named constant that provides some context. i.e. const int NUM_FIELDS = 50;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This value change is necessary after changing the c.element().split() to have limit of -1. In the second input data, when we didn't have the limit set, split() would actually truncate the fields following after the last 0 on line 61 resulting in length of 45. After setting the limit, it increased the number of fields to 49 for that input. We still maintained 50 fields for the input that starts on line 59, which textExtractTotalFlow() seems to care about.

Great suggestion on the constant, I'll push up the change with that now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks for the explanation!

@swegner
Copy link
Contributor

swegner commented May 31, 2018

Just one comment above, then everything else LGTM (looks good to me).

@cademarkegard cademarkegard force-pushed the beam4303/errorprone-examples branch 2 times, most recently from b656b88 to 7081b19 Compare June 1, 2018 15:36
@cademarkegard
Copy link
Contributor Author

@iemejia @swegner I've addressed the feedback and the tests pass. Please take a look when you have a chance.

@swegner
Copy link
Contributor

swegner commented Jun 1, 2018

LGTM.

I'll leave it to @iemejia to merge in case he has any other feedback.

@iemejia iemejia merged commit 7545855 into apache:master Jun 1, 2018
@iemejia
Copy link
Member

iemejia commented Jun 1, 2018

LGTM. Thanks @cademarkegard !

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

3 participants