This is an automated email from the ASF dual-hosted git repository. sarutak pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new c532f82 [SPARK-35609][BUILD] Add style rules to prohibit to use a Guava's API which is incompatible with newer versions c532f82 is described below commit c532f8260ee2f2f4170dc50f7e890fafab438b76 Author: Kousuke Saruta <saru...@oss.nttdata.com> AuthorDate: Thu Jun 3 21:52:41 2021 +0900 [SPARK-35609][BUILD] Add style rules to prohibit to use a Guava's API which is incompatible with newer versions ### What changes were proposed in this pull request? This PR adds rules to `checkstyle.xml` and `scalastyle-config.xml` to avoid introducing `Objects.toStringHelper` a Guava's API which is no longer present in newer Guava. ### Why are the changes needed? SPARK-30272 (#26911) replaced `Objects.toStringHelper` which is an APIs Guava 14 provides with `commons.lang3` API because `Objects.toStringHelper` is no longer present in newer Guava. But toStringHelper was introduced into Spark again and replaced them in SPARK-35420 (#32567). I think it's better to have a style rule to avoid such repetition. SPARK-30272 replaced some APIs aside from `Objects.toStringHelper` but `Objects.toStringHelper` seems to affect Spark for now so I add rules only for it. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? I confirmed that `lint-java` and `lint-scala` detect the usage of `toStringHelper` and let the lint check fail. ``` $ dev/lint-java exec: curl --silent --show-error -L https://downloads.lightbend.com/scala/2.12.14/scala-2.12.14.tgz Using `mvn` from path: /opt/maven/3.6.3//bin/mvn Checkstyle checks failed at following occurrences: [ERROR] src/main/java/org/apache/spark/network/protocol/OneWayMessage.java:[78] (regexp) RegexpSinglelineJava: Avoid using Object.toStringHelper. Use ToStringBuilder instead. $ dev/lint-scala Scalastyle checks failed at following occurrences: [error] /home/kou/work/oss/spark/core/src/main/scala/org/apache/spark/rdd/RDD.scala:93:25: Avoid using Object.toStringHelper. Use ToStringBuilder instead. [error] Total time: 25 s, completed 2021/06/02 16:18:25 ``` Closes #32740 from sarutak/style-rule-for-guava. Authored-by: Kousuke Saruta <saru...@oss.nttdata.com> Signed-off-by: Kousuke Saruta <saru...@oss.nttdata.com> --- dev/checkstyle.xml | 5 ++++- scalastyle-config.xml | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dev/checkstyle.xml b/dev/checkstyle.xml index 483fc7c..06c79a9 100644 --- a/dev/checkstyle.xml +++ b/dev/checkstyle.xml @@ -185,6 +185,9 @@ <property name="format" value="throw new \w+Error\("/> <property name="message" value="Avoid throwing error in application code."/> </module> - + <module name="RegexpSinglelineJava"> + <property name="format" value="Objects\.toStringHelper"/> + <property name="message" value="Avoid using Object.toStringHelper. Use ToStringBuilder instead." /> + </module> </module> </module> diff --git a/scalastyle-config.xml b/scalastyle-config.xml index c1dc57b..c06b4ab 100644 --- a/scalastyle-config.xml +++ b/scalastyle-config.xml @@ -397,4 +397,8 @@ This file is divided into 3 sections: <parameters><parameter name="ignore">-1,0,1,2,3</parameter></parameters> </check> + <check customId="GuavaToStringHelper" level="error" class="org.scalastyle.file.RegexChecker" enabled="true"> + <parameters><parameter name="regex">Objects.toStringHelper</parameter></parameters> + <customMessage>Avoid using Object.toStringHelper. Use ToStringBuilder instead.</customMessage> + </check> </scalastyle> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org