Skip to content

Commit 6bb5af6

Browse files
pan3793yaooqinn
authored andcommitted
[KYUUBI #1433] Enable scalafmt check in spotless
### _Why are the changes needed?_ fail compile if violating scalafmt rules. ``` [ERROR] Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:2.17.4:check (default) on project kyuubi-common_2.12: The following files had format violations: [ERROR] src/test/scala/org/apache/kyuubi/operation/JDBCTestHelper.scala [ERROR] -52,7 +52,7 [ERROR] ··} [ERROR] [ERROR] ··def·withMultipleConnectionJdbcStatement( [ERROR] -····tableNames:·String*)(fs:·(Statement·=>·Unit)*):·Unit·=·{ [ERROR] +······tableNames:·String*)(fs:·(Statement·=>·Unit)*):·Unit·=·{ [ERROR] ····val·connections·=·fs.map·{·_·=>·DriverManager.getConnection(jdbcUrlWithConf,·user,·password)·} [ERROR] ····val·statements·=·connections.map(_.createStatement()) [ERROR] [ERROR] Run 'mvn spotless:apply' to fix these violations. ``` Can auto-fix by `dev/reformat` or `build/mvn spotless:apply` ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1433 from pan3793/scalafmt. Closes #1433 26188a5 [Cheng Pan] Enable scalafmt check in spotless Authored-by: Cheng Pan <chengpan@apache.org> Signed-off-by: Kent Yao <yao@apache.org>
1 parent 0489250 commit 6bb5af6

File tree

6 files changed

+28
-26
lines changed

6 files changed

+28
-26
lines changed

kyuubi-common/src/test/scala/org/apache/kyuubi/operation/HiveJDBCTestHelper.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ trait HiveJDBCTestHelper extends JDBCTestHelper {
3737

3838
protected def matchAllPatterns = Seq("", "*", "%", null, ".*", "_*", "_%", ".%")
3939

40-
protected override lazy val user: String = Utils.currentUser
41-
protected override val password = "anonymous"
40+
override protected lazy val user: String = Utils.currentUser
41+
override protected val password = "anonymous"
4242
private var _sessionConfigs: Map[String, String] = Map.empty
4343
private var _jdbcConfigs: Map[String, String] = Map.empty
4444
private var _jdbcVars: Map[String, String] = Map.empty
4545

46-
protected override def sessionConfigs: Map[String, String] = _sessionConfigs
46+
override protected def sessionConfigs: Map[String, String] = _sessionConfigs
4747

48-
protected override def jdbcConfigs: Map[String, String] = _jdbcConfigs
48+
override protected def jdbcConfigs: Map[String, String] = _jdbcConfigs
4949

50-
protected override def jdbcVars: Map[String, String] = _jdbcVars
50+
override protected def jdbcVars: Map[String, String] = _jdbcVars
5151

5252
def withSessionConf[T](
5353
sessionConfigs: Map[String, String] = Map.empty)(
@@ -64,7 +64,7 @@ trait HiveJDBCTestHelper extends JDBCTestHelper {
6464
}
6565
}
6666

67-
protected override def jdbcUrlWithConf(jdbcUrl: String): String = {
67+
override protected def jdbcUrlWithConf(jdbcUrl: String): String = {
6868
val sessionConfStr = sessionConfigs.map(kv => kv._1 + "=" + kv._2).mkString(";")
6969
val jdbcConfStr =
7070
if (jdbcConfigs.isEmpty) {

kyuubi-common/src/test/scala/org/apache/kyuubi/operation/JDBCTestHelper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ trait JDBCTestHelper extends KyuubiFunSuite {
5252
}
5353

5454
def withMultipleConnectionJdbcStatement(
55-
tableNames: String*)(fs: (Statement => Unit)*): Unit = {
55+
tableNames: String*)(fs: (Statement => Unit)*): Unit = {
5656
val connections = fs.map { _ => DriverManager.getConnection(jdbcUrlWithConf, user, password) }
5757
val statements = connections.map(_.createStatement())
5858

kyuubi-server/src/main/scala/org/apache/kyuubi/server/mysql/MySQLCommandHandler.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object MySQLCommandHandler {
4242
class MySQLCommandHandler(be: BackendService, execPool: ThreadPoolExecutor)
4343
extends SimpleChannelInboundHandler[MySQLCommandPacket] with Logging {
4444

45-
private implicit val ec: ExecutionContextExecutor = ExecutionContext.fromExecutor(execPool)
45+
implicit private val ec: ExecutionContextExecutor = ExecutionContext.fromExecutor(execPool)
4646

4747
@volatile private var closed: Boolean = false
4848

@@ -131,31 +131,27 @@ class MySQLCommandHandler(be: BackendService, execPool: ThreadPoolExecutor)
131131

132132
def handlePing(
133133
ctx: ChannelHandlerContext,
134-
pkg: MySQLComPingPacket
135-
): Seq[MySQLPacket] = {
134+
pkg: MySQLComPingPacket): Seq[MySQLPacket] = {
136135
MySQLOKPacket(1) :: Nil
137136
}
138137

139138
def handleInitDb(
140139
ctx: ChannelHandlerContext,
141-
pkg: MySQLComInitDbPacket
142-
): Seq[MySQLPacket] = {
140+
pkg: MySQLComInitDbPacket): Seq[MySQLPacket] = {
143141
beExecuteStatement(ctx, s"use ${pkg.database}")
144142
MySQLOKPacket(1) :: Nil
145143
}
146144

147145
def handleQuit(
148146
ctx: ChannelHandlerContext,
149-
pkg: MySQLComQuitPacket
150-
): Seq[MySQLPacket] = {
147+
pkg: MySQLComQuitPacket): Seq[MySQLPacket] = {
151148
closeSession(ctx)
152149
MySQLOKPacket(1) :: Nil
153150
}
154151

155152
def handleQuery(
156153
ctx: ChannelHandlerContext,
157-
pkg: MySQLComQueryPacket
158-
): Seq[MySQLPacket] = {
154+
pkg: MySQLComQueryPacket): Seq[MySQLPacket] = {
159155
debug(s"Receive query: ${pkg.sql}")
160156
executeStatement(ctx, pkg.sql).toPackets
161157
}

kyuubi-server/src/main/scala/org/apache/kyuubi/server/mysql/MySQLQueryResult.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ trait MySQLQueryResult {
5858

5959
class MySQLSimpleQueryResult(
6060
schema: Seq[MySQLField],
61-
rows: Seq[Seq[Any]]
62-
) extends MySQLQueryResult {
61+
rows: Seq[Seq[Any]]) extends MySQLQueryResult {
6362

6463
override def colCount: Int = schema.size
6564

@@ -87,8 +86,7 @@ class MySQLSimpleQueryResult(
8786

8887
class MySQLThriftQueryResult(
8988
schema: TTableSchema,
90-
rows: TRowSet
91-
) extends MySQLQueryResult {
89+
rows: TRowSet) extends MySQLQueryResult {
9290

9391
override def colCount: Int = schema.getColumnsSize
9492

@@ -102,8 +100,7 @@ class MySQLThriftQueryResult(
102100

103101
private def tColDescToMySQL(
104102
tCol: TColumnDesc,
105-
sequenceId: Int
106-
): MySQLColumnDefinition41Packet = {
103+
sequenceId: Int): MySQLColumnDefinition41Packet = {
107104
val tType = tCol.getTypeDesc
108105
val dataType = tTypeDescToMySQL(tType)
109106
val decimals = 0 // TODO

kyuubi-server/src/test/scala/org/apache/kyuubi/server/mysql/MySQLJDBCTestHelper.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ trait MySQLJDBCTestHelper extends JDBCTestHelper {
3131
private val _jdbcConfigs: Map[String, String] = Map(
3232
"useSSL" -> "false")
3333

34-
protected override def sessionConfigs: Map[String, String] = Map.empty
34+
override protected def sessionConfigs: Map[String, String] = Map.empty
3535

36-
protected override def jdbcConfigs: Map[String, String] = _jdbcConfigs
36+
override protected def jdbcConfigs: Map[String, String] = _jdbcConfigs
3737

38-
protected override def jdbcVars: Map[String, String] = Map.empty
38+
override protected def jdbcVars: Map[String, String] = Map.empty
3939

4040
protected def jdbcUrlWithConf(jdbcUrl: String): String = {
4141
val jdbcConfStr =

pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,12 +1348,21 @@
13481348
<include>src/main/java/**/*.java</include>
13491349
<include>src/test/java/**/*.java</include>
13501350
</includes>
1351-
13521351
<googleJavaFormat>
13531352
<version>1.7</version>
13541353
<style>GOOGLE</style>
13551354
</googleJavaFormat>
13561355
</java>
1356+
<scala>
1357+
<includes>
1358+
<include>src/main/scala/**/*.scala</include>
1359+
<include>src/test/scala/**/*.scala</include>
1360+
</includes>
1361+
<scalafmt>
1362+
<version>3.1.1</version>
1363+
<file>${maven.multiModuleProjectDirectory}/.scalafmt.conf</file>
1364+
</scalafmt>
1365+
</scala>
13571366
</configuration>
13581367
<executions>
13591368
<execution>

0 commit comments

Comments
 (0)