Skip to content
Snippets Groups Projects
Commit d34d6503 authored by Dongjoon Hyun's avatar Dongjoon Hyun Committed by Reynold Xin
Browse files

[SPARK-14868][BUILD] Enable NewLineAtEofChecker in checkstyle and fix lint-java errors

## What changes were proposed in this pull request?

Spark uses `NewLineAtEofChecker` rule in Scala by ScalaStyle. And, most Java code also comply with the rule. This PR aims to enforce the same rule `NewlineAtEndOfFile` by CheckStyle explicitly. Also, this fixes lint-java errors since SPARK-14465. The followings are the items.

- Adds a new line at the end of the files (19 files)
- Fixes 25 lint-java errors (12 RedundantModifier, 6 **ArrayTypeStyle**, 2 LineLength, 2 UnusedImports, 2 RegexpSingleline, 1 ModifierOrder)

## How was this patch tested?

After the Jenkins test succeeds, `dev/lint-java` should pass. (Currently, Jenkins dose not run lint-java.)
```bash
$ dev/lint-java
Using `mvn` from path: /usr/local/bin/mvn
Checkstyle checks passed.
```

Author: Dongjoon Hyun <dongjoon@apache.org>

Closes #12632 from dongjoon-hyun/SPARK-14868.
parent d0ca5797
No related branches found
No related tags found
No related merge requests found
...@@ -18,4 +18,4 @@ ...@@ -18,4 +18,4 @@
/** /**
* Spark's machine learning library. * Spark's machine learning library.
*/ */
package org.apache.spark.mllib; package org.apache.spark.mllib;
\ No newline at end of file
...@@ -81,15 +81,15 @@ public class JavaRandomForestClassifierSuite implements Serializable { ...@@ -81,15 +81,15 @@ public class JavaRandomForestClassifierSuite implements Serializable {
for (String featureSubsetStrategy: RandomForestClassifier.supportedFeatureSubsetStrategies()) { for (String featureSubsetStrategy: RandomForestClassifier.supportedFeatureSubsetStrategies()) {
rf.setFeatureSubsetStrategy(featureSubsetStrategy); rf.setFeatureSubsetStrategy(featureSubsetStrategy);
} }
String realStrategies[] = {".1", ".10", "0.10", "0.1", "0.9", "1.0"}; String[] realStrategies = {".1", ".10", "0.10", "0.1", "0.9", "1.0"};
for (String strategy: realStrategies) { for (String strategy: realStrategies) {
rf.setFeatureSubsetStrategy(strategy); rf.setFeatureSubsetStrategy(strategy);
} }
String integerStrategies[] = {"1", "10", "100", "1000", "10000"}; String[] integerStrategies = {"1", "10", "100", "1000", "10000"};
for (String strategy: integerStrategies) { for (String strategy: integerStrategies) {
rf.setFeatureSubsetStrategy(strategy); rf.setFeatureSubsetStrategy(strategy);
} }
String invalidStrategies[] = {"-.1", "-.10", "-0.10", ".0", "0.0", "1.1", "0"}; String[] invalidStrategies = {"-.1", "-.10", "-0.10", ".0", "0.0", "1.1", "0"};
for (String strategy: invalidStrategies) { for (String strategy: invalidStrategies) {
try { try {
rf.setFeatureSubsetStrategy(strategy); rf.setFeatureSubsetStrategy(strategy);
......
...@@ -81,15 +81,15 @@ public class JavaRandomForestRegressorSuite implements Serializable { ...@@ -81,15 +81,15 @@ public class JavaRandomForestRegressorSuite implements Serializable {
for (String featureSubsetStrategy: RandomForestRegressor.supportedFeatureSubsetStrategies()) { for (String featureSubsetStrategy: RandomForestRegressor.supportedFeatureSubsetStrategies()) {
rf.setFeatureSubsetStrategy(featureSubsetStrategy); rf.setFeatureSubsetStrategy(featureSubsetStrategy);
} }
String realStrategies[] = {".1", ".10", "0.10", "0.1", "0.9", "1.0"}; String[] realStrategies = {".1", ".10", "0.10", "0.1", "0.9", "1.0"};
for (String strategy: realStrategies) { for (String strategy: realStrategies) {
rf.setFeatureSubsetStrategy(strategy); rf.setFeatureSubsetStrategy(strategy);
} }
String integerStrategies[] = {"1", "10", "100", "1000", "10000"}; String[] integerStrategies = {"1", "10", "100", "1000", "10000"};
for (String strategy: integerStrategies) { for (String strategy: integerStrategies) {
rf.setFeatureSubsetStrategy(strategy); rf.setFeatureSubsetStrategy(strategy);
} }
String invalidStrategies[] = {"-.1", "-.10", "-0.10", ".0", "0.0", "1.1", "0"}; String[] invalidStrategies = {"-.1", "-.10", "-0.10", ".0", "0.0", "1.1", "0"};
for (String strategy: invalidStrategies) { for (String strategy: invalidStrategies) {
try { try {
rf.setFeatureSubsetStrategy(strategy); rf.setFeatureSubsetStrategy(strategy);
......
...@@ -38,7 +38,6 @@ import static org.apache.parquet.hadoop.ParquetFileReader.readFooter; ...@@ -38,7 +38,6 @@ import static org.apache.parquet.hadoop.ParquetFileReader.readFooter;
import static org.apache.parquet.hadoop.ParquetInputFormat.getFilter; import static org.apache.parquet.hadoop.ParquetInputFormat.getFilter;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.Path;
import org.apache.hadoop.mapreduce.InputSplit; import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader; import org.apache.hadoop.mapreduce.RecordReader;
......
...@@ -18,4 +18,4 @@ ...@@ -18,4 +18,4 @@
/** /**
* Java APIs for spark streaming. * Java APIs for spark streaming.
*/ */
package org.apache.spark.streaming.api.java; package org.apache.spark.streaming.api.java;
\ No newline at end of file
...@@ -18,4 +18,4 @@ ...@@ -18,4 +18,4 @@
/** /**
* Various implementations of DStreams. * Various implementations of DStreams.
*/ */
package org.apache.spark.streaming.dstream; package org.apache.spark.streaming.dstream;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment