You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by ca...@apache.org on 2022/09/01 13:49:38 UTC

[incubator-linkis] branch dev-1.3.1 updated: feat:Scala code format alarm clear in dev1.3.1-linkis-configuration-format (#3136)

This is an automated email from the ASF dual-hosted git repository.

casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new a0cc02084 feat:Scala code format alarm clear in dev1.3.1-linkis-configuration-format (#3136)
a0cc02084 is described below

commit a0cc0208426d8e29eabd739f672e6719ba748215
Author: ruY <43...@users.noreply.github.com>
AuthorDate: Thu Sep 1 21:49:28 2022 +0800

    feat:Scala code format alarm clear in dev1.3.1-linkis-configuration-format (#3136)
---
 .../configuration/service/CategoryService.scala      | 20 +++++++++++++-------
 .../configuration/util/LabelParameterParser.scala    |  5 +++--
 .../configuration/validate/FloatValidator.scala      |  4 ++--
 .../configuration/validate/NumericalValidator.scala  |  6 +++---
 .../configuration/validate/OneOfValidator.scala      |  4 ++--
 .../validate/ValidatorManagerImpl.scala              |  2 +-
 6 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/CategoryService.scala b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/CategoryService.scala
index 81ebb19e2..91a13f3c1 100644
--- a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/CategoryService.scala
+++ b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/service/CategoryService.scala
@@ -35,6 +35,7 @@ import org.springframework.stereotype.Service
 import org.springframework.transaction.annotation.Transactional
 
 import java.util
+import java.util.Locale
 
 import scala.collection.JavaConverters._
 
@@ -52,7 +53,7 @@ class CategoryService extends Logging {
 
   private val combinedLabelBuilder = new CombinedLabelBuilder
 
-  def setCategoryVo(vo: CategoryLabelVo, categoryLabel: CategoryLabel) = {
+  def setCategoryVo(vo: CategoryLabelVo, categoryLabel: CategoryLabel): Unit = {
     vo.setCategoryId(categoryLabel.getCategoryId)
     vo.setLabelId(categoryLabel.getId)
     vo.setCreateTime(categoryLabel.getCreateTime)
@@ -133,7 +134,7 @@ class CategoryService extends Logging {
   def createFirstCategory(categoryName: String, description: String): Unit = {
     val categoryList =
       getAllCategory().asScala.map(category => category.getCategoryName.toLowerCase())
-    if (categoryList.contains(categoryName.toLowerCase)) {
+    if (categoryList.contains(categoryName.toLowerCase(Locale.ROOT))) {
       throw new ConfigurationException(
         s"category name : ${categoryName} is exist, cannot be created(目录名:${categoryName}已存在,无法创建)"
       )
@@ -186,7 +187,11 @@ class CategoryService extends Logging {
     val childList = categoryList.getChildCategory.asScala
     if (
         childList != null && !childList
-          .filter(_.getCategoryName.toLowerCase.equals(engineType.toLowerCase + "-" + version))
+          .filter(
+            _.getCategoryName
+              .toLowerCase(Locale.ROOT)
+              .equals(engineType.toLowerCase(Locale.ROOT) + "-" + version)
+          )
           .isEmpty
     ) {
       throw new ConfigurationException(
@@ -204,13 +209,12 @@ class CategoryService extends Logging {
       configurationService.generateCombinedLabel(engineType, version, null, creator)
     val parsedLabel = LabelEntityParser.parseToConfigLabel(combinedLabel)
     Utils.tryCatch(labelMapper.insertLabel(parsedLabel)) {
-      case exception: DuplicateKeyException => {
+      case exception: DuplicateKeyException =>
         parsedLabel.setId(
           labelMapper
             .getLabelByKeyValue(parsedLabel.getLabelKey, parsedLabel.getStringValue)
             .getId
         )
-      }
       case exception: Exception => throw exception
     }
     if (parsedLabel.getId != null) {
@@ -220,9 +224,11 @@ class CategoryService extends Logging {
         s"success to create category: ${combinedLabel.getStringValue} --category id: ${categoryLabel.getCategoryId} " +
           s"--category level: 2"
       )
-      // 1.Here, the engine and the corresponding engine default configuration are associated and initialized, and the relevant configuration of the corresponding version of the engine needs to be entered in the database in advance
+      // 1.Here, the engine and the corresponding engine default configuration are associated and initialized,
+      // and the relevant configuration of the corresponding version of the engine needs to be entered in the database in advance
       // 2.Now all the default configurations obtained are the default configuration of the engine level, and there is no default configuration of the application level for the time being.
-      // If you need to consider, you need to change the creator of the label generated here to the corresponding application, and you need to modify the getFullTree to obtain the label of the defaultConfig, and also replace its creator with the creator of the application.
+      // If you need to consider, you need to change the creator of the label generated here to the corresponding application,
+      // and you need to modify the getFullTree to obtain the label of the defaultConfig, and also replace its creator with the creator of the application.
       val linkedEngineTypeLabel =
         configurationService.generateCombinedLabel(engineType, version, null, null)
       val linkedEngineTypeLabelInDb = labelMapper.getLabelByKeyValue(
diff --git a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/util/LabelParameterParser.scala b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/util/LabelParameterParser.scala
index 904befbd0..2fb9ef50d 100644
--- a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/util/LabelParameterParser.scala
+++ b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/util/LabelParameterParser.scala
@@ -27,6 +27,7 @@ import org.apache.linkis.manager.label.entity.engine.{EngineType, EngineTypeLabe
 import org.springframework.util.CollectionUtils
 
 import java.util
+import java.util.Locale
 
 import scala.collection.JavaConverters._
 
@@ -36,8 +37,8 @@ object LabelParameterParser {
   def getDefaultEngineVersion(engineType: String): String = {
     var returnType: CommonVars[String] = null
     EngineType.values.foreach(DefinedEngineType => {
-      if (DefinedEngineType.toString.equals(engineType.toLowerCase)) {
-        returnType = engineType.toLowerCase match {
+      if (DefinedEngineType.toString.equals(engineType.toLowerCase(Locale.ROOT))) {
+        returnType = engineType.toLowerCase(Locale.ROOT) match {
           case "spark" => GovernanceCommonConf.SPARK_ENGINE_VERSION
           case "hive" => GovernanceCommonConf.HIVE_ENGINE_VERSION
           case "python" => GovernanceCommonConf.PYTHON_ENGINE_VERSION
diff --git a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/FloatValidator.scala b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/FloatValidator.scala
index 63cbdb095..15ee09eab 100644
--- a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/FloatValidator.scala
+++ b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/FloatValidator.scala
@@ -40,6 +40,6 @@ class FloatValidator extends Validator with Logging {
   override var kind: String = "FloatInterval"
 }
 
-/*object FloatValidator extends App {
+/* object FloatValidator extends App {
   print(new FloatValidator().validate("3", "[1.12,5.22]"))
-}*/
+} */
diff --git a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/NumericalValidator.scala b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/NumericalValidator.scala
index 28e29c4bc..87aa62f09 100644
--- a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/NumericalValidator.scala
+++ b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/NumericalValidator.scala
@@ -38,7 +38,7 @@ class NumericalValidator extends Validator with Logging {
           s"${value} cannot be converted to int, validation failed(${value}不能转换为int,校验失败)"
         ); return false
       // If there is a problem with range, then an exception is thrown.(如果range出问题,那么还是抛出异常)
-      /*case e:JsonSyntaxException =>info(s"${range}Cannot convert to int, check failed(不能转换为int,校验失败)"); return false*/
+      /* case e:JsonSyntaxException =>info(s"${range}Cannot convert to int, check failed(不能转换为int,校验失败)"); return false */
       case e: Exception => throw e
     }
   }
@@ -46,8 +46,8 @@ class NumericalValidator extends Validator with Logging {
   override var kind: String = "NumInterval"
 }
 
-/*object NumericalValidator {
+/* object NumericalValidator {
   def main(args: Array[String]): Unit = {
     print(new NumericalValidator().validate("22.5", "[17.5,150]"))
   }
-}*/
+} */
diff --git a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/OneOfValidator.scala b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/OneOfValidator.scala
index 24003ba0e..027f78611 100644
--- a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/OneOfValidator.scala
+++ b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/OneOfValidator.scala
@@ -29,7 +29,7 @@ class OneOfValidator extends Validator {
   override var kind: String = "OFT" // one of them
 }
 
-/*object OneOfValidator{
+/* object OneOfValidator{
   def main(args: Array[String]): Unit = {
     val range = "[\",\",\"\\t\"]"
     print(new OneOfValidator().validate(",,",range))
@@ -39,4 +39,4 @@ class OneOfValidator extends Validator {
     new GsonBuilder().create().toJson(a)
     print(new GsonBuilder().create().toJson(a))*/
   }
-}*/
+} */
diff --git a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/ValidatorManagerImpl.scala b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/ValidatorManagerImpl.scala
index 657213529..e15345158 100644
--- a/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/ValidatorManagerImpl.scala
+++ b/linkis-public-enhancements/linkis-configuration/src/main/scala/org/apache/linkis/configuration/validate/ValidatorManagerImpl.scala
@@ -29,7 +29,7 @@ class ValidatorManagerImpl extends ValidatorManager with Logging {
   private var validators: Array[Validator] = _
 
   @PostConstruct
-  def init() = {
+  def init(): Unit = {
     validators = Array(
       new NumericalValidator,
       new OneOfValidator,


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org