Added Scalastyle config
Fixed style check errors
This commit is contained in:
Родитель
1b2ae395ea
Коммит
5ca09106bc
|
@ -0,0 +1,150 @@
|
|||
<scalastyle commentFilter="enabled">
|
||||
<name>Scalastyle standard configuration</name>
|
||||
<check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="maxFileLength"><![CDATA[800]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.file.HeaderMatchesChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="header"><![CDATA[/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2018 Microsoft Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="maxLineLength"><![CDATA[160]]></parameter>
|
||||
<parameter name="tabSize"><![CDATA[4]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="maxParameters"><![CDATA[8]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="ignore"><![CDATA[-1,0,1,2,3]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.NullChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="regex"><![CDATA[println]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="maxTypes"><![CDATA[30]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="maximum"><![CDATA[15]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
|
||||
<parameter name="doubleLineAllowed"><![CDATA[false]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="maxLength"><![CDATA[70]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="maxMethods"><![CDATA[30]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.file.NewLineAtEofChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.WhileChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.VarFieldChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.VarLocalChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.RedundantIfChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
|
||||
<parameters>
|
||||
<parameter name="regex"><![CDATA[println]]></parameter>
|
||||
</parameters>
|
||||
<customMessage>Avoid print line, use logger.</customMessage>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.DeprecatedJavaChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.EmptyClassChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.ClassTypeParameterChecker" enabled="false">
|
||||
<parameters>
|
||||
<parameter name="regex"><![CDATA[^[A-Z_]$]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.UnderscoreImportChecker" enabled="false"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.LowercasePatternMatchChecker" enabled="true"></check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.MultipleStringLiteralsChecker" enabled="false">
|
||||
<parameters>
|
||||
<parameter name="allowed"><![CDATA[2]]></parameter>
|
||||
<parameter name="ignoreRegex"><![CDATA[^""$]]></parameter>
|
||||
</parameters>
|
||||
</check>
|
||||
<check level="warning" class="org.scalastyle.scalariform.ImportGroupingChecker" enabled="true"></check>
|
||||
</scalastyle>
|
1
pom.xml
1
pom.xml
|
@ -134,7 +134,6 @@
|
|||
<sourceDirectory>${project.basedir}/src/main/scala</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/scala</testSourceDirectory>
|
||||
<configLocation>${project.basedir}/lib/scalastyle_config.xml</configLocation>
|
||||
<outputFile>${project.basedir}/scalastyle-output.xml</outputFile>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
package com.microsoft.azure.sqldb.spark.config
|
||||
|
||||
import com.microsoft.azure.sqldb.spark.config.Config._
|
||||
import com.microsoft.azure.sqldb.spark.config.Config.Property
|
||||
|
||||
case class SqlDBConfigBuilder(props: Map[Property, Any] = Map()) extends {
|
||||
|
||||
|
|
|
@ -66,4 +66,4 @@ package object connect {
|
|||
@DeveloperApi
|
||||
implicit def toDataFrameFunctions[T](ds: Dataset[T]): DataFrameFunctions[Row] = DataFrameFunctions[Row](ds.toDF())
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,5 +41,5 @@ package object query {
|
|||
*/
|
||||
@DeveloperApi
|
||||
implicit def toQueryFunctions(sqlContext: SQLContext): QueryFunctions = QueryFunctions(sqlContext)
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,27 @@
|
|||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2018 Microsoft Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.microsoft.azure.sqldb.spark
|
||||
|
||||
import org.scalatest.{BeforeAndAfter, BeforeAndAfterEach, FlatSpec, Matchers}
|
||||
|
||||
trait SqlDBSpark extends FlatSpec with Matchers with BeforeAndAfter with BeforeAndAfterEach {
|
||||
|
||||
}
|
||||
trait SqlDBSpark extends FlatSpec with Matchers with BeforeAndAfter with BeforeAndAfterEach
|
||||
|
|
|
@ -1,3 +1,25 @@
|
|||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2018 Microsoft Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package com.microsoft.azure.sqldb.spark.bulk
|
||||
|
||||
import com.microsoft.azure.sqldb.spark.SqlDBSpark
|
||||
|
|
|
@ -27,20 +27,20 @@ import com.microsoft.azure.sqldb.spark.SqlDBSpark
|
|||
class ConfigSpec extends SqlDBSpark {
|
||||
|
||||
it should "throw IllegalArgumentException if required properties aren't met" in {
|
||||
a [IllegalArgumentException] should be thrownBy {
|
||||
an [IllegalArgumentException] should be thrownBy {
|
||||
Config(Map("url" -> "mysql.database.windows.net"))
|
||||
}
|
||||
}
|
||||
|
||||
it should "throw IllegalArgumentException if queryCustom and dbTable are both stated" in {
|
||||
a [IllegalArgumentException] should be thrownBy {
|
||||
an [IllegalArgumentException] should be thrownBy {
|
||||
Config(Map(
|
||||
"url" -> "mysql.database.windows.net",
|
||||
"databaseName" -> "",
|
||||
"user" -> "",
|
||||
"password" -> "",
|
||||
"dbTable" -> "",
|
||||
"QueryCustom" -> ""
|
||||
"databaseName" -> "MyDatabase",
|
||||
"user" -> "MyUsername",
|
||||
"password" -> "**********",
|
||||
"dbTable" -> "MyDBTable",
|
||||
"QueryCustom" -> "MyQueryCustom"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,4 +86,4 @@ class ConnectionUtilsSpec extends SqlDBSpark {
|
|||
))
|
||||
ConnectionUtils.getTableOrQuery(queryConfig) should be (ConnectionUtils.getQueryCustom(queryCustom))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче