Skip to content

Commit

Permalink
[Improve] add maven-scalastyle-plugin (#3842)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfboys authored Jul 7, 2024
1 parent f750984 commit 4ef83ae
Show file tree
Hide file tree
Showing 329 changed files with 4,103 additions and 4,235 deletions.
19 changes: 15 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
<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>
<spotless.scalafmt.version>3.7.5</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>
Expand Down Expand Up @@ -510,8 +510,8 @@
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<suppressionsLocation>/tools/checkstyle/suppressions.xml</suppressionsLocation>
<configLocation>/tools/checkstyle/checkstyle.xml</configLocation>
<suppressionsLocation>${maven.multiModuleProjectDirectory}/tools/checkstyle/suppressions.xml</suppressionsLocation>
<configLocation>${maven.multiModuleProjectDirectory}/tools/checkstyle/checkstyle.xml</configLocation>
<inputEncoding>UTF-8</inputEncoding>
<outputEncoding>UTF-8</outputEncoding>
<consoleOutput>true</consoleOutput>
Expand Down Expand Up @@ -564,7 +564,7 @@
<failOnWarning>false</failOnWarning>
<sourceDirectory>${project.basedir}/src/main/scala</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/scala</testSourceDirectory>
<configLocation>/tools/checkstyle/scalastyle-config.xml</configLocation>
<configLocation>${maven.multiModuleProjectDirectory}/tools/checkstyle/scalastyle-config.xml</configLocation>
<outputFile>${project.build.directory}/scalastyle-output.xml</outputFile>
<outputEncoding>UTF-8</outputEncoding>
<skip>${maven.scalastyle.skip}</skip>
Expand Down Expand Up @@ -594,6 +594,9 @@
<eclipse>
<file>${maven.multiModuleProjectDirectory}/tools/checkstyle/spotless_streampark_formatter.xml</file>
</eclipse>
<licenseHeader>
<file>${maven.multiModuleProjectDirectory}/tools/checkstyle/copyright.txt</file>
</licenseHeader>
<importOrder>
<order>org.apache.streampark,org.apache.streampark.shaded,org.apache,,javax,java,scala,\#</order>
</importOrder>
Expand Down Expand Up @@ -626,6 +629,9 @@
<version>${spotless.scalafmt.version}</version>
<file>${maven.multiModuleProjectDirectory}/tools/checkstyle/.scalafmt.conf</file>
</scalafmt>
<licenseHeader>
<file>${maven.multiModuleProjectDirectory}/tools/checkstyle/copyright.txt</file>
</licenseHeader>
</scala>
<pom>
<includes>
Expand Down Expand Up @@ -916,6 +922,11 @@
<artifactId>maven-checkstyle-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.scalastyle</groupId>
<artifactId>scalastyle-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@ private Constant() {

public static final String DEFAULT_DATAMASK_STRING = "********";

public static final String PYTHON_FLINK_DRIVER_CLASS_NAME =
"org.apache.flink.client.python.PythonDriver";
public static final String PYTHON_FLINK_DRIVER_CLASS_NAME = "org.apache.flink.client.python.PythonDriver";

public static final String STREAMPARK_FLINKSQL_CLIENT_CLASS =
"org.apache.streampark.flink.cli.SqlClient";
public static final String STREAMPARK_FLINKSQL_CLIENT_CLASS = "org.apache.streampark.flink.cli.SqlClient";

public static final String STREAMPARK_SPARKSQL_CLIENT_CLASS =
"org.apache.streampark.spark.cli.SqlClient";
public static final String STREAMPARK_SPARKSQL_CLIENT_CLASS = "org.apache.streampark.spark.cli.SqlClient";

public static final String PYTHON_EXECUTABLE = "venv.zip/venv/bin/python3";
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.conf

import java.lang.{Integer => JavaInt, Long => JavaLong}
Expand Down Expand Up @@ -57,22 +58,19 @@ object CommonConfig {
key = "streampark.docker.http-client.max-connections",
defaultValue = 100,
classType = classOf[JavaInt],
description = "instantiating max connections for DockerHttpClient"
)
description = "instantiating max connections for DockerHttpClient")

val DOCKER_CONNECTION_TIMEOUT_SEC: InternalOption = InternalOption(
key = "streampark.docker.http-client.connection-timeout-sec",
defaultValue = 100L,
classType = classOf[JavaLong],
description = "instantiating connection timeout for DockerHttpClient"
)
description = "instantiating connection timeout for DockerHttpClient")

val DOCKER_RESPONSE_TIMEOUT_SEC: InternalOption = InternalOption(
key = "streampark.docker.http-client.response-timeout-sec",
defaultValue = 120L,
classType = classOf[JavaLong],
description = "instantiating connection timeout for DockerHttpClient"
)
description = "instantiating connection timeout for DockerHttpClient")

val MAVEN_SETTINGS_PATH: InternalOption = InternalOption(
key = "streampark.maven.settings",
Expand All @@ -84,8 +82,7 @@ object CommonConfig {
key = "streampark.maven.central.repository",
defaultValue = "https://repo1.maven.org/maven2/",
classType = classOf[String],
description = "maven repository used for built-in compilation"
)
description = "maven repository used for built-in compilation")

val MAVEN_AUTH_USER: InternalOption = InternalOption(
key = "streampark.maven.auth.user",
Expand Down Expand Up @@ -115,7 +112,6 @@ object CommonConfig {
key = "spring.profiles.active",
defaultValue = "h2",
classType = classOf[String],
description = "Use the database type"
)
description = "Use the database type")

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.conf

object ConfigKeys {
Expand Down Expand Up @@ -65,13 +66,17 @@ object ConfigKeys {
val KEY_SPARK_BATCH_DURATION = "spark.batch.duration"

/** about config flink */
def KEY_APP_CONF(prefix: String = null): String = s"${Option(prefix).getOrElse("")}conf"
def KEY_APP_CONF(prefix: String = null): String =
s"${Option(prefix).getOrElse("")}conf"

def KEY_FLINK_CONF(prefix: String = null): String = s"${Option(prefix).getOrElse("")}flink.conf"
def KEY_FLINK_CONF(prefix: String = null): String =
s"${Option(prefix).getOrElse("")}flink.conf"

def KEY_APP_NAME(prefix: String = null): String = s"${Option(prefix).getOrElse("")}app.name"
def KEY_APP_NAME(prefix: String = null): String =
s"${Option(prefix).getOrElse("")}app.name"

def KEY_FLINK_SQL(prefix: String = null): String = s"${Option(prefix).getOrElse("")}sql"
def KEY_FLINK_SQL(prefix: String = null): String =
s"${Option(prefix).getOrElse("")}sql"

def KEY_FLINK_PARALLELISM(prefix: String = null): String =
s"${Option(prefix).getOrElse("")}parallelism.default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.conf

import org.apache.streampark.common.util.ImplicitsUtils._
Expand Down Expand Up @@ -44,7 +45,8 @@ case class ConfigOption[T](
description: String = "",
handle: String => T = null)(implicit prefix: String = "", prop: Properties) {

private[this] lazy val fullKey = if (prefix != null && prefix.nonEmpty) s"$prefix.$key" else key
private[this] lazy val fullKey =
if (prefix != null && prefix.nonEmpty) s"$prefix.$key" else key

def get(): T = handle match {
case null =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.conf

import org.apache.streampark.common.util.{CommandUtils, Logger}
Expand Down Expand Up @@ -79,8 +80,7 @@ class FlinkVersion(val flinkHome: String) extends java.io.Serializable with Logg
flinkVersion.set(matcher.group(1))
}
}
}
)
})
logInfo(buffer.toString())
if (!success.get()) {
throw new IllegalStateException(s"[StreamPark] parse flink version failed. $buffer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ object InternalConfigHolder extends Logger {
private val confData = new ConcurrentHashMap[String, Any](initialCapacity)

/** configuration key options storage (key -> ConfigOption) */
private val confOptions = new ConcurrentHashMap[String, InternalOption](initialCapacity)
private val confOptions =
new ConcurrentHashMap[String, InternalOption](initialCapacity)

/** Initialize the ConfigHub. */
Seq(CommonConfig, K8sFlinkConfig)
Expand Down Expand Up @@ -160,10 +161,9 @@ object InternalConfigHolder extends Logger {
logInfo(s"""Registered configs:
|ConfigHub collected configs: ${configKeys.size}
| ${configKeys
.map(
key =>
s"$key = ${if (key.contains("password")) Constant.DEFAULT_DATAMASK_STRING
else get(key)}")
.map(key =>
s"$key = ${if (key.contains("password")) Constant.DEFAULT_DATAMASK_STRING
else get(key)}")
.mkString("\n ")}""".stripMargin)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,45 +21,40 @@ package org.apache.streampark.common.conf
object K8sFlinkConfig {

// ======= deprecated =======
@Deprecated
@deprecated
val jobStatusTrackTaskTimeoutSec: InternalOption = InternalOption(
key = "streampark.flink-k8s.tracking.polling-task-timeout-sec.job-status",
defaultValue = 120L,
classType = classOf[java.lang.Long],
description = "run timeout seconds of single flink-k8s metrics tracking task"
)
description = "run timeout seconds of single flink-k8s metrics tracking task")

@Deprecated
@deprecated
val metricTrackTaskTimeoutSec: InternalOption = InternalOption(
key = "streampark.flink-k8s.tracking.polling-task-timeout-sec.cluster-metric",
defaultValue = 120L,
classType = classOf[java.lang.Long],
description = "run timeout seconds of single flink-k8s job status tracking task"
)
description = "run timeout seconds of single flink-k8s job status tracking task")

@Deprecated
@deprecated
val jobStatueTrackTaskIntervalSec: InternalOption = InternalOption(
key = "streampark.flink-k8s.tracking.polling-interval-sec.job-status",
defaultValue = 5L,
classType = classOf[java.lang.Long],
description = "interval seconds between two single flink-k8s metrics tracking task"
)
description = "interval seconds between two single flink-k8s metrics tracking task")

@Deprecated
@deprecated
val metricTrackTaskIntervalSec: InternalOption = InternalOption(
key = "streampark.flink-k8s.tracking.polling-interval-sec.cluster-metric",
defaultValue = 5L,
classType = classOf[java.lang.Long],
description = "interval seconds between two single flink-k8s metrics tracking task"
)
description = "interval seconds between two single flink-k8s metrics tracking task")

@Deprecated
@deprecated
val silentStateJobKeepTrackingSec: InternalOption = InternalOption(
key = "streampark.flink-k8s.tracking.silent-state-keep-sec",
defaultValue = 60,
classType = classOf[java.lang.Integer],
description = "retained tracking time for SILENT state flink tasks"
)
description = "retained tracking time for SILENT state flink tasks")

/**
* If an ingress controller is specified in the configuration, the ingress class
Expand All @@ -70,11 +65,10 @@ object K8sFlinkConfig {
key = "streampark.flink-k8s.ingress.class",
defaultValue = "nginx",
classType = classOf[java.lang.String],
description = "Direct ingress to the ingress controller."
)
description = "Direct ingress to the ingress controller.")

/** kubernetes default namespace */
@Deprecated
@deprecated
val DEFAULT_KUBERNETES_NAMESPACE = "default"

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.conf

import org.apache.streampark.common.util.{CommandUtils, Logger}
Expand Down Expand Up @@ -101,8 +102,7 @@ class SparkVersion(val sparkHome: String) extends java.io.Serializable with Logg
sparkVersion.set(matcher.group(2))
}
}
}
)
})
logInfo(buffer.toString())
if (!success.get()) {
throw new IllegalStateException(s"[StreamPark] parse spark version failed. $buffer")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.conf

import org.apache.streampark.common.enums.StorageType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.enums

object ApiType extends Enumeration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.enums

object PlannerType extends Enumeration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.enums

object TableMode extends Enumeration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.apache.commons.lang3.StringUtils
import java.io.{File, FileInputStream}

/** Local File System (aka LFS) Operator */
//noinspection DuplicatedCode
object LfsOperator extends FsOperator with Logger {

override def exists(path: String): Boolean = {
Expand Down Expand Up @@ -147,13 +146,15 @@ object LfsOperator extends FsOperator with Logger {

/** list file under directory, one level of traversal only */
def listDir(path: String): Array[File] = {
if (path == null || path.trim.isEmpty) Array.empty
else
if (path == null || path.trim.isEmpty) {
Array.empty
} else {
new File(path) match {
case f if !f.exists => Array()
case f if f.isFile => Array(f)
case f => f.listFiles()
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.common.util

import org.apache.streampark.common.util.Utils.isEmpty
Expand Down Expand Up @@ -265,7 +266,8 @@ object AssertUtils {
}
}

private[this] def getHasLength(@Nullable str: String): Boolean = str != null && str.nonEmpty
private[this] def getHasLength(@Nullable str: String): Boolean =
str != null && str.nonEmpty

private[this] def getHasText(@Nullable str: String): Boolean = {
str != null && str.nonEmpty && containsText(str)
Expand Down
Loading

0 comments on commit 4ef83ae

Please sign in to comment.