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

[FLINK-6901] Flip checkstyle configuration files #4112

Closed
wants to merge 2 commits into from

Conversation

zentol
Copy link
Contributor

@zentol zentol commented Jun 12, 2017

This PR makes the strict-checkstyle.xml the default checkstyle configuration.

As a first step i made flink-streaming-scala checkstyle compliant (FLINK-6902), because it required few changes and i didn't want to add an exclusion only to remove it again tomorrow.

Making the strict checkstyle the default required a few more changes than i expected. As it stands it is not possible to execute the checkstyle plugin twice in a single build with different configurations. This also implies that currently many parts of flink-runtime aren't even covered by the lenient checkstyle.

So we need a way to both check the lenient for all files, and the strict for a subset in a single run. Given that the strict checkstyle is an extension of the lenient one i instead opted for creating suppression files for each of the non-covered modules, disabling all the new checks added by the strict checkstyle. This didn't work out completely as it still required resolving 2 violations in flink-core, but that's ok i guess.

The suppression files are pretty ugly as they consist of a giant regex checking for every module in a single line, and the same for packages in flink-runtime, but i couldn't find a better solution. Spreading the regex over multiple-lines frustratingly enough doesn't work.

One could resolve this somewhat for flink-runtime by adding a separate suppression for every package, but you would still retain the endless rules regex.

Note that this change implies that every new module is now covered by the strict checkstyle.

@greghogan
Copy link
Contributor

@zentol did you mean to include [FLINK-6902] Activate strict checkstyle for flink-streaming-scala as the first commit?


<suppressions>
<suppress
files=" (.*)runtime/akka/(.*)|(.*)runtime/blob/(.*)|(.*)runtime/broadcast/(.*)|(.*)runtime/checkpoint/(.*)|(.*)runtime/client/(.*)|(.*)runtime/clusterframework/(.*)|(.*)runtime/concurrent/(.*)|(.*)runtime/deployment/(.*)|(.*)runtime/execution/(.*)|(.*)runtime/executiongraph/(.*)|(.*)runtime/fs/(.*)|(.*)runtime/heartbeat/(.*)|(.*)runtime/highavailability/(.*)|(.*)runtime/instance/(.*)|(.*)runtime/io/(.*)|(.*)runtime/iterative/(.*)|(.*)runtime/jobgraph/(.*)|(.*)runtime/jobmanager/(.*)|(.*)runtime/jobmaster/(.*)|(.*)runtime/leaderelection/(.*)|(.*)runtime/memory/(.*)|(.*)runtime/messages/(.*)|(.*)runtime/minicluster/(.*)|(.*)runtime/net/(.*)|(.*)runtime/operators/(.*)|(.*)runtime/plugable/(.*)|(.*)runtime/query/(.*)|(.*)runtime/registration/(.*)|(.*)runtime/resourcemanager/(.*)|(.*)runtime/rpc/(.*)|(.*)runtime/security/(.*)|(.*)runtime/state/(.*)|(.*)runtime/taskexecutor/(.*)|(.*)runtime/taskmanager/(.*)|(.*)runtime/testutils/(.*)|(.*)runtime/util/(.*)|(.*)runtime/zookeeper/(.*)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we duplicate the listing one package per suppress tag to prevent merge conflicts when removing excluded packages?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've split the suppressions by package.

@@ -114,15 +114,17 @@ public boolean next(StringValue target) {
int pos = this.pos;

// skip the delimiter
for (; pos < limit && Character.isWhitespace(data[pos]); pos++);
for (; pos < limit && Character.isWhitespace(data[pos]); pos++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the reason for these two changes in flink-core?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The NeedBraces module was extended with the strict-checkstyle to also apply to do, while and for.

Since i can't selectively disable parts of the module I had to make the changes instead.

@zentol
Copy link
Contributor Author

zentol commented Jun 12, 2017

yes, i intended to include FLINK-6902, as described in the second paragraph of the PR description.

@greghogan
Copy link
Contributor

+1 and my apologies for overlooking your comprehensive description.

@zentol
Copy link
Contributor Author

zentol commented Jun 13, 2017

Looks like the same problem we have in flink-core also exists in flink-runtime, some braces are missing...

[INFO] There are 10 errors reported by Checkstyle 6.19 with /tools/maven/checkstyle.xml ruleset.
[ERROR] src/main/java/org/apache/flink/runtime/broadcast/BroadcastVariableMaterialization.java:[134] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/io/network/netty/NettyBufferPool.java:[25,1] (imports) IllegalImport: Import from illegal package - io.netty.util.internal.PlatformDependent.
[ERROR] src/main/java/org/apache/flink/runtime/iterative/task/AbstractIterativeTask.java:[247] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/operators/AbstractCachedBuildSideJoinDriver.java:[176] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/operators/AbstractOuterJoinDriver.java:[160] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/operators/JoinDriver.java:[222] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/operators/sort/AbstractMergeInnerJoinIterator.java:[68] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/operators/sort/AbstractMergeInnerJoinIterator.java:[69] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/operators/sort/AbstractMergeOuterJoinIterator.java:[92] (blocks) NeedBraces: 'while' construct must use '{}'s.
[ERROR] src/main/java/org/apache/flink/runtime/operators/sort/AbstractMergeOuterJoinIterator.java:[103] (blocks) NeedBraces: 'while' construct must use '{}'s.

@zentol
Copy link
Contributor Author

zentol commented Jun 13, 2017

I've adjusted the suppressions file to properly work on windows (slashes...), and resolves the few issues in flink-runtime.

I'm a bit unsure about the change in the NettyBufferPool, @uce does that look ok to you?

@greghogan
Copy link
Contributor

LGTM on a second look. Don't have any suggestion on NettyBufferPool. @uce?

if (!PlatformDependent.hasUnsafe()) {
try {
Class.forName("sun.misc.Unsafe");
} catch (ClassNotFoundException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

After checking with @StefanRRichter, it seems this check is unnecessary anyway since org.apache.flink.core.memory.MemoryUtils#UNSAFE is getting the class if needed and if not existing, Flink should not start anyway.

Copy link
Contributor

@uce uce Jul 10, 2017

Choose a reason for hiding this comment

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

It's ok with me to remove this check

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