Skip to content

Commit

Permalink
refactor(style): fix the scala's maxColumn from 98 to 100 (#3164)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackxu2011 authored Aug 31, 2022
1 parent 47d7347 commit c7791d2
Show file tree
Hide file tree
Showing 239 changed files with 680 additions and 1,391 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runner.dialect = scala211
align.preset = none
align.tokens = []
optIn.configStyleArguments = false
maxColumn = 98
maxColumn = 100

indent.ctrlSite = 4

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ class BlockingLoopArray[T](maxCapacity: Int = 32) extends LoopArray[T](maxCapaci
}

/**
* Get the latest one, if not, it will return None.(获取最新的一个,如果没有,将会返回None.) Note: This method
* does not move the pointer(注意:该方法不会移动指针)
* Get the latest one, if not, it will return None.(获取最新的一个,如果没有,将会返回None.) Note: This method does
* not move the pointer(注意:该方法不会移动指针)
* @return
*/
def peek(): Option[T] = readLock synchronized {
Expand All @@ -159,8 +159,8 @@ class BlockingLoopArray[T](maxCapacity: Int = 32) extends LoopArray[T](maxCapaci
}

/**
* Get the latest one, if not, it will return None.(获取最新的一个,如果没有,将会返回None.) Note: This method
* will move the pointer(注意:该方法会移动指针)
* Get the latest one, if not, it will return None.(获取最新的一个,如果没有,将会返回None.) Note: This method will
* move the pointer(注意:该方法会移动指针)
* @return
*/
def poll(): Option[T] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ private[conf] object BDPConfiguration extends Logging {

val DEFAULT_SERVER_CONF_FILE_NAME = "linkis-server.properties"

private val extractConfig = new Properties
private val config = new Properties
private val sysProps = sys.props
private val extractConfig = new Properties

private val env = sys.env

private def init: Unit = {
Expand All @@ -45,27 +44,29 @@ private[conf] object BDPConfiguration extends Logging {
val propertyFile = sysProps.getOrElse("wds.linkis.configuration", DEFAULT_PROPERTY_FILE_NAME)
val configFileURL = getClass.getClassLoader.getResource(propertyFile)
if (configFileURL != null && new File(configFileURL.getPath).exists) {
logger.warn(
s"******************************** Notice: The Linkis configuration file is $propertyFile ! ***************************"
logger.info(
s"******************* Notice: The Linkis configuration file is $propertyFile ! *******************"
)
initConfig(config, configFileURL.getPath)
} else
} else {
logger.warn(
s"******************************** Notice: The Linkis configuration file $propertyFile is not exists! ***************************"
s"************ Notice: The Linkis configuration file $propertyFile is not exists! *******************"
)
}

// load pub linkis conf
val serverConf = sysProps.getOrElse("wds.linkis.server.conf", DEFAULT_SERVER_CONF_FILE_NAME)
val serverConfFileURL = getClass.getClassLoader.getResource(serverConf)
if (serverConfFileURL != null && new File(serverConfFileURL.getPath).exists) {
logger.warn(
s"******************************** Notice: The Linkis serverConf file is $serverConf ! ***************************"
logger.info(
s"*********************** Notice: The Linkis serverConf file is $serverConf ! ******************"
)
initConfig(config, serverConfFileURL.getPath)
} else
} else {
logger.warn(
s"******************************** Notice: The Linkis serverConf file $serverConf is not exists! ***************************"
s"**************** Notice: The Linkis serverConf file $serverConf is not exists! *******************"
)
}

// load server confs
val propertyFileOptions = sysProps.get("wds.linkis.server.confs")
Expand All @@ -74,14 +75,15 @@ private[conf] object BDPConfiguration extends Logging {
propertyFiles.foreach { propertyF =>
val configFileURL = getClass.getClassLoader.getResource(propertyF)
if (configFileURL != null && new File(configFileURL.getPath).exists) {
logger.warn(
s"******************************** Notice: The Linkis server.confs is file $propertyF ***************************"
logger.info(
s"************** Notice: The Linkis server.confs is file $propertyF ****************"
)
initConfig(config, configFileURL.getPath)
} else
} else {
logger.warn(
s"******************************** Notice: The Linkis server.confs file $propertyF is not exists! ***************************"
s"********** Notice: The Linkis server.confs file $propertyF is not exists! **************"
)
}
}
}

Expand Down Expand Up @@ -125,16 +127,16 @@ private[conf] object BDPConfiguration extends Logging {

def properties: Properties = {
val props = new Properties
props.putAll(env.asJava)
props.putAll(sysProps.asJava)
props.putAll(config)
props.putAll(extractConfig)
props.putAll(env.asJava)
props
}

def getOption[T](commonVars: CommonVars[T]): Option[T] = if (commonVars.value != null)
def getOption[T](commonVars: CommonVars[T]): Option[T] = if (commonVars.value != null) {
Option(commonVars.value)
else {
} else {
val value = BDPConfiguration.getOption(commonVars.key)
if (value.isEmpty) Option(commonVars.defaultValue)
else formatValue(commonVars.defaultValue, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ object DWCArgumentsParser {
optionParser.setConf(args(i), key, value)
i += 1
case _ =>
throw new IllegalArgumentException(
"illegal commond line, format: --conf key=value."
)
throw new IllegalArgumentException("illegal commond line, format: --conf key=value.")
}
case _ =>
throw new IllegalArgumentException(
s"illegal commond line, ${args(i)} cannot recognize."
)
throw new IllegalArgumentException(s"illegal commond line, ${args(i)} cannot recognize.")
}
i += 1
}
Expand All @@ -78,9 +74,7 @@ object DWCArgumentsParser {
springOptionMap: Map[String, String],
dwcOptionMap: Map[String, String]
): Array[String] =
formatToArray(
new DWCArgumentsParser().setSpringConf(springOptionMap).setDWCConf(dwcOptionMap)
)
formatToArray(new DWCArgumentsParser().setSpringConf(springOptionMap).setDWCConf(dwcOptionMap))

def format(optionParser: DWCArgumentsParser): String = formatToArray(optionParser).mkString(" ")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ trait ListenerBus[L <: EventListener, E <: Event] extends Logging {
}

/**
* Remove a listener and it won't receive any events. This method is thread-safe and can be
* called in any thread.
* Remove a listener and it won't receive any events. This method is thread-safe and can be called
* in any thread.
*/
final def removeListener(listener: L): Unit = {
listeners.remove(listener)
Expand Down Expand Up @@ -103,8 +103,8 @@ abstract class ListenerEventBus[L <: EventListener, E <: Event](
* Start sending events to attached listeners.
*
* This first sends out all buffered events posted before this listener bus has started, then
* listens for any additional events asynchronously while the listener bus is still running.
* This should only be called once.
* listens for any additional events asynchronously while the listener bus is still running. This
* should only be called once.
*/
def start(): Unit = {
if (started.compareAndSet(false, true)) {
Expand Down Expand Up @@ -135,9 +135,9 @@ abstract class ListenerEventBus[L <: EventListener, E <: Event](
}

/**
* For testing only. Wait until there are no more events in the queue, or until the specified
* time has elapsed. Throw `TimeoutException` if the specified time elapsed before the queue
* emptied. Exposed for testing.
* For testing only. Wait until there are no more events in the queue, or until the specified time
* has elapsed. Throw `TimeoutException` if the specified time elapsed before the queue emptied.
* Exposed for testing.
*/
@throws(classOf[TimeoutException])
def waitUntilEmpty(timeoutMillis: Long): Unit = {
Expand Down Expand Up @@ -230,8 +230,8 @@ abstract class ListenerEventBus[L <: EventListener, E <: Event](
})

/**
* If the event queue exceeds its capacity, the new events will be dropped. The subclasses
* will be notified with the dropped events.
* If the event queue exceeds its capacity, the new events will be dropped. The subclasses will
* be notified with the dropped events.
*
* Note: `onDropEvent` can be called in any thread.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package org.apache.linkis.common.utils
import org.slf4j.LoggerFactory

/**
* use the class's method will miss the real info line number, so deprecated all the method and
* this trait will be deprecated too
* use the class's method will miss the real info line number, so deprecated all the method and this
* trait will be deprecated too
*/
trait Logging {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ object ZipUtils {
* :The name of the compressed file(压缩后文件的名称)
* @return
*/
def zip(sourceFilePath: String, zipFilePath: String, fileName: String)(implicit
fs: Fs
): Unit = {
def zip(sourceFilePath: String, zipFilePath: String, fileName: String)(implicit fs: Fs): Unit = {
var bis: BufferedInputStream = null
var zos: ZipOutputStream = null
val sourcePath = new FsPath(sourceFilePath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,7 @@ class CustomQuarterType(date: String, std: Boolean = true, isEnd: Boolean = fals
}

def +(quarters: Int): String = {
DateTypeUtils.getQuarter(
std,
isEnd,
DateUtils.addMonths(getCurrentQuarter(date), quarters * 3)
)
DateTypeUtils.getQuarter(std, isEnd, DateUtils.addMonths(getCurrentQuarter(date), quarters * 3))
}

override def toString: String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ case class QuarterType(value: CustomQuarterType) extends VariableType {
case "+" => value + bValue.toInt
case "-" => value - bValue.toInt
case _ =>
throw new LinkisCommonErrorException(
20046,
s"QuarterType is not supported to use:$signal"
)
throw new LinkisCommonErrorException(20046, s"QuarterType is not supported to use:$signal")
}
}

Expand All @@ -93,10 +90,7 @@ case class HalfYearType(value: CustomHalfYearType) extends VariableType {
case "+" => value + bValue.toInt
case "-" => value - bValue.toInt
case _ =>
throw new LinkisCommonErrorException(
20046,
s"HalfYearType is not supported to use:$signal"
)
throw new LinkisCommonErrorException(20046, s"HalfYearType is not supported to use:$signal")
}
}

Expand Down Expand Up @@ -142,10 +136,7 @@ case class DoubleValue(value: Double) extends VariableType {
case "*" => val res = value * bValue.toDouble; doubleOrLong(res).toString
case "/" => val res = value / bValue.toDouble; doubleOrLong(res).toString
case _ =>
throw new LinkisCommonErrorException(
20047,
s"Double class is not supported to use:$signal"
)
throw new LinkisCommonErrorException(20047, s"Double class is not supported to use:$signal")
}
}

Expand All @@ -165,10 +156,7 @@ case class FloatType(value: Float) extends VariableType {
case "*" => val res = value * bValue.toFloat; floatOrLong(res).toString
case "/" => val res = value / bValue.toLong; floatOrLong(res).toString
case _ =>
throw new LinkisCommonErrorException(
20048,
s"Float class is not supported to use:$signal"
)
throw new LinkisCommonErrorException(20048, s"Float class is not supported to use:$signal")
}
}

Expand All @@ -185,10 +173,7 @@ case class StringType(value: String) extends VariableType {
signal match {
case "+" => value + bValue
case _ =>
throw new LinkisCommonErrorException(
20049,
s"String class is not supported to use:$signal"
)
throw new LinkisCommonErrorException(20049, s"String class is not supported to use:$signal")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ class CodeAndRunTypeUtilsTest {
val python =
CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot("py", CodeAndRunTypeUtils.RUN_TYPE_PYTHON)
assertTrue(python)
val scala = CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot(
"java",
CodeAndRunTypeUtils.RUN_TYPE_SCALA
)
val scala =
CodeAndRunTypeUtils.getSuffixBelongToRunTypeOrNot("java", CodeAndRunTypeUtils.RUN_TYPE_SCALA)
assertTrue(!scala)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ object HadoopConf {
val hadoopConfDir =
CommonVars("hadoop.config.dir", CommonVars("HADOOP_CONF_DIR", "").getValue).getValue

val HADOOP_EXTERNAL_CONF_DIR_PREFIX = CommonVars(
"wds.linkis.hadoop.external.conf.dir.prefix",
"/appcom/config/external-conf/hadoop"
)
val HADOOP_EXTERNAL_CONF_DIR_PREFIX =
CommonVars("wds.linkis.hadoop.external.conf.dir.prefix", "/appcom/config/external-conf/hadoop")

val HDFS_ENABLE_CACHE = CommonVars("wds.linkis.hadoop.hdfs.cache.enable", false).getValue

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,14 @@ abstract class AbstractHttpClient(clientConfig: ClientConfig, clientName: String
d.setSchedule(clientConfig.getDiscoveryPeriod, clientConfig.getDiscoveryTimeUnit)
case d => d.setServerUrl(clientConfig.getServerUrl)
}
val loadBalancer = if (
clientConfig.isLoadbalancerEnabled && this.clientConfig.getLoadbalancerStrategy != null
) {
Some(this.clientConfig.getLoadbalancerStrategy.createLoadBalancer())
} else if (clientConfig.isLoadbalancerEnabled)
Some(DefaultLoadbalancerStrategy.createLoadBalancer())
else None
val loadBalancer =
if (
clientConfig.isLoadbalancerEnabled && this.clientConfig.getLoadbalancerStrategy != null
) {
Some(this.clientConfig.getLoadbalancerStrategy.createLoadBalancer())
} else if (clientConfig.isLoadbalancerEnabled)
Some(DefaultLoadbalancerStrategy.createLoadBalancer())
else None
loadBalancer match {
case Some(lb: AbstractLoadBalancer) =>
discovery.foreach(_.addDiscoveryListener(lb))
Expand Down Expand Up @@ -169,9 +170,7 @@ abstract class AbstractHttpClient(clientConfig: ClientConfig, clientName: String
if (metricResult.getMetric == null) metricResult.setMetric(new HttpMetric)
metricResult.getMetric.setPrepareReqTime(prepareReqTime)
metricResult.getMetric.addRetries(attempts)
metricResult.getMetric.setDeserializeTime(
System.currentTimeMillis - beforeDeserializeTime
)
metricResult.getMetric.setDeserializeTime(System.currentTimeMillis - beforeDeserializeTime)
metricResult.getMetric.setExecuteTotalTime(System.currentTimeMillis - startTime)
metricResult
case result: Result => result
Expand Down Expand Up @@ -344,9 +343,7 @@ abstract class AbstractHttpClient(clientConfig: ClientConfig, clientName: String
val entity: HttpEntity = EntityBuilder
.create()
. /*setContentEncoding("UTF-8").*/
setContentType(
ContentType.create("application/x-www-form-urlencoded", Consts.UTF_8)
)
setContentType(ContentType.create("application/x-www-form-urlencoded", Consts.UTF_8))
.setParameters(nvps)
.build();
httpPost.setEntity(entity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ trait UploadAction extends UserAction {
@Deprecated val files: util.Map[String, String]

/**
* The inputStream that needs to be uploaded, the key is the parameter name, and the value is
* the input stream. 需要上传的输入流,key为参数名,value为输入流
* The inputStream that needs to be uploaded, the key is the parameter name, and the value is the
* input stream. 需要上传的输入流,key为参数名,value为输入流
*/
def inputStreams: util.Map[String, InputStream] = new util.HashMap[String, InputStream]()

/**
* The inputStream that needs to be uploaded, the key is the parameter name, and the value is
* the fileName of inputStream. 需要上传的输入流,key为参数名,value为输入流的文件名
* The inputStream that needs to be uploaded, the key is the parameter name, and the value is the
* fileName of inputStream. 需要上传的输入流,key为参数名,value为输入流的文件名
*/
@Deprecated def inputStreamNames: util.Map[String, String] = new util.HashMap[String, String]()
def binaryBodies: util.List[BinaryBody] = new util.ArrayList[BinaryBody](0)
Expand Down
Loading

0 comments on commit c7791d2

Please sign in to comment.