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

[SPARK-13583][CORE][STREAMING] Remove unused imports and add checkstyle rule #11438

Closed
wants to merge 4 commits into from
Closed

[SPARK-13583][CORE][STREAMING] Remove unused imports and add checkstyle rule #11438

wants to merge 4 commits into from

Conversation

dongjoon-hyun
Copy link
Member

What changes were proposed in this pull request?

After SPARK-6990, dev/lint-java keeps Java code healthy and helps PR review by saving much time.
This issue aims remove unused imports from Java/Scala code and add UnusedImports checkstyle rule to help developers.

How was this patch tested?

./dev/lint-java
./build/sbt compile

@srowen
Copy link
Member

srowen commented Feb 29, 2016

I'm OK with this. Can we enforce this in Scala too?

Since we've bothered to fail the build if imports aren't in the right order I think it's reasonable to enforce removal of unused imports everywhere too.

@dongjoon-hyun I think you could add that too if you feel so inclined. If you're busy I might add it to https://issues.apache.org/jira/browse/SPARK-13423 but I like your focused PR here.

@srowen
Copy link
Member

srowen commented Feb 29, 2016

Jenkins, test this please

@dongjoon-hyun
Copy link
Member Author

Thank you, @srowen !
Up to know, I'm not sure about enforcing Scala Imports but I'll check that, too.
I'll leave a message soon.

By the way, your SPARK-13423 looks great.

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
Surprisingly, according to the ScalaStyle Ruleset , it seems that we can not do that for Scala as of today. I think it's strange, do you think is there any other ways to do that?

@zsxwing
Copy link
Member

zsxwing commented Mar 1, 2016

FYI because mvn checkstyle:check depends on mvn install which cost huge time for sbt, java style checker is disabled now: https://github.com/apache/spark/blob/master/dev/run-tests.py#L546

@dongjoon-hyun
Copy link
Member Author

Oh, thank you for informing that, @zsxwing .

By the way, dev\lint-java does not depend on mvn install. I think It depends on compiled classes.
You can do that by the following. How do you think of that, @zsxwing ? Is there any way to re-enable that?

$ ./build/sbt compile
$ # Add "<module name="UnusedImports"/>" into checkstyle.xml.
$ time ./dev/lint-java
...
real    0m14.880s
user    0m35.663s
sys 0m1.741s

@dongjoon-hyun
Copy link
Member Author

@srowen , for the scala code, should we take advantage of -Ywarn-unused-import option for that in some way?

@zsxwing
Copy link
Member

zsxwing commented Mar 1, 2016

@dongjoon-hyun I mean lint-java will fail on a clean machine without maven cache. It will fail to resolve the snapshot jars which don't exist before running mvn install.

@dongjoon-hyun
Copy link
Member Author

Oh, I see. Then, this PR will not enforce automatically, just helps developers to check before pushing PR.

Thank you, @zsxwing !

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
I've tested more, but found that -Ywarn-unused-import option is also not reliable yet in Scala 2.11.7.
Please refer https://issues.scala-lang.org/browse/SI-9616 .
I think I can not handle Scala part in this PR.
Sorry about that.

@SparkQA
Copy link

SparkQA commented Mar 1, 2016

Test build #52203 has finished for PR 11438 at commit 5e82490.

  • This patch fails from timeout after a configured wait of 250m.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

It seems that Jenkins fails due to irrelevant things like the following.

Error instrumenting class:org.apache.spark.mllib.regression.IsotonicRegressionModel$SaveLoadV1_0$
...

Other PRs' test fail with similar logs. Should we wait for a while and re-trigger to test?

@dongjoon-hyun
Copy link
Member Author

Rebased to trigger the Jenkins test.

@srowen
Copy link
Member

srowen commented Mar 1, 2016

If you're willing, I think you're welcome to also remove unused Scala imports, even if you can't enforce it. IDEs can make this easy.

Yes the test failure looks unrelated.

@srowen
Copy link
Member

srowen commented Mar 1, 2016

Jenkins, retest this please

@SparkQA
Copy link

SparkQA commented Mar 1, 2016

Test build #52233 has finished for PR 11438 at commit 93b50e2.

  • This patch fails from timeout after a configured wait of 250m.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Thank you for the testing, @srowen . Unfortunately, it still fails.
For the Scala Unused Imports, I see what you mean.
Then, I'll update Jira issue and remove them in this PR, too.
Thank you again.

@zsxwing
Copy link
Member

zsxwing commented Mar 1, 2016

ok to test

@dongjoon-hyun
Copy link
Member Author

Thank you, @zsxwing !

@SparkQA
Copy link

SparkQA commented Mar 2, 2016

Test build #52254 has finished for PR 11438 at commit 93b50e2.

  • This patch fails from timeout after a configured wait of 250m.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Hi, @srowen .
The unused imports in Scala code are removed, too.

@dongjoon-hyun
Copy link
Member Author

I've compared the Jenkins logs. My PR hangs at the following test.

[info] WithAggregationKinesisBackedBlockRDDSuite:
Using endpoint URL https://kinesis.us-west-2.amazonaws.com for creating Kinesis streams for tests.
[2016-03-01 13:06:10.815940] [0x00007fbb51998700] [info] [kinesis_producer.cc:79] Created pipeline for stream 

Other PR passing this test looks like the following.

[info] WithAggregationKinesisBackedBlockRDDSuite:
[info] - Basic reading from Kinesis [enable by setting env var ENABLE_KINESIS_TESTS=1] !!! IGNORED !!!
[info] - Read data available in both block manager and Kinesis [enable by setting env var ENABLE_KINESIS_TESTS=1] !!! IGNORED !!!

Up to now, I cannot figure out how to make this PR pass the Jenkins. Could you give me some clue?

@srowen
Copy link
Member

srowen commented Mar 2, 2016

Yeah I think it's worth biting the bullet and cleaning up imports in one big go for 2.0.
The failures are certainly spurious, let's try again.

@SparkQA
Copy link

SparkQA commented Mar 2, 2016

Test build #52313 has finished for PR 11438 at commit 627d561.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 2, 2016

Test build #52310 has finished for PR 11438 at commit 90d0241.

  • This patch fails from timeout after a configured wait of 250m.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun
Copy link
Member Author

Thank you. I see. I rebased to test one more time.

@SparkQA
Copy link

SparkQA commented Mar 2, 2016

Test build #52323 has finished for PR 11438 at commit 1938445.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

After SPARK-6990, `dev/lint-java` keeps Java code healthy and helps PR review by saving much time.
This issue aims to enforce `UnusedImports` rule by adding a `UnusedImports` rule to `checkstyle.xml` and fixing all existing unused imports.

./build/sbt compile
./dev/lint-java
@SparkQA
Copy link

SparkQA commented Mar 2, 2016

Test build #52333 has finished for PR 11438 at commit f85d167.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Mar 3, 2016

Test build #52340 has finished for PR 11438 at commit 4ecb8d7.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-13583][BUILD] Enforce UnusedImports Java checkstyle rule [SPARK-13583][CORE][STREAMING] Remove unused imports and add checkstyle rule Mar 3, 2016
@dongjoon-hyun
Copy link
Member Author

It passes the test finally. I updated the title and description of this PR and JIRA.
To sum up,

  • Remove all detected unused imports in Java (except one line in JavaKinesisStreamSuite.java)
  • Remove all observed unused imports in Scala (by manually with IntelliJ)
  • Add UnusedImports rule to checkstyle.xml

Thanks to your advice and help, I can finish this PR.
Thank you, @srowen and @zsxwing .

@srowen
Copy link
Member

srowen commented Mar 3, 2016

Merged to master

@asfgit asfgit closed this in b5f02d6 Mar 3, 2016
@dongjoon-hyun
Copy link
Member Author

Thank you for merging!

@dongjoon-hyun dongjoon-hyun deleted the SPARK-13583 branch March 3, 2016 20:41
roygao94 pushed a commit to roygao94/spark that referenced this pull request Mar 22, 2016
…le rule

## What changes were proposed in this pull request?

After SPARK-6990, `dev/lint-java` keeps Java code healthy and helps PR review by saving much time.
This issue aims remove unused imports from Java/Scala code and add `UnusedImports` checkstyle rule to help developers.

## How was this patch tested?
```
./dev/lint-java
./build/sbt compile
```

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes apache#11438 from dongjoon-hyun/SPARK-13583.
zzcclp pushed a commit to zzcclp/spark that referenced this pull request Apr 1, 2016
…rame decoder apache#12038

[EXT][SPARK-13583][CORE][STREAMING] Remove unused imports and add checkstyle rule apache#11438
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants