Skip to content

Commit

Permalink
[Improve] scala code-style improvement (apache#3839)
Browse files Browse the repository at this point in the history
* [Improve] scala code style improvement
  • Loading branch information
wolfboys authored Jul 6, 2024
1 parent 7a511d5 commit 0f1f1c9
Show file tree
Hide file tree
Showing 91 changed files with 757 additions and 505 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/owasp-dependency-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
java-version: 8
distribution: 'adopt'
- name: Run OWASP Dependency Check
run: ./mvnw -B clean install dependency-check:check -DskipDependencyCheck==false -Dspotless.skip=true
run: ./mvnw -B clean install dependency-check:check -Dowasp.skip=false -Dspotless.skip=true -Drat.skip=true
- name: Upload report
uses: actions/upload-artifact@v4
if: ${{ cancelled() || failure() }}
Expand Down
173 changes: 126 additions & 47 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
<packaging>pom</packaging>
<name>StreamPark Project Parent POM</name>

<url>https://streampark.apache.org/</url>
<description>StreamPark, Make stream processing easier! easy-to-use streaming application development framework and operation
platform</description>

<description>
StreamPark, Make stream processing easier! easy-to-use streaming application development framework and operation
platform
</description>
<url>https://streampark.apache.org/</url>

<organization>
<name>Apache Software Foundation</name>
Expand All @@ -49,30 +47,18 @@
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/apache/incubator-streampark.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/incubator-streampark.git</developerConnection>
<url>scm:git:[email protected]:apache/incubator-streampark.git</url>
<tag>HEAD</tag>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/apache/incubator-streampark/issues</url>
</issueManagement>

<mailingLists>
<mailingList>
<name>StreamPark Developer List</name>
<post>[email protected]</post>
<subscribe>[email protected]</subscribe>
<unsubscribe>[email protected]</unsubscribe>
<post>[email protected]</post>
</mailingList>
<mailingList>
<name>StreamPark Commits List</name>
<post>[email protected]</post>
<subscribe>[email protected]</subscribe>
<unsubscribe>[email protected]</unsubscribe>
<post>[email protected]</post>
</mailingList>
</mailingLists>

Expand All @@ -83,6 +69,18 @@
<module>streampark-console</module>
</modules>

<scm>
<connection>scm:git:git://github.com/apache/incubator-streampark.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/incubator-streampark.git</developerConnection>
<tag>HEAD</tag>
<url>scm:git:[email protected]:apache/incubator-streampark.git</url>
</scm>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/apache/incubator-streampark/issues</url>
</issueManagement>

<properties>
<project.build.jdk>1.8</project.build.jdk>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -134,8 +132,10 @@
<maven-source-plugin.version>2.2.1</maven-source-plugin.version>
<maven-spotless-plugin.version>2.27.2</maven-spotless-plugin.version>
<maven-apache-rat-plugin.version>0.13</maven-apache-rat-plugin.version>
<maven-silencer-plugin.version>1.7.13</maven-silencer-plugin.version>
<spotless.scalafmt.version>3.4.3</spotless.scalafmt.version>
<maven-checkstyle-plugin.version>3.2.0</maven-checkstyle-plugin.version>
<maven-scalastyle-plugin.version>1.0.0</maven-scalastyle-plugin.version>
<owasp-dependency-check-maven.version>9.2.0</owasp-dependency-check-maven.version>
<build-helper-maven-plugin.version>3.3.0</build-helper-maven-plugin.version>
<streampark.shaded.package>org.apache.streampark.shaded</streampark.shaded.package>
Expand All @@ -147,11 +147,12 @@
<mockito-scala.version>1.17.14</mockito-scala.version>
<assertj.version>3.23.1</assertj.version>

<PermGen>64m</PermGen>
<MaxPermGen>512m</MaxPermGen>
<CodeCacheSize>512m</CodeCacheSize>
<MaxMetaspace>512m</MaxMetaspace>
<skipDependencyCheck>true</skipDependencyCheck>
<maven.scaladoc.skip>false</maven.scaladoc.skip>
<maven.scalastyle.skip>false</maven.scalastyle.skip>

<spotless.skip>false</spotless.skip>
<rat.skip>false</rat.skip>
<owasp.skip>true</owasp.skip>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -520,25 +521,19 @@
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
</sourceDirectories>
<resourceIncludes>
**/*.properties,
<resourceIncludes>**/*.properties,
**/*.sh,
**/*.bat,
**/*.yml,
**/*.yaml,
**/*.xml,
**/*.dict
</resourceIncludes>
<resourceExcludes>
**/.asf.yaml,
**/*.dict</resourceIncludes>
<resourceExcludes>**/.asf.yaml,
**/.github/**,
**/crd/**.yml,
**/crd/**.yaml
</resourceExcludes>
<excludes>
**/*.java,
**/*.scala
</excludes>
**/crd/**.yaml</resourceExcludes>
<excludes>**/*.java,
**/*.scala</excludes>
</configuration>
<dependencies>
<dependency>
Expand All @@ -550,7 +545,32 @@
<executions>
<execution>
<id>validate</id>
<goals>
<goal>check</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.scalastyle</groupId>
<artifactId>scalastyle-maven-plugin</artifactId>
<version>${maven-scalastyle-plugin.version}</version>
<configuration>
<verbose>false</verbose>
<failOnViolation>true</failOnViolation>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<failOnWarning>false</failOnWarning>
<sourceDirectory>${project.basedir}/src/main/scala</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/scala</testSourceDirectory>
<configLocation>/tools/checkstyle/scalastyle-config.xml</configLocation>
<outputFile>${project.build.directory}/scalastyle-output.xml</outputFile>
<outputEncoding>UTF-8</outputEncoding>
<skip>${maven.scalastyle.skip}</skip>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
Expand All @@ -563,6 +583,7 @@
<artifactId>spotless-maven-plugin</artifactId>
<version>${maven-spotless-plugin.version}</version>
<configuration>
<skip>${spotless.skip}</skip>
<java>
<includes>
<include>src/main/java/**/*.java</include>
Expand All @@ -571,12 +592,10 @@
<include>streampark-e2e/streampark-e2e-core/src/main/java/**/*.java</include>
</includes>
<eclipse>
<file>${maven.multiModuleProjectDirectory}/style/spotless_streampark_formatter.xml</file>
<file>${maven.multiModuleProjectDirectory}/tools/checkstyle/spotless_streampark_formatter.xml</file>
</eclipse>
<importOrder>
<order>
org.apache.streampark,org.apache.streampark.shaded,org.apache,,javax,java,scala,\#
</order>
<order>org.apache.streampark,org.apache.streampark.shaded,org.apache,,javax,java,scala,\#</order>
</importOrder>
<replaceRegex>
<name>Remove wildcard imports</name>
Expand All @@ -593,23 +612,41 @@
<searchRegex>import\s+org\.junit\.[^jupiter][^\*\s]*(|\*);(\r\n|\r|\n)</searchRegex>
<replacement>$1</replacement>
</replaceRegex>
<removeUnusedImports/>
<removeUnusedImports></removeUnusedImports>
</java>

<scala>
<includes>
<include>src/main/scala/**/*.scala</include>
<include>src/main/scala-*/**/*.scala</include>
<include>src/test/scala/**/*.scala</include>
<include>src/test/scala-*/**/*.scala</include>
</includes>
<scalafmt>
<version>${spotless.scalafmt.version}</version>
<!--suppress UnresolvedMavenProperty -->
<file>${maven.multiModuleProjectDirectory}/style/.scalafmt.conf</file>
<file>${maven.multiModuleProjectDirectory}/tools/checkstyle/.scalafmt.conf</file>
</scalafmt>
</scala>
<pom>
<includes>
<include>pom.xml</include>
</includes>
<sortPom>
<encoding>${project.build.sourceEncoding}</encoding>
<expandEmptyElements>true</expandEmptyElements>
<indentSchemaLocation>true</indentSchemaLocation>
<nrOfIndentSpace>4</nrOfIndentSpace>
</sortPom>
</pom>

</configuration>
<executions>
<execution>
<id>spotless-check</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
Expand Down Expand Up @@ -641,6 +678,34 @@
<addScalacArgs>-target:jvm-${project.build.jdk}</addScalacArgs>
<target>${project.build.jdk}</target>
<source>${project.build.jdk}</source>
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-explaintypes</arg>
<arg>-P:silencer:globalFilters=.*deprecated.*</arg>
<arg>-P:silencer:globalFilters=.*Could not find any member to link for.*</arg>
<arg>-P:silencer:globalFilters=.*undefined in comment for class.*</arg>
<arg>-Xfatal-warnings</arg>
<arg>-Ywarn-unused:imports</arg>
</args>
<jvmArgs>
<jvmArg>-Xms1024m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
<jvmArg>-XX:ReservedCodeCacheSize=512M</jvmArg>
</jvmArgs>
<javacArgs>
<javacArg>-Xlint:all,-serial,-path,-try,-processing</javacArg>
</javacArgs>
<compilerPlugins>
<compilerPlugin>
<groupId>com.github.ghik</groupId>
<artifactId>silencer-plugin_${scala.version}</artifactId>
<version>${maven-silencer-plugin.version}</version>
</compilerPlugin>
</compilerPlugins>
<!-- only skipping `scala:doc-jar` -->
<skip>${maven.scaladoc.skip}</skip>
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -669,8 +734,7 @@
<configuration>
<shadedArtifactId>true</shadedArtifactId>
<createDependencyReducedPom>true</createDependencyReducedPom>
<dependencyReducedPomLocation>${project.basedir}/target/dependency-reduced-pom.xml
</dependencyReducedPomLocation>
<dependencyReducedPomLocation>${project.basedir}/target/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<artifactSet>
<includes>
<!--
Expand Down Expand Up @@ -756,7 +820,7 @@
<artifactId>dependency-check-maven</artifactId>
<version>${owasp-dependency-check-maven.version}</version>
<configuration>
<skip>${skipDependencyCheck}</skip>
<skip>${owasp.skip}</skip>
<skipProvidedScope>true</skipProvidedScope>
<skipRuntimeScope>true</skipRuntimeScope>
<skipSystemScope>true</skipSystemScope>
Expand All @@ -777,6 +841,7 @@
<artifactId>apache-rat-plugin</artifactId>
<version>${maven-apache-rat-plugin.version}</version>
<configuration>
<skip>${rat.skip}</skip>
<excludes>
<exclude>.asf.yaml</exclude>
<exclude>.git-blame-ignore-revs</exclude>
Expand Down Expand Up @@ -907,6 +972,20 @@
<module>streampark-spark</module>
</modules>
</profile>

<profile>
<id>fast</id>
<properties>
<enforcer.skip>true</enforcer.skip>
<maven.javadoc.skip>true</maven.javadoc.skip>
<maven.scaladoc.skip>true</maven.scaladoc.skip>
<maven.scalastyle.skip>true</maven.scalastyle.skip>
<skipTests>true</skipTests>
<rat.skip>true</rat.skip>
<owasp.skip>true</owasp.skip>
<spotless.skip>true</spotless.skip>
</properties>
</profile>
</profiles>

</project>
5 changes: 2 additions & 3 deletions streampark-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
<artifactId>HikariCP</artifactId>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down Expand Up @@ -129,7 +129,6 @@
<optional>true</optional>
</dependency>


<!--logback -->
<dependency>
<groupId>org.apache.streampark</groupId>
Expand Down Expand Up @@ -162,10 +161,10 @@
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<dependencyReducedPomLocation>${project.basedir}/target/dependency-reduced-pom.xml</dependencyReducedPomLocation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class FlinkVersion(val flinkHome: String) extends java.io.Serializable with Logg
}

// StreamPark flink shims version, like "streampark-flink-shims_flink-1.13"
lazy val shimsVersion: String = s"streampark-flink-shims_flink-$majorVersion"
private lazy val shimsVersion: String = s"streampark-flink-shims_flink-$majorVersion"

override def toString: String =
s"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import java.util
import java.util.concurrent.ConcurrentHashMap

import scala.collection.convert.ImplicitConversions._
import scala.language.postfixOps

/**
* Thread-safe configuration storage containers. All configurations will be automatically
Expand Down Expand Up @@ -73,7 +72,7 @@ object InternalConfigHolder extends Logger {
case v if v != null => v.cast[T](conf.classType)
case _ => conf.defaultValue.asInstanceOf[T]
}
case v: T => v
case v => v.asInstanceOf[T]
}
}

Expand Down Expand Up @@ -106,7 +105,7 @@ object InternalConfigHolder extends Logger {
}
case conf: InternalOption => conf.defaultValue.asInstanceOf[T]
}
case v: T => v
case v => v.asInstanceOf[T]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object ExceptionUtils {
stm.toString
} catch {
case e: Exception => s"${e.getClass.getName} (error while printing stack trace)";
case _ => null
case _: Throwable => null
} finally {
Utils.close(writer, stm)
}
Expand Down
Loading

0 comments on commit 0f1f1c9

Please sign in to comment.