diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-03-29 00:34:10 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-03-29 00:34:10 +0200 |
commit | 5b12fc5320ee347fbcb4514c442d22ae7e34d045 (patch) | |
tree | 1bd3e08a6c8c9835c1bb7d124af4a9ccb284b71b | |
parent | 8e0be3f950d7a012d6374eb27acb1a59cc3aa6e5 (diff) | |
download | kvision-5b12fc5320ee347fbcb4514c442d22ae7e34d045.tar.gz kvision-5b12fc5320ee347fbcb4514c442d22ae7e34d045.tar.bz2 kvision-5b12fc5320ee347fbcb4514c442d22ae7e34d045.zip |
Code style fixes.
11 files changed, 261 insertions, 165 deletions
@@ -1,14 +1,31 @@ autoCorrect: true failFast: false +test-pattern: # Configure exclusions for test sources + active: true + patterns: # Test file regexes + - '.*/test/.*' + - '.*Test.kt' + - '.*Spec.kt' + exclude-rule-sets: + - 'comments' + exclude-rules: + - 'NamingRules' + - 'WildcardImport' + - 'MagicNumber' + - 'MaxLineLength' + - 'LateinitUsage' + - 'StringLiteralDuplication' + - 'SpreadOperator' + - 'TooManyFunctions' + build: - warningThreshold: 5 - failThreshold: 10 + maxIssues: 10 weights: - complexity: 2 - formatting: 1 - LongParameterList: 1 - comments: 1 + # complexity: 2 + # LongParameterList: 1 + # style: 1 + # comments: 1 processors: active: true @@ -31,67 +48,78 @@ console-reports: output-reports: active: true exclude: + # - 'HtmlOutputReport' # - 'PlainOutputReport' # - 'XmlOutputReport' -potential-bugs: +comments: active: true - DuplicateCaseInWhenExpression: - active: true - EqualsAlwaysReturnsTrueOrFalse: + CommentOverPrivateFunction: active: false - EqualsWithHashCodeExist: - active: true - WrongEqualsTypeParameter: - active: false - ExplicitGarbageCollectionCall: - active: true - UnreachableCode: - active: true - LateinitUsage: + CommentOverPrivateProperty: active: false - UnsafeCallOnNullableType: + EndOfSentenceFormat: active: false - UnsafeCast: + endOfSentenceFormat: ([.?!][ \t\n\r\f<])|([.?!]$) + UndocumentedPublicClass: active: false - UselessPostfixExpression: + searchInNestedClass: true + searchInInnerClass: true + searchInInnerObject: true + searchInInnerInterface: true + UndocumentedPublicFunction: active: false -performance: +complexity: active: true - ForEachOnRange: + ComplexCondition: active: true - SpreadOperator: + threshold: 4 + ComplexInterface: + active: false + threshold: 10 + includeStaticDeclarations: false + ComplexMethod: active: true - UnnecessaryTemporaryInstantiation: + threshold: 10 + ignoreSingleWhenExpression: false + LabeledExpression: + active: false + LargeClass: active: true - -exceptions: - active: true - TooGenericExceptionCatched: - active: true - exceptions: - - ArrayIndexOutOfBoundsException - - Error - - Exception - - IllegalMonitorStateException - - IndexOutOfBoundsException - - NullPointerException - - RuntimeException - TooGenericExceptionThrown: + threshold: 150 + LongMethod: + active: true + threshold: 20 + LongParameterList: + active: true + threshold: 6 + ignoreDefaultParameters: true + MethodOverloading: + active: false + threshold: 6 + NestedBlockDepth: + active: true + threshold: 4 + StringLiteralDuplication: + active: false + threshold: 3 + ignoreAnnotation: true + excludeStringsWithLessThan5Characters: true + ignoreStringsRegex: '$^' + TooManyFunctions: active: true - exceptions: - - Throwable - - ThrowError - - ThrowException - - ThrowNullPointerException - - ThrowRuntimeException - - ThrowThrowable + thresholdInFiles: 11 + thresholdInClasses: 11 + thresholdInInterfaces: 11 + thresholdInObjects: 11 + thresholdInEnums: 11 empty-blocks: active: true EmptyCatchBlock: active: true + allowedExceptionNameRegex: "^(ignore|expected).*" EmptyClassBlock: active: true EmptyDefaultConstructor: @@ -110,6 +138,8 @@ empty-blocks: active: true EmptyInitBlock: active: true + EmptyKtFile: + active: true EmptySecondaryConstructor: active: true EmptyWhenBlock: @@ -117,176 +147,233 @@ empty-blocks: EmptyWhileBlock: active: true -complexity: +exceptions: active: true - LongMethod: - threshold: 20 - LongParameterList: - threshold: 5 - LargeClass: - threshold: 150 - ComplexMethod: - threshold: 10 - TooManyFunctions: - threshold: 10 - ComplexCondition: - threshold: 3 - LabeledExpression: + ExceptionRaisedInUnexpectedLocation: active: false - StringLiteralDuplication: + methodNames: 'toString,hashCode,equals,finalize' + InstanceOfCheckForException: active: false - threshold: 2 - ignoreAnnotation: true - excludeStringsWithLessThan5Characters: true - ignoreStringsRegex: '$^' - -code-smell: - active: true - FeatureEnvy: - threshold: 0.5 - weight: 0.45 - base: 0.5 + NotImplementedDeclaration: + active: false + PrintStackTrace: + active: false + RethrowCaughtException: + active: false + ReturnFromFinally: + active: false + SwallowedException: + active: false + ThrowingExceptionFromFinally: + active: false + ThrowingExceptionInMain: + active: false + ThrowingExceptionsWithoutMessageOrCause: + active: false + exceptions: 'IllegalArgumentException,IllegalStateException,IOException' + ThrowingNewInstanceOfSameException: + active: false + TooGenericExceptionCaught: + active: true + exceptionNames: + - ArrayIndexOutOfBoundsException + - Error + - Exception + - IllegalMonitorStateException + - NullPointerException + - IndexOutOfBoundsException + - RuntimeException + - Throwable + TooGenericExceptionThrown: + active: true + exceptionNames: + - Error + - Exception + - Throwable + - RuntimeException -formatting: +naming: active: true - useTabs: true - Indentation: + ClassNaming: + active: true + classPattern: '[A-Z$][a-zA-Z0-9$]*' + EnumNaming: + active: true + enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*' + ForbiddenClassName: active: false - indentSize: 4 - ConsecutiveBlankLines: + forbiddenName: '' + FunctionMaxLength: + active: false + maximumFunctionNameLength: 30 + FunctionMinLength: + active: false + minimumFunctionNameLength: 3 + FunctionNaming: active: true - autoCorrect: true - MultipleSpaces: + functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$' + excludeClassPattern: '$^' + MatchingDeclarationName: active: true - autoCorrect: true - SpacingAfterComma: + MemberNameEqualsClassName: + active: false + ignoreOverriddenFunction: true + ObjectPropertyNaming: active: true - autoCorrect: true - SpacingAfterKeyword: + propertyPattern: '[A-Za-z][_A-Za-z0-9]*' + PackageNaming: active: true - autoCorrect: true - SpacingAroundColon: + packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$' + TopLevelPropertyNaming: active: true - autoCorrect: true - SpacingAroundCurlyBraces: + constantPattern: '[A-Z][_A-Z0-9]*' + propertyPattern: '[a-z][A-Za-z\d]*' + privatePropertyPattern: '(_)?[a-z][A-Za-z0-9]*' + VariableMaxLength: + active: false + maximumVariableNameLength: 64 + VariableMinLength: + active: false + minimumVariableNameLength: 1 + VariableNaming: active: true - autoCorrect: true - SpacingAroundOperator: + variablePattern: '[a-z][A-Za-z0-9]*' + privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*' + excludeClassPattern: '$^' + +performance: + active: true + ForEachOnRange: active: true - autoCorrect: true - TrailingSpaces: + SpreadOperator: active: true - autoCorrect: true - UnusedImports: + UnnecessaryTemporaryInstantiation: + active: true + +potential-bugs: + active: true + DuplicateCaseInWhenExpression: active: true - autoCorrect: true - OptionalSemicolon: + EqualsAlwaysReturnsTrueOrFalse: + active: false + EqualsWithHashCodeExist: active: true - autoCorrect: true - OptionalUnit: + ExplicitGarbageCollectionCall: active: true - autoCorrect: true - ExpressionBodySyntax: + InvalidRange: + active: false + IteratorHasNextCallsNextMethod: + active: false + IteratorNotThrowingNoSuchElementException: active: false - autoCorrect: false - ExpressionBodySyntaxLineBreaks: + LateinitUsage: + active: false + excludeAnnotatedProperties: "" + ignoreOnClassesPattern: "" + UnconditionalJumpStatementInLoop: active: false - autoCorrect: false - OptionalReturnKeyword: + UnreachableCode: active: true - autoCorrect: false + UnsafeCallOnNullableType: + active: false + UnsafeCast: + active: false + UselessPostfixExpression: + active: false + WrongEqualsTypeParameter: + active: false style: active: true - ReturnCount: - active: true - max: 2 - NewLineAtEndOfFile: - active: true - OptionalAbstractKeyword: - active: true - OptionalWhenBraces: + CollapsibleIfStatements: + active: false + DataClassContainsFunctions: active: false + conversionFunctionPrefix: 'to' EqualsNullCall: active: false + ExpressionBodySyntax: + active: false ForbiddenComment: active: true values: 'TODO:,FIXME:,STOPSHIP:' ForbiddenImport: active: false imports: '' - ModifierOrder: - active: true + FunctionOnlyReturningConstant: + active: false + ignoreOverridableFunction: true + excludedFunctions: 'describeContents' + LoopWithTooManyJumpStatements: + active: false + maxJumpCount: 1 MagicNumber: active: true ignoreNumbers: '-1,0,1,2' ignoreHashCodeFunction: false ignorePropertyDeclaration: false + ignoreConstantDeclaration: true + ignoreCompanionObjectPropertyDeclaration: true ignoreAnnotation: false - WildcardImport: - active: true - SafeCast: - active: true + ignoreNamedArgument: true + ignoreEnums: false MaxLineLength: active: true maxLineLength: 120 excludePackageStatements: false excludeImportStatements: false - PackageNaming: - active: true - packagePattern: '^[a-z]+(\.[a-z][a-z0-9]*)*$' - ClassNaming: + MayBeConst: + active: false + ModifierOrder: active: true - classPattern: '[A-Z$][a-zA-Z$]*' - EnumNaming: + NestedClassesVisibility: + active: false + NewLineAtEndOfFile: active: true - enumEntryPattern: '^[A-Z$][a-zA-Z_$]*$' - FunctionNaming : + NoTabs: + active: false + OptionalAbstractKeyword: active: true - functionPattern: '^[a-z$][a-zA-Z$0-9]*$' - FunctionMaxLength: + OptionalUnit: active: false - maximumFunctionNameLength: 30 - FunctionMinLength: + OptionalWhenBraces: active: false - minimumFunctionNameLength: 3 - VariableNaming : + ProtectedMemberInFinalClass: + active: false + RedundantVisibilityModifierRule: + active: false + ReturnCount: active: true - variablePattern: '^(_)?[a-z$][a-zA-Z$0-9]*$' - ConstantNaming : + max: 2 + excludedFunctions: "equals" + SafeCast: active: true - constantPattern: '^([A-Z_]*|serialVersionUID)$' - VariableMaxLength: + SerialVersionUIDInSerializableClass: active: false - maximumVariableNameLength: 30 - VariableMinLength: + SpacingBetweenPackageAndImports: active: false - minimumVariableNameLength: 3 - ProtectedMemberInFinalClass: + ThrowsCount: + active: true + max: 2 + TrailingWhitespace: + active: false + UnnecessaryAbstractClass: + active: false + UnnecessaryInheritance: active: false UnnecessaryParentheses: active: false - -comments: - active: true - CommentOverPrivateMethod: - active: true - CommentOverPrivateProperty: - active: true - UndocumentedPublicClass: + UntilInsteadOfRangeTo: active: false - searchInNestedClass: true - searchInInnerClass: true - searchInInnerObject: true - searchInInnerInterface: true - UndocumentedPublicFunction: + UnusedImports: active: false - -# *experimental feature* -# Migration rules can be defined in the same config file or a new one -migration: - active: true - imports: - # your.package.Class: new.package.or.Class - # for example: - # io.gitlab.arturbosch.detekt.api.Rule: io.gitlab.arturbosch.detekt.rule.Rule + UnusedPrivateMember: + active: false + UseDataClass: + active: false + excludeAnnotatedClasses: "" + UtilityClassWithPublicConstructor: + active: false + WildcardImport: + active: true + excludeImports: 'java.util.*,kotlinx.android.synthetic.*' diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Component.kt b/src/main/kotlin/pl/treksoft/kvision/core/Component.kt index 659f8e1a..766d9f9c 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Component.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Component.kt @@ -29,6 +29,7 @@ import pl.treksoft.kvision.panel.Root /** * Base interface for all components. */ +@Suppress("TooManyFunctions") interface Component { /** * Parent of the current component. diff --git a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt index 9b759f79..c4ac8295 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/StyledComponent.kt @@ -27,6 +27,7 @@ import kotlin.reflect.KProperty /** * Base class for components supporting CSS styling. */ +@Suppress("LargeClass") abstract class StyledComponent : Component { private val propertyValues: MutableMap<String, Any?> = mutableMapOf() diff --git a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt index 61e9ba4e..30271cd0 100644 --- a/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt +++ b/src/main/kotlin/pl/treksoft/kvision/core/Widget.kt @@ -219,6 +219,7 @@ open class Widget(classes: Set<String> = setOf()) : StyledComponent() { * Returns list of event handlers in the form of a Snabbdom *On* object. * @return list of event handlers */ + @Suppress("ComplexMethod") protected open fun getSnOn(): com.github.snabbdom.On? { return if (internalListeners.size > 0 || listeners.size > 0) { val internalHandlers = on(this) diff --git a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt index 8900437b..b4ed127a 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/check/RadioGroup.kt @@ -45,6 +45,7 @@ import pl.treksoft.kvision.panel.SimplePanel * @param label label text of the options group * @param rich determines if [label] can contain HTML code */ +@Suppress("TooManyFunctions") open class RadioGroup( options: List<StringPair>? = null, value: String? = null, name: String? = null, inline: Boolean = false, label: String? = null, diff --git a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt index e318db35..d0bde3fe 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/spinner/SpinnerInput.kt @@ -169,6 +169,7 @@ open class SpinnerInput( return cl } + @Suppress("ComplexMethod") override fun getSnAttrs(): List<StringPair> { val sn = super.getSnAttrs().toMutableList() sn.add("type" to "text") diff --git a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt index 35418534..43e522d8 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/text/RichTextInput.kt @@ -62,7 +62,7 @@ open class RichTextInput(value: String? = null, classes: Set<String> = setOf()) return sn } - @Suppress("UnsafeCastFromDynamic") + @Suppress("UnsafeCastFromDynamic", "ComplexMethod") override fun afterInsert(node: VNode) { if (this.disabled || this.readonly == true) { this.getElementJQuery()?.removeAttr("contenteditable") diff --git a/src/main/kotlin/pl/treksoft/kvision/html/List.kt b/src/main/kotlin/pl/treksoft/kvision/html/List.kt index 020806ce..377b805f 100644 --- a/src/main/kotlin/pl/treksoft/kvision/html/List.kt +++ b/src/main/kotlin/pl/treksoft/kvision/html/List.kt @@ -93,6 +93,7 @@ open class ListTag( } } + @Suppress("ComplexCondition") override fun childrenVNodes(): Array<VNode> { val childrenElements = children.filter { it.visible } val res = when (type) { diff --git a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt index 3a5f25f2..7f1226af 100644 --- a/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt +++ b/src/main/kotlin/pl/treksoft/kvision/panel/DockPanel.kt @@ -97,7 +97,7 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit * @param position position in the dock * @return current container */ - @Suppress("MagicNumber") + @Suppress("MagicNumber", "ComplexMethod") open fun add(child: Component, position: Side): DockPanel { when (position) { Side.UP -> { @@ -152,6 +152,7 @@ open class DockPanel(classes: Set<String> = setOf(), init: (DockPanel.() -> Unit * @param position position in the dock * @return current container */ + @Suppress("ComplexMethod") open fun removeAt(position: Side): DockPanel { when (position) { Side.UP -> { diff --git a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt index 31a0913a..73fda1d2 100644 --- a/src/main/kotlin/pl/treksoft/kvision/table/Table.kt +++ b/src/main/kotlin/pl/treksoft/kvision/table/Table.kt @@ -35,6 +35,7 @@ enum class TableType(internal val type: String) { * @param classes a set of CSS class names * @param init an initializer extension function */ +@Suppress("TooManyFunctions") open class Table( headerNames: List<String>? = null, types: Set<TableType> = setOf(), caption: String? = null, responsive: Boolean = false, diff --git a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt index 728eff38..9607b01d 100644 --- a/src/main/kotlin/pl/treksoft/kvision/window/Window.kt +++ b/src/main/kotlin/pl/treksoft/kvision/window/Window.kt @@ -55,6 +55,7 @@ internal const val WINDOW_CONTENT_MARGIN_BOTTOM = 11 * @param classes a set of CSS class names * @param init an initializer extension function */ +@Suppress("TooManyFunctions") open class Window( caption: String? = null, contentWidth: CssSize? = CssSize(0, UNIT.auto), |