From c4d5b74cefc697ced8a5051d206e90ce26130423 Mon Sep 17 00:00:00 2001 From: aktsay6 Date: Tue, 9 Feb 2021 14:50:37 +0300 Subject: [PATCH] bugfix/newlinesrule(#748) ### What's done: * Fixed bugs --- .../cqfn/diktat/ruleset/rules/chapter1/FileNaming.kt | 6 +++--- .../ruleset/rules/chapter2/comments/CommentsRule.kt | 6 +++--- .../ruleset/rules/chapter2/kdoc/KdocComments.kt | 8 ++++---- .../ruleset/rules/chapter2/kdoc/KdocFormatting.kt | 10 +++++----- .../ruleset/rules/chapter2/kdoc/KdocMethods.kt | 8 ++++---- .../ruleset/rules/chapter3/AnnotationNewLineRule.kt | 6 +++--- .../ruleset/rules/chapter3/BlockStructureBraces.kt | 6 +++--- .../chapter3/BracesInConditionalsAndLoopsRule.kt | 6 +++--- .../rules/chapter3/ClassLikeStructuresOrderRule.kt | 6 +++--- .../ruleset/rules/chapter3/ConsecutiveSpacesRule.kt | 6 +++--- .../cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt | 6 +++--- .../diktat/ruleset/rules/chapter3/EnumsSeparated.kt | 6 +++--- .../cqfn/diktat/ruleset/rules/chapter3/LineLength.kt | 6 +++--- .../chapter3/LongNumericalValuesSeparatedRule.kt | 6 +++--- .../rules/chapter3/MultipleModifiersSequence.kt | 6 +++--- .../ruleset/rules/chapter3/NullableTypeRule.kt | 6 +++--- .../rules/chapter3/SingleLineStatementsRule.kt | 6 +++--- .../cqfn/diktat/ruleset/rules/chapter3/SortRule.kt | 6 +++--- .../rules/chapter3/StringConcatenationRule.kt | 6 +++--- .../rules/chapter3/StringTemplateFormatRule.kt | 6 +++--- .../ruleset/rules/chapter3/TrailingCommaRule.kt | 6 +++--- .../ruleset/rules/chapter3/WhenMustHaveElseRule.kt | 6 +++--- .../ruleset/rules/chapter3/files/BlankLinesRule.kt | 6 +++--- .../diktat/ruleset/rules/chapter3/files/FileSize.kt | 6 +++--- .../ruleset/rules/chapter3/files/IndentationRule.kt | 6 +++--- .../ruleset/rules/chapter3/files/NewlinesRule.kt | 12 ++++++------ .../rules/chapter3/files/TopLevelOrderRule.kt | 6 +++--- .../ruleset/rules/chapter3/files/WhiteSpaceRule.kt | 6 +++--- .../rules/chapter3/identifiers/LocalVariablesRule.kt | 6 +++--- .../ruleset/rules/chapter4/ImmutableValNoVarRule.kt | 6 +++--- .../diktat/ruleset/rules/chapter4/NullChecksRule.kt | 6 +++--- .../diktat/ruleset/rules/chapter4/SmartCastRule.kt | 6 +++--- .../diktat/ruleset/rules/chapter4/TypeAliasRule.kt | 6 +++--- .../chapter4/VariableGenericTypeDeclarationRule.kt | 6 +++--- .../calculations/AccurateCalculationsRule.kt | 6 +++--- .../ruleset/rules/chapter5/AsyncAndSyncRule.kt | 6 +++--- .../rules/chapter5/AvoidNestedFunctionsRule.kt | 6 +++--- .../ruleset/rules/chapter5/CheckInverseMethodRule.kt | 6 +++--- .../diktat/ruleset/rules/chapter5/CustomLabel.kt | 6 +++--- .../ruleset/rules/chapter5/FunctionArgumentsSize.kt | 6 +++--- .../diktat/ruleset/rules/chapter5/FunctionLength.kt | 6 +++--- .../ruleset/rules/chapter5/LambdaLengthRule.kt | 6 +++--- .../ruleset/rules/chapter5/LambdaParameterOrder.kt | 6 +++--- .../ruleset/rules/chapter5/NestedFunctionBlock.kt | 6 +++--- .../rules/chapter5/OverloadingArgumentsFunction.kt | 6 +++--- .../rules/chapter6/AvoidEmptyPrimaryConstructor.kt | 6 +++--- .../ruleset/rules/chapter6/AvoidUtilityClass.kt | 6 +++--- .../ruleset/rules/chapter6/CustomGetterSetterRule.kt | 6 +++--- .../rules/chapter6/ExtensionFunctionsSameNameRule.kt | 6 +++--- .../rules/chapter6/ImplicitBackingPropertyRule.kt | 6 +++--- .../ruleset/rules/chapter6/PropertyAccessorFields.kt | 6 +++--- .../rules/chapter6/TrivialPropertyAccessors.kt | 6 +++--- .../ruleset/rules/chapter6/UselessSupertype.kt | 6 +++--- .../rules/chapter6/classes/AbstractClassesRule.kt | 6 +++--- .../rules/chapter6/classes/CompactInitialization.kt | 6 +++--- .../rules/chapter6/classes/DataClassesRule.kt | 6 +++--- .../rules/chapter6/classes/InlineClassesRule.kt | 6 +++--- .../rules/chapter6/classes/SingleConstructorRule.kt | 6 +++--- .../ruleset/rules/chapter6/classes/SingleInitRule.kt | 6 +++--- .../rules/chapter6/classes/StatelessClassesRule.kt | 6 +++--- 60 files changed, 187 insertions(+), 187 deletions(-) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/FileNaming.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/FileNaming.kt index b9efe14a6e..8c89d666d8 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/FileNaming.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/FileNaming.kt @@ -27,9 +27,9 @@ import java.io.File */ @Suppress("ForbiddenComment") class FileNaming(configRules: List) : DiktatRule( - "file-naming", - configRules, - listOf(FILE_NAME_INCORRECT, FILE_NAME_MATCH_CLASS)) { + "file-naming", + configRules, + listOf(FILE_NAME_INCORRECT, FILE_NAME_MATCH_CLASS)) { private lateinit var filePath: String override fun logic(node: ASTNode) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt index f59ba81fc4..4b60e373ed 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/CommentsRule.kt @@ -24,9 +24,9 @@ import org.jetbrains.kotlin.resolve.ImportPath */ @Suppress("ForbiddenComment") class CommentsRule(configRules: List) : DiktatRule( - "comments", - configRules, - listOf(COMMENTED_OUT_CODE)) { + "comments", + configRules, + listOf(COMMENTED_OUT_CODE)) { private lateinit var ktPsiFactory: KtPsiFactory override fun logic(node: ASTNode) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt index c667931d4b..0808ee0c34 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocComments.kt @@ -45,10 +45,10 @@ import org.jetbrains.kotlin.psi.psiUtil.parents * 3) All properties declared in the primary constructor are documented using `@property` tag in class KDoc */ class KdocComments(configRules: List) : DiktatRule( - "kdoc-comments", - configRules, - listOf(KDOC_EXTRA_PROPERTY, KDOC_NO_CONSTRUCTOR_PROPERTY, - KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT, MISSING_KDOC_CLASS_ELEMENTS, MISSING_KDOC_TOP_LEVEL)) { + "kdoc-comments", + configRules, + listOf(KDOC_EXTRA_PROPERTY, KDOC_NO_CONSTRUCTOR_PROPERTY, + KDOC_NO_CONSTRUCTOR_PROPERTY_WITH_COMMENT, MISSING_KDOC_CLASS_ELEMENTS, MISSING_KDOC_TOP_LEVEL)) { /** * @param node * @param autoCorrect diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt index d1321bee02..e958a8a0fb 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocFormatting.kt @@ -60,11 +60,11 @@ import java.time.temporal.ChronoField */ @Suppress("ForbiddenComment") class KdocFormatting(configRules: List) : DiktatRule( - "kdoc-formatting", - configRules, - listOf(KDOC_CONTAINS_DATE_OR_AUTHOR, KDOC_EMPTY_KDOC, KDOC_NEWLINES_BEFORE_BASIC_TAGS, KDOC_NO_DEPRECATED_TAG, - KDOC_NO_EMPTY_TAGS, KDOC_NO_NEWLINES_BETWEEN_BASIC_TAGS, KDOC_NO_NEWLINE_AFTER_SPECIAL_TAGS, - KDOC_WRONG_SPACES_AFTER_TAG, KDOC_WRONG_TAGS_ORDER)) { + "kdoc-formatting", + configRules, + listOf(KDOC_CONTAINS_DATE_OR_AUTHOR, KDOC_EMPTY_KDOC, KDOC_NEWLINES_BEFORE_BASIC_TAGS, KDOC_NO_DEPRECATED_TAG, + KDOC_NO_EMPTY_TAGS, KDOC_NO_NEWLINES_BETWEEN_BASIC_TAGS, KDOC_NO_NEWLINE_AFTER_SPECIAL_TAGS, + KDOC_WRONG_SPACES_AFTER_TAG, KDOC_WRONG_TAGS_ORDER)) { private val basicTagsList = listOf(KDocKnownTag.PARAM, KDocKnownTag.RETURN, KDocKnownTag.THROWS) private val specialTagNames = setOf("implSpec", "implNote", "apiNote") private var versionRegex: Regex? = null diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt index f3d4bbdf7f..3989b9b9e6 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt @@ -66,10 +66,10 @@ import org.jetbrains.kotlin.psi.psiUtil.referenceExpression */ @Suppress("ForbiddenComment") class KdocMethods(configRules: List) : DiktatRule( - "kdoc-methods", - configRules, - listOf(KDOC_TRIVIAL_KDOC_ON_FUNCTION, KDOC_WITHOUT_PARAM_TAG, KDOC_WITHOUT_RETURN_TAG, - KDOC_WITHOUT_THROWS_TAG, MISSING_KDOC_ON_FUNCTION)) { + "kdoc-methods", + configRules, + listOf(KDOC_TRIVIAL_KDOC_ON_FUNCTION, KDOC_WITHOUT_PARAM_TAG, KDOC_WITHOUT_RETURN_TAG, + KDOC_WITHOUT_THROWS_TAG, MISSING_KDOC_ON_FUNCTION)) { /** * @param node * @param autoCorrect diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/AnnotationNewLineRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/AnnotationNewLineRule.kt index 394eb9e7c8..ec025d6f15 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/AnnotationNewLineRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/AnnotationNewLineRule.kt @@ -20,9 +20,9 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl * This rule makes each annotation applied to a class, method or constructor is on its own line. Except: if first annotation of constructor, class or method */ class AnnotationNewLineRule(configRules: List) : DiktatRule( - "annotation-new-line", - configRules, - listOf(ANNOTATION_NEW_LINE)) { + "annotation-new-line", + configRules, + listOf(ANNOTATION_NEW_LINE)) { override fun logic(node: ASTNode) { when (node.elementType) { CLASS, FUN, PRIMARY_CONSTRUCTOR, SECONDARY_CONSTRUCTOR -> checkAnnotation(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BlockStructureBraces.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BlockStructureBraces.kt index 8b4aec3074..49a15eab5c 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BlockStructureBraces.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BlockStructureBraces.kt @@ -50,9 +50,9 @@ import org.jetbrains.kotlin.psi.KtTryExpression * - braces around `else`/`catch`/`finally`/`while` (in `do-while` loop) */ class BlockStructureBraces(configRules: List) : DiktatRule( - "block-structure", - configRules, - listOf(BRACES_BLOCK_STRUCTURE_ERROR)) { + "block-structure", + configRules, + listOf(BRACES_BLOCK_STRUCTURE_ERROR)) { override fun logic(node: ASTNode) { val configuration = BlockStructureBracesConfiguration( configRules.getRuleConfig(BRACES_BLOCK_STRUCTURE_ERROR)?.configuration ?: emptyMap() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BracesInConditionalsAndLoopsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BracesInConditionalsAndLoopsRule.kt index afacad5b96..4b72d25e09 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BracesInConditionalsAndLoopsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/BracesInConditionalsAndLoopsRule.kt @@ -35,9 +35,9 @@ import org.jetbrains.kotlin.psi.psiUtil.astReplace * Rule that checks that all conditionals and loops have braces. */ class BracesInConditionalsAndLoopsRule(configRules: List) : DiktatRule( - "braces-rule", - configRules, - listOf(NO_BRACES_IN_CONDITIONALS_AND_LOOPS)) { + "braces-rule", + configRules, + listOf(NO_BRACES_IN_CONDITIONALS_AND_LOOPS)) { override fun logic(node: ASTNode) { when (node.elementType) { IF -> checkIfNode(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ClassLikeStructuresOrderRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ClassLikeStructuresOrderRule.kt index 2583ee2efe..49a1f37e52 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ClassLikeStructuresOrderRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ClassLikeStructuresOrderRule.kt @@ -42,9 +42,9 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings * Rule that checks order of declarations inside classes, interfaces and objects. */ class ClassLikeStructuresOrderRule(configRules: List) : DiktatRule( - "class-like-structures", - configRules, - listOf(BLANK_LINE_BETWEEN_PROPERTIES, WRONG_ORDER_IN_CLASS_LIKE_STRUCTURES)) { + "class-like-structures", + configRules, + listOf(BLANK_LINE_BETWEEN_PROPERTIES, WRONG_ORDER_IN_CLASS_LIKE_STRUCTURES)) { override fun logic(node: ASTNode) { if (node.elementType == CLASS_BODY) { checkDeclarationsOrderInClass(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ConsecutiveSpacesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ConsecutiveSpacesRule.kt index 8cf144fb9b..73411dc604 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ConsecutiveSpacesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/ConsecutiveSpacesRule.kt @@ -21,9 +21,9 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafElement * */ class ConsecutiveSpacesRule(configRules: List) : DiktatRule( - "too-many-spaces", - configRules, - listOf(TOO_MANY_CONSECUTIVE_SPACES)) { + "too-many-spaces", + configRules, + listOf(TOO_MANY_CONSECUTIVE_SPACES)) { override fun logic(node: ASTNode) { val configuration = TooManySpacesRuleConfiguration( configRules.getRuleConfig(TOO_MANY_CONSECUTIVE_SPACES)?.configuration ?: emptyMap()) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt index fc487dc039..1034ed1063 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EmptyBlock.kt @@ -26,9 +26,9 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl * Rule that checks if empty code blocks (`{ }`) are used and checks their formatting. */ class EmptyBlock(configRules: List) : DiktatRule( - "empty-block-structure", - configRules, - listOf(EMPTY_BLOCK_STRUCTURE_ERROR)) { + "empty-block-structure", + configRules, + listOf(EMPTY_BLOCK_STRUCTURE_ERROR)) { override fun logic(node: ASTNode) { val configuration = EmptyBlockStyleConfiguration( configRules.getRuleConfig(EMPTY_BLOCK_STRUCTURE_ERROR)?.configuration ?: emptyMap() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EnumsSeparated.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EnumsSeparated.kt index 3091b9cb6e..fe607214c4 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EnumsSeparated.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/EnumsSeparated.kt @@ -27,9 +27,9 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl * Rule that checks enum classes formatting */ class EnumsSeparated(configRules: List) : DiktatRule( - "enum-separated", - configRules, - listOf(ENUMS_SEPARATED)) { + "enum-separated", + configRules, + listOf(ENUMS_SEPARATED)) { override fun logic(node: ASTNode) { if (node.elementType == CLASS && node.hasChildOfType(CLASS_BODY)) { if (node.isClassEnum()) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt index 161d63dbd0..a259e7c3f4 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LineLength.kt @@ -58,9 +58,9 @@ import java.net.URL */ @Suppress("ForbiddenComment") class LineLength(configRules: List) : DiktatRule( - "line-length", - configRules, - listOf(LONG_LINE)) { + "line-length", + configRules, + listOf(LONG_LINE)) { private lateinit var positionByOffset: (Int) -> Pair override fun logic(node: ASTNode) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt index e0616f9e19..556b79cff2 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/LongNumericalValuesSeparatedRule.kt @@ -17,9 +17,9 @@ import java.lang.StringBuilder * Rule that checks if numerical separators (`_`) are used for long numerical literals */ class LongNumericalValuesSeparatedRule(configRules: List) : DiktatRule( - "long-numerical-values", - configRules, - listOf(LONG_NUMERICAL_VALUES_SEPARATED)) { + "long-numerical-values", + configRules, + listOf(LONG_NUMERICAL_VALUES_SEPARATED)) { override fun logic(node: ASTNode) { val configuration = LongNumericalValuesConfiguration( configRules.getRuleConfig(LONG_NUMERICAL_VALUES_SEPARATED)?.configuration ?: emptyMap()) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MultipleModifiersSequence.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MultipleModifiersSequence.kt index a33feb127e..a326996341 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MultipleModifiersSequence.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MultipleModifiersSequence.kt @@ -16,9 +16,9 @@ import org.jetbrains.kotlin.psi.psiUtil.children * @property configRules */ class MultipleModifiersSequence(configRules: List) : DiktatRule( - "multiple-modifiers", - configRules, - listOf(WRONG_MULTIPLE_MODIFIERS_ORDER)) { + "multiple-modifiers", + configRules, + listOf(WRONG_MULTIPLE_MODIFIERS_ORDER)) { override fun logic(node: ASTNode) { if (node.elementType == MODIFIER_LIST) { checkModifierList(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/NullableTypeRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/NullableTypeRule.kt index 4c7ece779a..6ef6d78631 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/NullableTypeRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/NullableTypeRule.kt @@ -38,9 +38,9 @@ import org.jetbrains.kotlin.com.intellij.psi.tree.IElementType * Rule that checks if nullable types are used and suggest to substitute them with non-nullable */ class NullableTypeRule(configRules: List) : DiktatRule( - "nullable-type", - configRules, - listOf(NULLABLE_PROPERTY_TYPE)) { + "nullable-type", + configRules, + listOf(NULLABLE_PROPERTY_TYPE)) { override fun logic(node: ASTNode) { if (node.elementType == PROPERTY) { checkProperty(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SingleLineStatementsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SingleLineStatementsRule.kt index b72b53b108..a4fc8ec5e4 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SingleLineStatementsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SingleLineStatementsRule.kt @@ -19,9 +19,9 @@ import org.jetbrains.kotlin.com.intellij.psi.tree.TokenSet * Rule that looks for multiple statements on a single line separated with a `;` and splits them in multiple lines. */ class SingleLineStatementsRule(configRules: List) : DiktatRule( - "statement", - configRules, - listOf(MORE_THAN_ONE_STATEMENT_PER_LINE)) { + "statement", + configRules, + listOf(MORE_THAN_ONE_STATEMENT_PER_LINE)) { override fun logic(node: ASTNode) { checkSemicolon(node) } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt index 52d553e2c1..e9d2726fc8 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/SortRule.kt @@ -27,9 +27,9 @@ import org.jetbrains.kotlin.psi.KtObjectDeclaration * Rule that sorts class properties and enum members alphabetically */ class SortRule(configRules: List) : DiktatRule( - "sort-rule", - configRules, - listOf(WRONG_DECLARATIONS_ORDER)) { + "sort-rule", + configRules, + listOf(WRONG_DECLARATIONS_ORDER)) { override fun logic(node: ASTNode) { val configuration = SortRuleConfiguration( configRules.getRuleConfig(WRONG_DECLARATIONS_ORDER)?.configuration ?: emptyMap() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringConcatenationRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringConcatenationRule.kt index 1ac972c458..9b2be11948 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringConcatenationRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringConcatenationRule.kt @@ -20,9 +20,9 @@ import org.jetbrains.kotlin.com.intellij.lang.ASTNode * // FixMe: .toString() method and functions that return strings are not supported */ class StringConcatenationRule(configRules: List) : DiktatRule( - "string-concatenation", - configRules, - listOf(STRING_CONCATENATION)) { + "string-concatenation", + configRules, + listOf(STRING_CONCATENATION)) { override fun logic(node: ASTNode) { if (node.elementType == BINARY_EXPRESSION) { // searching top-level binary expression to detect any operations with "plus" (+) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringTemplateFormatRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringTemplateFormatRule.kt index 27be97a66d..40d5b607cf 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringTemplateFormatRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/StringTemplateFormatRule.kt @@ -29,9 +29,9 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement * FixMe: The important caveat here: in "$foo" kotlin compiler adds implicit call to foo.toString() in case foo type is not string. */ class StringTemplateFormatRule(configRules: List) : DiktatRule( - "string-template-format", - configRules, - listOf(STRING_TEMPLATE_CURLY_BRACES, STRING_TEMPLATE_QUOTES)) { + "string-template-format", + configRules, + listOf(STRING_TEMPLATE_CURLY_BRACES, STRING_TEMPLATE_QUOTES)) { override fun logic(node: ASTNode) { when (node.elementType) { LONG_STRING_TEMPLATE_ENTRY -> handleLongStringTemplate(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt index f8b136ee6c..6e288e23af 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/TrailingCommaRule.kt @@ -50,9 +50,9 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings */ @Suppress("TOO_LONG_FUNCTION") class TrailingCommaRule(configRules: List) : DiktatRule( - "trailing-comma", - configRules, - listOf(TRAILING_COMMA)) { + "trailing-comma", + configRules, + listOf(TRAILING_COMMA)) { private val commonConfig by configRules.getCommonConfiguration() private val trailingConfig = this.configRules.getRuleConfig(TRAILING_COMMA)?.configuration ?: emptyMap() private val configuration by lazy { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/WhenMustHaveElseRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/WhenMustHaveElseRule.kt index 8e5102a585..98f289431a 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/WhenMustHaveElseRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/WhenMustHaveElseRule.kt @@ -37,9 +37,9 @@ import org.jetbrains.kotlin.psi.KtWhenExpression */ @Suppress("ForbiddenComment") class WhenMustHaveElseRule(configRules: List) : DiktatRule( - "no-else-in-when", - configRules, - listOf(WHEN_WITHOUT_ELSE)) { + "no-else-in-when", + configRules, + listOf(WHEN_WITHOUT_ELSE)) { override fun logic(node: ASTNode) { if (node.elementType == ElementType.WHEN && isStatement(node)) { checkEntries(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/BlankLinesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/BlankLinesRule.kt index 4a4ec205c1..d055ffbf7f 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/BlankLinesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/BlankLinesRule.kt @@ -24,9 +24,9 @@ import org.jetbrains.kotlin.com.intellij.lang.ASTNode * 2. Checks that blank lines are not put in the beginning or at the end of code blocks with curly braces */ class BlankLinesRule(configRules: List) : DiktatRule( - "blank-lines", - configRules, - listOf(TOO_MANY_BLANK_LINES)) { + "blank-lines", + configRules, + listOf(TOO_MANY_BLANK_LINES)) { override fun logic(node: ASTNode) { if (node.elementType == WHITE_SPACE) { // note that no blank lines counts as one newline diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileSize.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileSize.kt index 0fcc3a08eb..461c9ec925 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileSize.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileSize.kt @@ -16,9 +16,9 @@ import org.slf4j.LoggerFactory * Rule that checks number of lines in a file */ class FileSize(configRules: List) : DiktatRule( - "file-size", - configRules, - listOf(FILE_IS_TOO_LONG)) { + "file-size", + configRules, + listOf(FILE_IS_TOO_LONG)) { private val configuration by lazy { FileSizeConfiguration( this.configRules.getRuleConfig(FILE_IS_TOO_LONG)?.configuration ?: emptyMap() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt index fc8f6bd8bd..1e8218d90b 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/IndentationRule.kt @@ -65,9 +65,9 @@ import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult * @see CustomIndentationChecker */ class IndentationRule(configRules: List) : DiktatRule( - "indentation", - configRules, - listOf(WRONG_INDENTATION)) { + "indentation", + configRules, + listOf(WRONG_INDENTATION)) { private val configuration: IndentationConfig by lazy { IndentationConfig(configRules.getRuleConfig(WRONG_INDENTATION)?.configuration ?: emptyMap()) } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt index 1d92498a97..6fd0653518 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt @@ -97,9 +97,9 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings */ @Suppress("ForbiddenComment") class NewlinesRule(configRules: List) : DiktatRule( - "newlines", - configRules, - listOf(COMPLEX_EXPRESSION, REDUNDANT_SEMICOLON, WRONG_NEWLINES)) { + "newlines", + configRules, + listOf(COMPLEX_EXPRESSION, REDUNDANT_SEMICOLON, WRONG_NEWLINES)) { private val configuration by lazy { NewlinesRuleConfiguration(configRules.getRuleConfig(WRONG_NEWLINES)?.configuration ?: emptyMap()) } @@ -346,9 +346,9 @@ class NewlinesRule(configRules: List) : DiktatRule( .filter { it.elementType == filterType } .toList() .takeIf { it.size > 1 } - ?.let { + ?.let { list -> val freeText = if (filterType == VALUE_ARGUMENT) { - warnText.format(it.first().text) + warnText.format(list.first().text) } else { warnText } @@ -371,7 +371,7 @@ class NewlinesRule(configRules: List) : DiktatRule( .toList() .takeIf { it.isNotEmpty() } ?.let { invalidCommas -> - val warnText = if (node.getParentIdentifier() != null) { + val warnText = if (node.getParentIdentifier() ?: false) { "$entryType should be placed on different lines in declaration of <${node.getParentIdentifier()}>" } else { "$entryType should be placed on different lines" diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/TopLevelOrderRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/TopLevelOrderRule.kt index 1fb5e219c6..473d3b3627 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/TopLevelOrderRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/TopLevelOrderRule.kt @@ -26,9 +26,9 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings * Rule that checks order in top level */ class TopLevelOrderRule(configRules: List) : DiktatRule( - "top-level-order", - configRules, - listOf(TOP_LEVEL_ORDER)) { + "top-level-order", + configRules, + listOf(TOP_LEVEL_ORDER)) { override fun logic(node: ASTNode) { if (node.elementType == FILE) { checkNode(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt index 4064509b51..254de14f43 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/WhiteSpaceRule.kt @@ -93,9 +93,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf */ @Suppress("ForbiddenComment") class WhiteSpaceRule(configRules: List) : DiktatRule( - "horizontal-whitespace", - configRules, - listOf(WRONG_WHITESPACE)) { + "horizontal-whitespace", + configRules, + listOf(WRONG_WHITESPACE)) { @Suppress("ComplexMethod") override fun logic(node: ASTNode) { when (node.elementType) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/identifiers/LocalVariablesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/identifiers/LocalVariablesRule.kt index 2866bd5dae..8170e552c3 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/identifiers/LocalVariablesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/identifiers/LocalVariablesRule.kt @@ -38,9 +38,9 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset * * Properties initialized with constructor calls cannot be distinguished from method call and are no supported. */ class LocalVariablesRule(configRules: List) : DiktatRule( - "local-variables", - configRules, - listOf(LOCAL_VARIABLE_EARLY_DECLARATION)) { + "local-variables", + configRules, + listOf(LOCAL_VARIABLE_EARLY_DECLARATION)) { override fun logic(node: ASTNode) { if (node.elementType == FILE) { // collect all local properties and associate with corresponding references diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/ImmutableValNoVarRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/ImmutableValNoVarRule.kt index ee2153df4c..520772ed87 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/ImmutableValNoVarRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/ImmutableValNoVarRule.kt @@ -20,9 +20,9 @@ import org.jetbrains.kotlin.psi.psiUtil.getParentOfType * FixMe: here we should also raise warnings for a reassignment of a var (if var has no assignments except in declaration - it can be final) */ class ImmutableValNoVarRule(configRules: List) : DiktatRule( - "no-var-rule", - configRules, - listOf(SAY_NO_TO_VAR)) { + "no-var-rule", + configRules, + listOf(SAY_NO_TO_VAR)) { override fun logic(node: ASTNode) { if (node.elementType == ElementType.FILE) { // we will raise warning for cases when var property has no assignments diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt index 86dfef5c5f..51ce63c06d 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/NullChecksRule.kt @@ -27,9 +27,9 @@ import org.jetbrains.kotlin.psi.KtIfExpression * There are several code-structures that can be used in Kotlin to avoid null-checks. For example: `?:`, `.let {}`, `.also {}`, e.t.c */ class NullChecksRule(configRules: List) : DiktatRule( - "null-checks", - configRules, - listOf(AVOID_NULL_CHECKS)) { + "null-checks", + configRules, + listOf(AVOID_NULL_CHECKS)) { override fun logic(node: ASTNode) { if (node.elementType == CONDITION) { node.parent(IF)?.let { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt index f1bfef6011..e34ceb96cb 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/SmartCastRule.kt @@ -40,9 +40,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parents * Rule that detects redundant explicit casts */ class SmartCastRule(configRules: List) : DiktatRule( - "smart-cast-rule", - configRules, - listOf(SMART_CAST_NEEDED)) { + "smart-cast-rule", + configRules, + listOf(SMART_CAST_NEEDED)) { override fun logic(node: ASTNode) { if (node.elementType == FILE) { val usages = collectLocalPropertiesWithUsages(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/TypeAliasRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/TypeAliasRule.kt index a4267630cb..1804b09aa1 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/TypeAliasRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/TypeAliasRule.kt @@ -20,9 +20,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parents * Length type reference can be configured */ class TypeAliasRule(configRules: List) : DiktatRule( - "type-alias", - configRules, - listOf(TYPE_ALIAS)) { + "type-alias", + configRules, + listOf(TYPE_ALIAS)) { override fun logic(node: ASTNode) { if (node.elementType == TYPE_REFERENCE && node .parents() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/VariableGenericTypeDeclarationRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/VariableGenericTypeDeclarationRule.kt index a005a45c32..b2027af05c 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/VariableGenericTypeDeclarationRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/VariableGenericTypeDeclarationRule.kt @@ -22,9 +22,9 @@ import org.jetbrains.kotlin.psi.KtProperty */ // FIXME: we now don't have access to return types, so we can perform this check only if explicit type is present, but should be able also if it's not. class VariableGenericTypeDeclarationRule(configRules: List) : DiktatRule( - "variable-generic-type", - configRules, - listOf(GENERIC_VARIABLE_WRONG_DECLARATION)) { + "variable-generic-type", + configRules, + listOf(GENERIC_VARIABLE_WRONG_DECLARATION)) { override fun logic(node: ASTNode) { when (node.elementType) { PROPERTY, VALUE_PARAMETER -> handleProperty(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt index 6784425855..fb32b85809 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter4/calculations/AccurateCalculationsRule.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset * Fixme: detect variables by type, not only floating-point literals */ class AccurateCalculationsRule(configRules: List) : DiktatRule( - "accurate-calculations", - configRules, - listOf(FLOAT_IN_ACCURATE_CALCULATIONS)) { + "accurate-calculations", + configRules, + listOf(FLOAT_IN_ACCURATE_CALCULATIONS)) { private fun KtCallExpression?.isAbsOfFloat() = this ?.run { (calleeExpression as? KtNameReferenceExpression) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AsyncAndSyncRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AsyncAndSyncRule.kt index 16724ba670..e79140b160 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AsyncAndSyncRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AsyncAndSyncRule.kt @@ -18,9 +18,9 @@ import org.jetbrains.kotlin.psi.psiUtil.hasSuspendModifier * This rule finds if using runBlocking in asynchronous code */ class AsyncAndSyncRule(configRules: List) : DiktatRule( - "sync-in-async", - configRules, - listOf(RUN_BLOCKING_INSIDE_ASYNC)) { + "sync-in-async", + configRules, + listOf(RUN_BLOCKING_INSIDE_ASYNC)) { private val asyncList = listOf("async", "launch") override fun logic(node: ASTNode) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AvoidNestedFunctionsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AvoidNestedFunctionsRule.kt index d3d99d5af3..17eff7b2e9 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AvoidNestedFunctionsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/AvoidNestedFunctionsRule.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parents * This rule checks for nested functions and warns if it finds any. */ class AvoidNestedFunctionsRule(configRules: List) : DiktatRule( - "avoid-nested-functions", - configRules, - listOf(AVOID_NESTED_FUNCTIONS)) { + "avoid-nested-functions", + configRules, + listOf(AVOID_NESTED_FUNCTIONS)) { override fun logic(node: ASTNode) { if (node.elementType == FUN) { handleNestedFunctions(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CheckInverseMethodRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CheckInverseMethodRule.kt index 77a098ac2e..c5504798d7 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CheckInverseMethodRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CheckInverseMethodRule.kt @@ -23,9 +23,9 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings * For example if there is !isEmpty() on collection call that it changes it to isNotEmpty() */ class CheckInverseMethodRule(configRules: List) : DiktatRule( - "inverse-method", - configRules, - listOf(INVERSE_FUNCTION_PREFERRED)) { + "inverse-method", + configRules, + listOf(INVERSE_FUNCTION_PREFERRED)) { override fun logic(node: ASTNode) { if (node.elementType == CALL_EXPRESSION && node.text in methodMap.keys) { checkCallExpressionName(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CustomLabel.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CustomLabel.kt index 2dcd4420ba..2359b3a8aa 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CustomLabel.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/CustomLabel.kt @@ -18,9 +18,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parents * Rule that checks using custom label */ class CustomLabel(configRules: List) : DiktatRule( - "custom-label", - configRules, - listOf(CUSTOM_LABEL)) { + "custom-label", + configRules, + listOf(CUSTOM_LABEL)) { private val forEachReference = listOf("forEach", "forEachIndexed") private val labels = listOf("@loop", "@forEach", "@forEachIndexed") private val stopWords = listOf(RETURN, BREAK, CONTINUE) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionArgumentsSize.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionArgumentsSize.kt index d563382a3c..a5ee1f9045 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionArgumentsSize.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionArgumentsSize.kt @@ -15,9 +15,9 @@ import org.jetbrains.kotlin.psi.KtFunction * Rule that checks that function doesn't contains too many parameters */ class FunctionArgumentsSize(configRules: List) : DiktatRule( - "argument-size", - configRules, - listOf(TOO_MANY_PARAMETERS)) { + "argument-size", + configRules, + listOf(TOO_MANY_PARAMETERS)) { private val configuration: FunctionArgumentsSizeConfiguration by lazy { FunctionArgumentsSizeConfiguration(configRules.getRuleConfig(TOO_MANY_PARAMETERS)?.configuration ?: emptyMap()) } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionLength.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionLength.kt index 79b05c9a2f..22de1d88a6 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionLength.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/FunctionLength.kt @@ -15,9 +15,9 @@ import org.jetbrains.kotlin.psi.KtFunction * Rule 5.1.1 check function length */ class FunctionLength(configRules: List) : DiktatRule( - "function-length", - configRules, - listOf(TOO_LONG_FUNCTION)) { + "function-length", + configRules, + listOf(TOO_LONG_FUNCTION)) { override fun logic(node: ASTNode) { val configuration = FunctionLengthConfiguration( configRules.getRuleConfig(TOO_LONG_FUNCTION)?.configuration ?: emptyMap() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaLengthRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaLengthRule.kt index 279ac70ae1..77fe03e357 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaLengthRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaLengthRule.kt @@ -14,9 +14,9 @@ import org.jetbrains.kotlin.com.intellij.lang.ASTNode * Rule 5.2.5 check lambda length without parameters */ class LambdaLengthRule(configRules: List) : DiktatRule( - "lambda-length", - configRules, - listOf(TOO_MANY_LINES_IN_LAMBDA)) { + "lambda-length", + configRules, + listOf(TOO_MANY_LINES_IN_LAMBDA)) { private val configuration by lazy { LambdaLengthConfiguration( this.configRules.getRuleConfig(TOO_MANY_LINES_IN_LAMBDA)?.configuration ?: emptyMap() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaParameterOrder.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaParameterOrder.kt index 97b8a596e8..efa7d4fae2 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaParameterOrder.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/LambdaParameterOrder.kt @@ -16,9 +16,9 @@ import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty * Rule that checks if parameter with function type is the last in parameter list */ class LambdaParameterOrder(configRules: List) : DiktatRule( - "lambda-parameter-order", - configRules, - listOf(LAMBDA_IS_NOT_LAST_PARAMETER)) { + "lambda-parameter-order", + configRules, + listOf(LAMBDA_IS_NOT_LAST_PARAMETER)) { override fun logic(node: ASTNode) { if (node.elementType == ElementType.FUN) { checkArguments(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/NestedFunctionBlock.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/NestedFunctionBlock.kt index 78cf11b481..66cbf9bd5a 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/NestedFunctionBlock.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/NestedFunctionBlock.kt @@ -21,9 +21,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parents * Rule 5.1.2 Nested blokcs */ class NestedFunctionBlock(configRules: List) : DiktatRule( - "nested-block", - configRules, - listOf(NESTED_BLOCK)) { + "nested-block", + configRules, + listOf(NESTED_BLOCK)) { private val configuration: NestedBlockConfiguration by lazy { NestedBlockConfiguration(configRules.getRuleConfig(NESTED_BLOCK)?.configuration ?: emptyMap()) } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt index 29278b6d29..9c67a1b7fe 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/OverloadingArgumentsFunction.kt @@ -18,9 +18,9 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset * Rule that suggests to use functions with default parameters instead of multiple overloads */ class OverloadingArgumentsFunction(configRules: List) : DiktatRule( - "overloading-default-values", - configRules, - listOf(WRONG_OVERLOADING_FUNCTION_ARGUMENTS)) { + "overloading-default-values", + configRules, + listOf(WRONG_OVERLOADING_FUNCTION_ARGUMENTS)) { override fun logic(node: ASTNode) { if (node.elementType == FUN) { checkFun(node.psi as KtFunction) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidEmptyPrimaryConstructor.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidEmptyPrimaryConstructor.kt index 26ac868793..d5a500660f 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidEmptyPrimaryConstructor.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidEmptyPrimaryConstructor.kt @@ -12,9 +12,9 @@ import org.jetbrains.kotlin.psi.KtClass * This rule checks if a class has an empty primary constructor. */ class AvoidEmptyPrimaryConstructor(configRules: List) : DiktatRule( - "avoid-empty-primary-constructor", - configRules, - listOf(EMPTY_PRIMARY_CONSTRUCTOR)) { + "avoid-empty-primary-constructor", + configRules, + listOf(EMPTY_PRIMARY_CONSTRUCTOR)) { override fun logic(node: ASTNode) { if (node.elementType == CLASS) { checkClass(node.psi as KtClass) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidUtilityClass.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidUtilityClass.kt index 35f8f3c6e3..6362053617 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidUtilityClass.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/AvoidUtilityClass.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.psi.psiUtil.children * Rule 6.4.1 checks that class/object, with a word "util" in its name, has only functions. */ class AvoidUtilityClass(configRules: List) : DiktatRule( - "avoid-utility-class", - configRules, - listOf(AVOID_USING_UTILITY_CLASS)) { + "avoid-utility-class", + configRules, + listOf(AVOID_USING_UTILITY_CLASS)) { override fun logic(node: ASTNode) { val config by configRules.getCommonConfiguration() val filePath = node.getRootNode().getFilePath() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/CustomGetterSetterRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/CustomGetterSetterRule.kt index 56782e1dbc..647ef47b84 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/CustomGetterSetterRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/CustomGetterSetterRule.kt @@ -16,9 +16,9 @@ import org.jetbrains.kotlin.com.intellij.lang.ASTNode * Inspection that checks that no custom getters and setters are used for properties. */ class CustomGetterSetterRule(configRules: List) : DiktatRule( - "custom-getter-setter", - configRules, - listOf(CUSTOM_GETTERS_SETTERS)) { + "custom-getter-setter", + configRules, + listOf(CUSTOM_GETTERS_SETTERS)) { override fun logic(node: ASTNode) { if (node.elementType == PROPERTY_ACCESSOR) { checkForCustomGetersSetters(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsSameNameRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsSameNameRule.kt index 68978e1394..2f37ae2de6 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsSameNameRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsSameNameRule.kt @@ -33,9 +33,9 @@ internal typealias SimilarSignatures = List) : DiktatRule( - "extension-functions-same-name", - configRules, - listOf(EXTENSION_FUNCTION_SAME_SIGNATURE)) { + "extension-functions-same-name", + configRules, + listOf(EXTENSION_FUNCTION_SAME_SIGNATURE)) { override fun logic(node: ASTNode) { /** * 1) Collect all classes that extend other classes (collect related classes) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ImplicitBackingPropertyRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ImplicitBackingPropertyRule.kt index b25001c91f..23116a6607 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ImplicitBackingPropertyRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ImplicitBackingPropertyRule.kt @@ -25,9 +25,9 @@ import org.jetbrains.kotlin.psi.KtProperty * This rule checks if there is a backing property for field with property accessors, in case they don't use field keyword */ class ImplicitBackingPropertyRule(configRules: List) : DiktatRule( - "implicit-backing-property", - configRules, - listOf(NO_CORRESPONDING_PROPERTY)) { + "implicit-backing-property", + configRules, + listOf(NO_CORRESPONDING_PROPERTY)) { override fun logic(node: ASTNode) { if (node.elementType == CLASS_BODY) { findAllProperties(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/PropertyAccessorFields.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/PropertyAccessorFields.kt index 5562494b97..10d05e6136 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/PropertyAccessorFields.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/PropertyAccessorFields.kt @@ -21,9 +21,9 @@ import org.jetbrains.kotlin.psi.KtProperty * Rule check that never use the name of a variable in the custom getter or setter */ class PropertyAccessorFields(configRules: List) : DiktatRule( - "getter-setter-fields", - configRules, - listOf(WRONG_NAME_OF_VARIABLE_INSIDE_ACCESSOR)) { + "getter-setter-fields", + configRules, + listOf(WRONG_NAME_OF_VARIABLE_INSIDE_ACCESSOR)) { override fun logic(node: ASTNode) { if (node.elementType == PROPERTY_ACCESSOR) { checkPropertyAccessor(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/TrivialPropertyAccessors.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/TrivialPropertyAccessors.kt index 5436c98257..899f71f390 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/TrivialPropertyAccessors.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/TrivialPropertyAccessors.kt @@ -27,9 +27,9 @@ import org.jetbrains.kotlin.psi.KtPropertyAccessor * This rule checks if there are any trivial getters and setters and, if so, deletes them */ class TrivialPropertyAccessors(configRules: List) : DiktatRule( - "trivial-property-accessors", - configRules, - listOf(TRIVIAL_ACCESSORS_ARE_NOT_RECOMMENDED)) { + "trivial-property-accessors", + configRules, + listOf(TRIVIAL_ACCESSORS_ARE_NOT_RECOMMENDED)) { override fun logic(node: ASTNode) { if (node.elementType == PROPERTY_ACCESSOR) { handlePropertyAccessors(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UselessSupertype.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UselessSupertype.kt index 2047f0b88d..9b63c527fb 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UselessSupertype.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UselessSupertype.kt @@ -32,9 +32,9 @@ import java.util.HashMap * fixme can't fix supertypes that are defined in other files. */ class UselessSupertype(configRules: List) : DiktatRule( - "useless-override", - configRules, - listOf(USELESS_SUPERTYPE)) { + "useless-override", + configRules, + listOf(USELESS_SUPERTYPE)) { override fun logic(node: ASTNode) { if (node.elementType == CLASS) { checkClass(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt index 8a864f43b7..66b9fcc8c6 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/AbstractClassesRule.kt @@ -20,9 +20,9 @@ import org.jetbrains.kotlin.com.intellij.lang.ASTNode * Checks if abstract class has any abstract method. If not, warns that class should not be abstract */ class AbstractClassesRule(configRules: List) : DiktatRule( - "abstract-classes", - configRules, - listOf(CLASS_SHOULD_NOT_BE_ABSTRACT)) { + "abstract-classes", + configRules, + listOf(CLASS_SHOULD_NOT_BE_ABSTRACT)) { override fun logic(node: ASTNode) { if (node.elementType == CLASS) { val classBody = node.getFirstChildWithType(CLASS_BODY) ?: return diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt index 5b17102eb3..f9dfcf8b9c 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/CompactInitialization.kt @@ -28,9 +28,9 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset * e.g `this@Foo`. But for this we need a mechanism to determine declaration scope and it's label. */ class CompactInitialization(configRules: List) : DiktatRule( - "class-compact-initialization", - configRules, - listOf(COMPACT_OBJECT_INITIALIZATION)) { + "class-compact-initialization", + configRules, + listOf(COMPACT_OBJECT_INITIALIZATION)) { private val kotlinParser by lazy { KotlinParser() } override fun logic(node: ASTNode) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt index 2c205907aa..eede606cbf 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/DataClassesRule.kt @@ -32,9 +32,9 @@ import org.jetbrains.kotlin.psi.KtPrimaryConstructor * This rule checks if class can be made as data class */ class DataClassesRule(configRules: List) : DiktatRule( - "data-classes", - configRules, - listOf(USE_DATA_CLASS)) { + "data-classes", + configRules, + listOf(USE_DATA_CLASS)) { override fun logic(node: ASTNode) { if (node.elementType == CLASS) { handleClass(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt index a2edfc58f8..9474688f6a 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/InlineClassesRule.kt @@ -26,9 +26,9 @@ import org.jetbrains.kotlin.psi.psiUtil.visibilityModifierType * This rule checks if inline class can be used. */ class InlineClassesRule(configRules: List) : DiktatRule( - "inline-classes", - configRules, - listOf(INLINE_CLASS_CAN_BE_USED)) { + "inline-classes", + configRules, + listOf(INLINE_CLASS_CAN_BE_USED)) { override fun logic(node: ASTNode) { val configuration by configRules.getCommonConfiguration() if (node.elementType == CLASS && configuration.kotlinVersion >= ktVersion) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleConstructorRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleConstructorRule.kt index b75538529f..6924e6a508 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleConstructorRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleConstructorRule.kt @@ -34,9 +34,9 @@ import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType * Secondary constructor is converted into primary, statements that are not assignments are moved into an `init` block. */ class SingleConstructorRule(configRules: List) : DiktatRule( - "single-constructor", - configRules, - listOf(SINGLE_CONSTRUCTOR_SHOULD_BE_PRIMARY)) { + "single-constructor", + configRules, + listOf(SINGLE_CONSTRUCTOR_SHOULD_BE_PRIMARY)) { private val kotlinParser by lazy { KotlinParser() } override fun logic(node: ASTNode) { diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt index a8ac3cc5a2..8e0fbf7649 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/SingleInitRule.kt @@ -26,9 +26,9 @@ import org.jetbrains.kotlin.psi.psiUtil.children * The rule that checks whether a class has a single `init` block or multiple. Having multiple `init` blocks is a bad practice. */ class SingleInitRule(configRules: List) : DiktatRule( - "multiple-init-block", - configRules, - listOf(MULTIPLE_INIT_BLOCKS)) { + "multiple-init-block", + configRules, + listOf(MULTIPLE_INIT_BLOCKS)) { override fun logic(node: ASTNode) { when (node.elementType) { CLASS_BODY -> handleInitBlocks(node) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/StatelessClassesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/StatelessClassesRule.kt index 70778ddc5d..3512aaa33e 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/StatelessClassesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/classes/StatelessClassesRule.kt @@ -28,9 +28,9 @@ import org.jetbrains.kotlin.psi.KtClass * This rule checks if class is stateless and if so changes it to object. */ class StatelessClassesRule(configRules: List) : DiktatRule( - "stateless-class", - configRules, - listOf(OBJECT_IS_PREFERRED)) { + "stateless-class", + configRules, + listOf(OBJECT_IS_PREFERRED)) { override fun logic(node: ASTNode) { // Fixme: We should find interfaces in all project and then check them if (node.elementType == FILE) {