diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/dummy/DummyWarning.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/dummy/DummyWarning.kt deleted file mode 100644 index 93c26348e9..0000000000 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/dummy/DummyWarning.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.cqfn.diktat.ruleset.dummy - -import org.cqfn.diktat.common.config.rules.RulesConfig -import org.cqfn.diktat.ruleset.constants.Warnings -import org.cqfn.diktat.ruleset.rules.DiktatRule -import org.jetbrains.kotlin.com.intellij.lang.ASTNode - -/** - * Dummy warning used for testing and debug purposes. - * Can be used in manual testing. - */ -class DummyWarning(configRules: List) : DiktatRule( - "dummy-rule", - configRules, - listOf( - Warnings.FILE_NAME_INCORRECT, - Warnings.FILE_NAME_MATCH_CLASS - ) -) { - @Suppress("UNUSED", "VarCouldBeVal") - private lateinit var filePath: String - - @Suppress("EmptyFunctionBlock") - override fun logic(node: ASTNode) {} -} diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt index 97e3ee2111..07e2eaf4ea 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/DiktatRuleSetProvider.kt @@ -3,9 +3,8 @@ package org.cqfn.diktat.ruleset.rules import org.cqfn.diktat.common.config.rules.DIKTAT_COMMON import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.RulesConfigReader -import org.cqfn.diktat.ruleset.constants.EmitType import org.cqfn.diktat.ruleset.constants.Warnings -import org.cqfn.diktat.ruleset.dummy.DummyWarning +import org.cqfn.diktat.ruleset.rules.OrderedRuleSet.Companion.ordered import org.cqfn.diktat.ruleset.rules.chapter1.FileNaming import org.cqfn.diktat.ruleset.rules.chapter1.IdentifierNaming import org.cqfn.diktat.ruleset.rules.chapter1.PackageNaming @@ -81,10 +80,8 @@ import org.cqfn.diktat.ruleset.rules.chapter6.classes.SingleConstructorRule import org.cqfn.diktat.ruleset.rules.chapter6.classes.SingleInitRule import org.cqfn.diktat.ruleset.rules.chapter6.classes.StatelessClassesRule -import com.pinterest.ktlint.core.Rule import com.pinterest.ktlint.core.RuleSet import com.pinterest.ktlint.core.RuleSetProvider -import org.jetbrains.kotlin.com.intellij.lang.ASTNode import org.jetbrains.kotlin.org.jline.utils.Levenshtein import org.slf4j.LoggerFactory @@ -144,9 +141,6 @@ class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYS // We don't have a way to enforce a specific order, so we should just be careful when adding new rules to this list and, when possible, // cover new rules in smoke test as well. If a rule needs to be at a specific position in a list, please add comment explaining it (like for NewlinesRule). val rules = listOf( - // test warning that can be used for manual testing of diktat - ::DummyWarning, - // comments & documentation ::CommentsRule, ::SingleConstructorRule, // this rule can add properties to a primary constructor, so should be before KdocComments @@ -231,13 +225,10 @@ class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYS .map { it.invoke(configRules) } - val orderedRules = rules.mapIndexed { index, rule -> - if (index != 0) OrderedRule(rule, rules[index - 1]) else rule - } return RuleSet( DIKTAT_RULE_SET_ID, - rules = orderedRules.toTypedArray() - ) + rules = rules.toTypedArray() + ).ordered() } private fun validate(config: RulesConfig) = @@ -269,43 +260,7 @@ class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYS private fun resolveConfigFileFromSystemProperty(): String? = System.getProperty(DIKTAT_CONF_PROPERTY) - /** - * This is a wrapper around Ktlint Rule which adjusts visitorModifiers to keep order with prevRule - * Added as a workaround after introducing a new logic for sorting KtLint Rules: https://github.com/pinterest/ktlint/issues/1478 - * - * @property rule KtLink Rule which this class wraps - * - * @param prevRule previous KtLink Rule, the wrapped rule is called after prevRule - */ - internal class OrderedRule(val rule: Rule, prevRule: Rule) : Rule(rule.id, adjustVisitorModifiers(rule, prevRule)) { - /** - * Delegating a call of this method - */ - override fun visit( - node: ASTNode, - autoCorrect: Boolean, - emit: EmitType - ) { - rule.visit(node, autoCorrect, emit) - } - } - companion object { private val log = LoggerFactory.getLogger(DiktatRuleSetProvider::class.java) - - private fun adjustVisitorModifiers(rule: Rule, prevRule: Rule): Set { - val visitorModifiers: Set = rule.visitorModifiers - require(visitorModifiers.none { it is Rule.VisitorModifier.RunAfterRule }) { - "Rule ${rule.id} already contains VisitorModifier.RunAfterRule" - } - require(rule.id != prevRule.id) { - "PrevRule has same ID as rule: ${rule.id}" - } - return visitorModifiers + Rule.VisitorModifier.RunAfterRule( - ruleId = prevRule.id, - loadOnlyWhenOtherRuleIsLoaded = false, - runOnlyWhenOtherRuleIsEnabled = false - ) - } } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/OrderedRuleSet.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/OrderedRuleSet.kt new file mode 100644 index 0000000000..08d77bc223 --- /dev/null +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/OrderedRuleSet.kt @@ -0,0 +1,84 @@ +package org.cqfn.diktat.ruleset.rules + +import org.cqfn.diktat.ruleset.constants.EmitType +import com.pinterest.ktlint.core.Rule +import com.pinterest.ktlint.core.RuleSet +import org.jetbrains.kotlin.com.intellij.lang.ASTNode + +/** + * This is a wrapper around Ktlint RuleSet which adjusts visitorModifiers for all rules to keep order with prevRule + * Added as a workaround after introducing a new logic for sorting KtLint Rules: https://github.com/pinterest/ktlint/issues/1478 + * + * @param id ID of RuleSet + * @param rules rules which belongs to current RuleSet + */ +class OrderedRuleSet(id: String, vararg rules: Rule) : RuleSet(id, rules = adjustRules(id, rules = rules)) { + companion object { + private fun adjustRules(ruleSetId: String, vararg rules: Rule): Array { + if (rules.isEmpty()) { + return rules + } + return rules.mapIndexed { index, rule -> + if (index == 0) { + checkVisitorModifiers(rule) + rule + } else { + OrderedRule(ruleSetId, rule, rules[index - 1]) + } + }.toTypedArray() + } + + private fun adjustVisitorModifiers( + ruleSetId: String, + rule: Rule, + prevRule: Rule + ): Set { + val visitorModifiers: Set = rule.visitorModifiers + checkVisitorModifiers(rule) + require(rule.id != prevRule.id) { + "PrevRule has same ID as rule: ${rule.id}" + } + return visitorModifiers + Rule.VisitorModifier.RunAfterRule( + ruleId = ruleSetId + ":" + prevRule.id, + loadOnlyWhenOtherRuleIsLoaded = false, + runOnlyWhenOtherRuleIsEnabled = false + ) + } + + private fun checkVisitorModifiers(rule: Rule) { + require(rule.visitorModifiers.none { it is Rule.VisitorModifier.RunAfterRule }) { + "Rule ${rule.id} contains VisitorModifier.RunAfterRule" + } + } + + /** + * @return a rule to which a logic is delegated + */ + internal fun Rule.delegatee(): Rule = if (this is OrderedRule) this.rule else this + + /** + * @return RuleSet with ordered rules + */ + fun RuleSet.ordered(): OrderedRuleSet = OrderedRuleSet(id = id, rules = rules) + + /** + * @property rule wraps this rule to keep order + */ + private class OrderedRule( + ruleSetId: String, + val rule: Rule, + prevRule: Rule + ) : Rule(rule.id, adjustVisitorModifiers(ruleSetId, rule, prevRule)) { + /** + * Delegating a call of this method + */ + override fun visit( + node: ASTNode, + autoCorrect: Boolean, + emit: EmitType + ) { + rule.visit(node, autoCorrect, emit) + } + } + } +} 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 68dd00d5b3..5d571fb478 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 @@ -77,7 +77,7 @@ class FileNaming(configRules: List) : DiktatRule( companion object { // FixMe: should be moved to properties - const val NAME_ID = "aag-file-naming" + const val NAME_ID = "file-naming" val validExtensions = listOf(".kt", ".kts") } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/IdentifierNaming.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/IdentifierNaming.kt index 41888a9a1e..1e26826fab 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/IdentifierNaming.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/IdentifierNaming.kt @@ -483,7 +483,7 @@ class IdentifierNaming(configRules: List) : DiktatRule( companion object { const val MAX_IDENTIFIER_LENGTH = 64 const val MIN_IDENTIFIER_LENGTH = 2 - const val NAME_ID = "aai-identifier-naming" + const val NAME_ID = "identifier-naming" // FixMe: this should be moved to properties val oneCharIdentifiers = setOf("i", "j", "k", "x", "y", "z") diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt index 9f5bfbee9d..a92cf4f044 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter1/PackageNaming.kt @@ -282,7 +282,7 @@ class PackageNaming(configRules: List) : DiktatRule( companion object { private val log = LoggerFactory.getLogger(PackageNaming::class.java) - const val NAME_ID = "aah-package-naming" + const val NAME_ID = "package-naming" /** * Directory which is considered the start of sources file tree 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 f5ab9cae58..f4a093d5cd 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 @@ -174,7 +174,7 @@ class CommentsRule(configRules: List) : DiktatRule( @Suppress("MaxLineLength") companion object { private val logger = LoggerFactory.getLogger(CommentsRule::class.java) - const val NAME_ID = "aaa-comments" + const val NAME_ID = "comments" private val importKeywordWithSpace = "${KtTokens.IMPORT_KEYWORD.value} " private val packageKeywordWithSpace = "${KtTokens.PACKAGE_KEYWORD.value} " private val importOrPackage = """($importKeywordWithSpace|$packageKeywordWithSpace)""".toRegex() diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt index 0048612d0d..1721f26684 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/comments/HeaderCommentRule.kt @@ -275,7 +275,7 @@ class HeaderCommentRule(configRules: List) : DiktatRule( companion object { private val log = LoggerFactory.getLogger(HeaderCommentRule::class.java) const val CURR_YEAR_PATTERN = ";@currYear;" - const val NAME_ID = "zcp-header-comment" + const val NAME_ID = "header-comment" val hyphenRegex = Regex("""\d+-\d+""") val afterCopyrightRegex = Regex("""((©|\([cC]\))+ *\d+)""") val curYear = LocalDate.now().year diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/CommentsFormatting.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/CommentsFormatting.kt index ff908f61de..800004bf8d 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/CommentsFormatting.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/CommentsFormatting.kt @@ -360,6 +360,6 @@ class CommentsFormatting(configRules: List) : DiktatRule( companion object { private const val APPROPRIATE_COMMENT_SPACES = 1 private const val MAX_SPACES = 1 - const val NAME_ID = "aaf-kdoc-comments-codeblocks-formatting" + const val NAME_ID = "kdoc-comments-codeblocks-formatting" } } 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 89a343a43d..70642b6b85 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 @@ -352,7 +352,7 @@ class KdocComments(configRules: List) : DiktatRule( private fun isTopLevelFunctionStandard(node: ASTNode): Boolean = node.elementType == FUN && node.isStandardMethod() companion object { - const val NAME_ID = "aac-kdoc-comments" + const val NAME_ID = "kdoc-comments" private val statementsToDocument = TokenSet.create(CLASS, FUN, PROPERTY) } } 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 edfa665b7a..9ecfeca584 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 @@ -379,7 +379,7 @@ class KdocFormatting(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aae-kdoc-formatting" + const val NAME_ID = "kdoc-formatting" val dateFormats: List = listOf("yyyy-dd-mm", "yy-dd-mm", "yyyy-mm-dd", "yy-mm-dd", "yyyy.mm.dd", "yyyy.dd.mm") .map { DateTimeFormatter.ofPattern(it) 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 c04485490c..2f22e8f909 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 @@ -309,7 +309,7 @@ class KdocMethods(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aad-kdoc-methods" + const val NAME_ID = "kdoc-methods" private val expressionBodyTypes = setOf(CALL_EXPRESSION, REFERENCE_EXPRESSION) private val allExpressionBodyTypes = setOf( DOT_QUALIFIED_EXPRESSION, 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 c9a29ac7ee..294523c2a0 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 @@ -76,6 +76,6 @@ class AnnotationNewLineRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abo-annotation-new-line" + const val NAME_ID = "annotation-new-line" } } 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 8adbdbe639..ab965cc2c0 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 @@ -273,6 +273,6 @@ class BlockStructureBraces(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "zcn-block-structure" + const val NAME_ID = "block-structure" } } 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 599dc912e3..3fb33de2da 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 @@ -193,7 +193,7 @@ class BracesInConditionalsAndLoopsRule(configRules: List) : DiktatR } companion object { private const val INDENT_STEP = 4 - const val NAME_ID = "aam-races-rule" + const val NAME_ID = "races-rule" private val scopeFunctions = listOf("let", "run", "apply", "also") } } 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 3a2745c643..2991901d71 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 @@ -229,7 +229,7 @@ class ClassLikeStructuresOrderRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aak-class-like-structures" + const val NAME_ID = "class-like-structures" private val childrenTypes = listOf(PROPERTY, CLASS, CLASS_INITIALIZER, SECONDARY_CONSTRUCTOR, FUN, OBJECT_DECLARATION, ENUM_ENTRY) } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt index b2d412a2f2..b771943e6f 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/CollapseIfStatementsRule.kt @@ -213,6 +213,6 @@ class CollapseIfStatementsRule(configRules: List) : DiktatRule( companion object { private const val DEFAULT_NESTED_LEVEL = 2 - const val NAME_ID = "abu-collapse-if" + const val NAME_ID = "collapse-if" } } 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 810a8a20ea..85270a69a9 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 @@ -84,6 +84,6 @@ class ConsecutiveSpacesRule(configRules: List) : DiktatRule( companion object { private const val MAX_SPACES = 1 - const val NAME_ID = "zco-too-many-spaces" + const val NAME_ID = "too-many-spaces" } } 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 a5721cc26d..46dbd1bbd0 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 @@ -134,6 +134,6 @@ class EmptyBlock(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aan-empty-block-structure" + const val NAME_ID = "empty-block-structure" } } 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 fc328a6b70..743fd2ab75 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 @@ -112,7 +112,7 @@ class EnumsSeparated(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abq-enum-separated" + const val NAME_ID = "enum-separated" private val simpleValue = listOf(IDENTIFIER, WHITE_SPACE, COMMA, SEMICOLON) private val simpleEnum = listOf(ENUM_ENTRY, WHITE_SPACE, LBRACE, RBRACE) } 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 1156b36db8..ca5460ed3c 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 @@ -772,7 +772,7 @@ class LineLength(configRules: List) : DiktatRule( */ companion object { private const val MAX_LENGTH = 120L - const val NAME_ID = "abv-line-length" + const val NAME_ID = "line-length" private const val STRING_PART_OFFSET = 4 private val propertyList = listOf(INTEGER_CONSTANT, LITERAL_STRING_TEMPLATE_ENTRY, FLOAT_CONSTANT, CHARACTER_CONSTANT, REFERENCE_EXPRESSION, BOOLEAN_CONSTANT, LONG_STRING_TEMPLATE_ENTRY, 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 e50332bab1..a069f834e1 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 @@ -158,6 +158,6 @@ class LongNumericalValuesSeparatedRule(configRules: List) : DiktatR companion object { private const val DELIMITER_LENGTH: Int = 3 private const val MAX_NUMBER_LENGTH: Int = 3 - const val NAME_ID = "abm-long-numerical-values" + const val NAME_ID = "long-numerical-values" } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt index 0fcb6d5752..fe90acd322 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/MagicNumberRule.kt @@ -114,7 +114,7 @@ class MagicNumberRule(configRules: List) : DiktatRule( companion object { const val IGNORE_TEST = true - const val NAME_ID = "aca-magic-number" + const val NAME_ID = "magic-number" val ignoreNumbersList = listOf("-1", "1", "0", "2", "0U", "1U", "2U", "-1L", "0L", "1L", "2L", "0UL", "1UL", "2UL") val mapConfiguration = mapOf( "ignoreHashCodeFunction" to true, 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 609377bb37..f132c8baa2 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 @@ -73,7 +73,7 @@ class MultipleModifiersSequence(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aar-multiple-modifiers" + const val NAME_ID = "multiple-modifiers" private val modifierOrder = listOf(KtTokens.PUBLIC_KEYWORD, KtTokens.INTERNAL_KEYWORD, KtTokens.PROTECTED_KEYWORD, KtTokens.PRIVATE_KEYWORD, KtTokens.EXPECT_KEYWORD, KtTokens.ACTUAL_KEYWORD, KtTokens.FINAL_KEYWORD, KtTokens.OPEN_KEYWORD, KtTokens.ABSTRACT_KEYWORD, KtTokens.SEALED_KEYWORD, KtTokens.CONST_KEYWORD, 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 eaf14365dc..582e87098e 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 @@ -162,7 +162,7 @@ class NullableTypeRule(configRules: List) : DiktatRule( ) companion object { - const val NAME_ID = "acg-nullable-type" + const val NAME_ID = "nullable-type" private val allowExpression = listOf("emptyList", "emptySequence", "emptyArray", "emptyMap", "emptySet", "listOf", "mapOf", "arrayOf", "sequenceOf", "setOf") } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/RangeConventionalRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/RangeConventionalRule.kt index c9317191b9..6f94e6013d 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/RangeConventionalRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/RangeConventionalRule.kt @@ -115,6 +115,6 @@ class RangeConventionalRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abj-range" + const val NAME_ID = "range" } } 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 fbf10f5b4e..8d09c52122 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 @@ -47,7 +47,7 @@ class SingleLineStatementsRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aaq-statement" + const val NAME_ID = "statement" private val semicolonToken = TokenSet.create(SEMICOLON) } } 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 4bfd312b50..92165bbbb7 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 @@ -186,6 +186,6 @@ class SortRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abp-sort-rule" + const val NAME_ID = "sort-rule" } } 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 680fd55b60..e3ffbfaa2f 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 @@ -217,6 +217,6 @@ class StringConcatenationRule(configRules: List) : DiktatRule( this.right is KtExpression companion object { - const val NAME_ID = "abr-string-concatenation" + const val NAME_ID = "string-concatenation" } } 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 42be33ecd6..c3b9a3efc0 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 @@ -109,6 +109,6 @@ class StringTemplateFormatRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abs-string-template-format" + const val NAME_ID = "string-template-format" } } 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 9145648f24..c80a508688 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 @@ -134,7 +134,7 @@ class TrailingCommaRule(configRules: List) : DiktatRule( companion object { private val log = LoggerFactory.getLogger(TrailingCommaRule::class.java) - const val NAME_ID = "abh-trailing-comma" + const val NAME_ID = "trailing-comma" val ktVersion = KotlinVersion(1, 4) val whenChildrenTypes = listOf(WHEN_CONDITION_WITH_EXPRESSION, WHEN_CONDITION_IS_PATTERN, WHEN_CONDITION_IN_RANGE) } 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 e91cf6148f..0ac937ab36 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 @@ -164,6 +164,6 @@ class WhenMustHaveElseRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aal-no-else-in-when" + const val NAME_ID = "no-else-in-when" } } 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 7da8d9e787..e79bd431e0 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 @@ -73,6 +73,6 @@ class BlankLinesRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "acd-blank-lines" + const val NAME_ID = "blank-lines" } } 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 395f706571..5d930b64a4 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 @@ -51,6 +51,6 @@ class FileSize(configRules: List) : DiktatRule( companion object { const val MAX_SIZE = 2000L - const val NAME_ID = "ace-file-size" + const val NAME_ID = "file-size" } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileStructureRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileStructureRule.kt index 6b0c3fa470..eda9ff938f 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileStructureRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/FileStructureRule.kt @@ -409,6 +409,6 @@ class FileStructureRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "zcq-file-structure" + const val NAME_ID = "file-structure" } } 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 afd0b56fcf..745c5e0315 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 @@ -545,7 +545,7 @@ class IndentationRule(configRules: List) : DiktatRule( companion object { private val log = LoggerFactory.getLogger(IndentationRule::class.java) - const val NAME_ID = "zct-indentation" + const val NAME_ID = "indentation" private val increasingTokens = listOf(LPAR, LBRACE, LBRACKET, LONG_TEMPLATE_ENTRY_START) private val decreasingTokens = listOf(RPAR, RBRACE, RBRACKET, LONG_TEMPLATE_ENTRY_END) private val matchingTokens = increasingTokens.zip(decreasingTokens) 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 9f9acfcf8d..44237ad89b 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 @@ -707,7 +707,7 @@ class NewlinesRule(configRules: List) : DiktatRule( companion object { private val log = LoggerFactory.getLogger(NewlinesRule::class.java) const val MAX_CALLS_IN_ONE_LINE = 3 - const val NAME_ID = "zcr-newlines" + const val NAME_ID = "newlines" // fixme: these token sets can be not full, need to add new once as corresponding cases are discovered. // error is raised if these operators are prepended by newline 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 09f8e97e99..2a574dba59 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 @@ -113,7 +113,7 @@ class TopLevelOrderRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aap-top-level-order" + const val NAME_ID = "top-level-order" /** * List of children that should be sort 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 4a783d87e0..79a27e6a47 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 @@ -457,7 +457,7 @@ class WhiteSpaceRule(configRules: List) : DiktatRule( companion object { private val log = LoggerFactory.getLogger(CompactInitialization::class.java) - const val NAME_ID = "zcs-horizontal-whitespace" + const val NAME_ID = "horizontal-whitespace" private const val NUM_PARENTS_FOR_LAMBDA = 3 // this is the number of parent nodes needed to check if this node is lambda from argument list private val keywordsWithSpaceAfter = TokenSet.create( 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 cd63b16fb3..2883a0aeb0 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 @@ -218,7 +218,7 @@ class LocalVariablesRule(configRules: List) : DiktatRule( ) = "<$name> is declared on line <$declared> and is used for the first time on line <$used>" companion object { - const val NAME_ID = "abc-local-variables" + const val NAME_ID = "local-variables" private val functionInitializers = listOf( "emptyList", "emptySet", "emptyMap", "emptyArray", "emptySequence", "listOf", "setOf", "mapOf", "arrayOf", "arrayListOf", 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 81d42eeec6..f483eef0ec 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 @@ -55,6 +55,6 @@ class ImmutableValNoVarRule(configRules: List) : DiktatRule( } } companion object { - const val NAME_ID = "aci-no-var-rule" + const val NAME_ID = "no-var-rule" } } 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 bd81d50c42..52d8f41975 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 @@ -287,6 +287,6 @@ class NullChecksRule(configRules: List) : DiktatRule( referenceExpression.elementType == REFERENCE_EXPRESSION && referenceExpression.firstChildNode.text == "require" companion object { - const val NAME_ID = "ach-null-checks" + const val NAME_ID = "null-checks" } } 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 4d05663208..5911d4c427 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 @@ -265,6 +265,6 @@ class SmartCastRule(configRules: List) : DiktatRule( class IsExpressions(val identifier: String, val type: String) companion object { - const val NAME_ID = "abd-smart-cast-rule" + const val NAME_ID = "smart-cast-rule" } } 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 a1dac69daa..8e08e59e2b 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 @@ -56,7 +56,7 @@ class TypeAliasRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abx-type-alias" + const val NAME_ID = "type-alias" const val TYPE_REFERENCE_MAX_LENGTH = 25 } } 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 b692115529..c4e6dd05ac 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 @@ -75,6 +75,6 @@ class VariableGenericTypeDeclarationRule(configRules: List) : Dikta } companion object { - const val NAME_ID = "abl-variable-generic-type" + const val NAME_ID = "variable-generic-type" } } 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 f46520bdd2..745b313998 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 @@ -120,7 +120,7 @@ class AccurateCalculationsRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abt-accurate-calculations" + const val NAME_ID = "accurate-calculations" private val arithmeticOperationTokens = listOf(KtTokens.PLUS, KtTokens.PLUSEQ, KtTokens.PLUSPLUS, KtTokens.MINUS, KtTokens.MINUSEQ, KtTokens.MINUSMINUS, KtTokens.MUL, KtTokens.MULTEQ, KtTokens.DIV, KtTokens.DIVEQ, 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 cb5435d697..e234169d13 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 @@ -43,6 +43,6 @@ class AsyncAndSyncRule(configRules: List) : DiktatRule( private fun ASTNode.isRunBlocking() = this.elementType == REFERENCE_EXPRESSION && this.text == "runBlocking" && this.treeParent.hasChildOfType(LAMBDA_ARGUMENT) companion object { - const val NAME_ID = "acf-sync-in-async" + const val NAME_ID = "sync-in-async" } } 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 5afed6dc3a..871b890ea6 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 @@ -101,6 +101,6 @@ class AvoidNestedFunctionsRule(configRules: List) : DiktatRule( (node.psi as KtFunction).valueParameters.map { it.name!! } companion object { - const val NAME_ID = "acj-avoid-nested-functions" + const val NAME_ID = "avoid-nested-functions" } } 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 ccfba1e0ed..bfabf27c85 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 @@ -57,7 +57,7 @@ class CheckInverseMethodRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aay-inverse-method" + const val NAME_ID = "inverse-method" val methodMap = mapOf( "isEmpty()" to "isNotEmpty()", "isBlank()" to "isNotBlank()", 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 25daf916a1..5a1c2b7fca 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 @@ -39,6 +39,6 @@ class CustomLabel(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abk-custom-label" + const val NAME_ID = "custom-label" } } 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 e3bed256ca..86b4327cef 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 @@ -50,6 +50,6 @@ class FunctionArgumentsSize(configRules: List) : DiktatRule( companion object { const val MAX_DEFAULT_PARAMETER_SIZE = 5L - const val NAME_ID = "acc-argument-size" + const val NAME_ID = "argument-size" } } 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 5fbe953c40..d120d0378d 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 @@ -63,6 +63,6 @@ class FunctionLength(configRules: List) : DiktatRule( companion object { private const val MAX_FUNCTION_LENGTH = 30L - const val NAME_ID = "abz-function-length" + const val NAME_ID = "function-length" } } 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 eafa95e20a..357c35851f 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 @@ -51,6 +51,6 @@ class LambdaLengthRule(configRules: List) : DiktatRule( companion object { private const val MAX_LINES_IN_LAMBDA = 10L - const val NAME_ID = "acl-lambda-length" + const val NAME_ID = "lambda-length" } } 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 cd23b9022e..f6cb61508a 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 @@ -45,6 +45,6 @@ class LambdaParameterOrder(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "acb-lambda-parameter-order" + const val NAME_ID = "lambda-parameter-order" } } 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 6c75a95c12..e51f0ae011 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 @@ -65,7 +65,7 @@ class NestedFunctionBlock(configRules: List) : DiktatRule( companion object { private const val MAX_NESTED_BLOCK_COUNT = 4L - const val NAME_ID = "abn-nested-block" + const val NAME_ID = "nested-block" /** * Nodes of these types reset counter of nested blocks 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 225c3649f1..ae705213dc 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 @@ -46,6 +46,6 @@ class OverloadingArgumentsFunction(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aby-overloading-default-values" + const val NAME_ID = "overloading-default-values" } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/ParameterNameInOuterLambdaRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/ParameterNameInOuterLambdaRule.kt index a66abba704..d4445e3769 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/ParameterNameInOuterLambdaRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter5/ParameterNameInOuterLambdaRule.kt @@ -36,6 +36,6 @@ class ParameterNameInOuterLambdaRule(configRules: List) : DiktatRul } } companion object { - const val NAME_ID = "acn-parameter-name-in-outer-lambda" + const val NAME_ID = "parameter-name-in-outer-lambda" } } 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 8a86997bb9..0fa8bb2680 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 @@ -34,6 +34,6 @@ class AvoidEmptyPrimaryConstructor(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aao-avoid-empty-primary-constructor" + const val NAME_ID = "avoid-empty-primary-constructor" } } 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 e05c50ef19..e7147dec65 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 @@ -59,7 +59,7 @@ class AvoidUtilityClass(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abe-avoid-utility-class" + const val NAME_ID = "avoid-utility-class" private val utilityClassChildren = listOf(LBRACE, WHITE_SPACE, FUN, RBRACE, KDOC, EOL_COMMENT, BLOCK_COMMENT, OBJECT_DECLARATION) } 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 8b971207ee..496fd51a9f 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 @@ -44,6 +44,6 @@ class CustomGetterSetterRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aat-custom-getter-setter" + const val NAME_ID = "custom-getter-setter" } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsInFileRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsInFileRule.kt index d46255ac04..84217f0c6c 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsInFileRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/ExtensionFunctionsInFileRule.kt @@ -54,6 +54,6 @@ class ExtensionFunctionsInFileRule(configRules: List) : DiktatRule( node.getFirstChildWithType(IDENTIFIER)!!.prevSibling { it.elementType == TYPE_REFERENCE }?.text in classNames companion object { - const val NAME_ID = "aax-extension-functions-class-file" + const val NAME_ID = "extension-functions-class-file" } } 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 15de6db138..08a2490283 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 @@ -151,6 +151,6 @@ class ExtensionFunctionsSameNameRule(configRules: List) : DiktatRul } companion object { - const val NAME_ID = "ack-extension-functions-same-name" + const val NAME_ID = "extension-functions-same-name" } } 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 1c8bb0cf92..16c74aaa6f 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 @@ -110,6 +110,6 @@ class ImplicitBackingPropertyRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aba-implicit-backing-property" + const val NAME_ID = "implicit-backing-property" } } 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 9cf4f09e56..fcb2e9e1f8 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 @@ -57,6 +57,6 @@ class PropertyAccessorFields(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abf-getter-setter-fields" + const val NAME_ID = "getter-setter-fields" } } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/RunInScript.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/RunInScript.kt index 59f62eceae..799a2ba0c8 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/RunInScript.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/RunInScript.kt @@ -82,6 +82,6 @@ class RunInScript(private val configRules: List) : Rule(NAME_ID) { } companion object { - const val NAME_ID = "abw-run-script" + const val NAME_ID = "run-script" } } 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 b89240a230..ecd883bb60 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 @@ -90,7 +90,7 @@ class TrivialPropertyAccessors(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aas-trivial-property-accessors" + const val NAME_ID = "trivial-property-accessors" private const val ONE_CHILD_IN_ARRAY = 1 private val excessChildrenTypes = listOf(LBRACE, RBRACE, WHITE_SPACE, EOL_COMMENT, BLOCK_COMMENT) } diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UseLastIndex.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UseLastIndex.kt index 7222845650..b0628774ad 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UseLastIndex.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter6/UseLastIndex.kt @@ -51,6 +51,6 @@ class UseLastIndex(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aav-last-index" + const val NAME_ID = "last-index" } } 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 7c233be352..8bb2f8ce0a 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 @@ -141,7 +141,7 @@ class UselessSupertype(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aaj-useless-override" + const val NAME_ID = "useless-override" private val superType = listOf(SUPER_TYPE_CALL_ENTRY, SUPER_TYPE_ENTRY) } } 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 35abde04f3..3ec9fed59b 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 @@ -69,6 +69,6 @@ class AbstractClassesRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abg-abstract-classes" + const val NAME_ID = "abstract-classes" } } 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 841047b3bb..8ae4f69856 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 @@ -212,6 +212,6 @@ class CompactInitialization(configRules: List) : DiktatRule( companion object { private val log = LoggerFactory.getLogger(CompactInitialization::class.java) - const val NAME_ID = "aau-class-compact-initialization" + const val NAME_ID = "class-compact-initialization" } } 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 d4031d40a2..78614d1522 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 @@ -145,7 +145,7 @@ class DataClassesRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abb-data-classes" + const val NAME_ID = "data-classes" private val badModifiers = listOf(OPEN_KEYWORD, ABSTRACT_KEYWORD, INNER_KEYWORD, SEALED_KEYWORD, ENUM_KEYWORD) } } 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 9b2a302190..c35d0fee89 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 @@ -79,7 +79,7 @@ class InlineClassesRule(configRules: List) : DiktatRule( ?: false companion object { - const val NAME_ID = "aaw-inline-classes" + const val NAME_ID = "inline-classes" val minKtVersion = KotlinVersion(1, 3) val maxKtVersion = KotlinVersion(1, 5, 0) val goodModifiers = listOf(PUBLIC_KEYWORD, PRIVATE_KEYWORD, FINAL_KEYWORD, PROTECTED_KEYWORD, INTERNAL_KEYWORD) 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 87c7d529dd..df4e9e557c 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 @@ -267,6 +267,6 @@ class SingleConstructorRule(configRules: List) : DiktatRule( .node companion object { - const val NAME_ID = "aab-single-constructor" + const val NAME_ID = "single-constructor" } } 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 b9600221e0..d7ff713969 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 @@ -158,6 +158,6 @@ class SingleInitRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "abi-multiple-init-block" + const val NAME_ID = "multiple-init-block" } } 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 a819e9e45d..04d31fcb89 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 @@ -92,6 +92,6 @@ class StatelessClassesRule(configRules: List) : DiktatRule( } companion object { - const val NAME_ID = "aaz-stateless-class" + const val NAME_ID = "stateless-class" } } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/dummy/DummyWarningWarnTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/dummy/DummyWarningWarnTest.kt deleted file mode 100644 index 6775038a64..0000000000 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/dummy/DummyWarningWarnTest.kt +++ /dev/null @@ -1,31 +0,0 @@ -package org.cqfn.diktat.ruleset.dummy - -import org.cqfn.diktat.ruleset.constants.Warnings.DUMMY_TEST_WARNING -import org.cqfn.diktat.ruleset.rules.DIKTAT_RULE_SET_ID -import org.cqfn.diktat.util.LintTestBase - -import com.pinterest.ktlint.core.LintError -import generated.WarningNames -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Tag -import org.junit.jupiter.api.Test - -/** - * In this class you can test the logic of your rule, which should be implemented in DummyWarning - */ -class DummyWarningWarnTest : LintTestBase(::DummyWarning) { - private val ruleId = "$DIKTAT_RULE_SET_ID:dummy-rule" - - // Remove @Disabled annotation before usage - @Disabled - @Test - @Tag(WarningNames.DUMMY_TEST_WARNING) - fun `check dummy property`() { - lintMethod( - """ - |// provide your check here - """.trimMargin(), - LintError(1, 1, ruleId, "${DUMMY_TEST_WARNING.warnText()} some detailed explanation", true) - ) - } -} diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/rules/OrderedRuleSetTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/rules/OrderedRuleSetTest.kt new file mode 100644 index 0000000000..7ac7092e99 --- /dev/null +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/rules/OrderedRuleSetTest.kt @@ -0,0 +1,105 @@ +package org.cqfn.diktat.ruleset.rules + +import org.cqfn.diktat.ruleset.constants.EmitType +import org.cqfn.diktat.util.TEST_FILE_NAME +import com.pinterest.ktlint.core.KtLint +import com.pinterest.ktlint.core.Rule +import com.pinterest.ktlint.core.api.FeatureInAlphaState +import org.jetbrains.kotlin.com.intellij.lang.ASTNode +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +class OrderedRuleSetTest { + @Test + fun `check OrderedRule with VisitorModifier RunAfterRule`() { + val rule = mockRule("rule") + Assertions.assertThrows(IllegalArgumentException::class.java) { + OrderedRuleSet("duplicate", rule, rule) + } + + val ruleWithRunAfterRule = mockRule("invalid-rule", setOf(Rule.VisitorModifier.RunAfterRule("another-rule"))) + // validate that second rule which will be modified doesn't contain VisitorModifier.RunAfterRule + Assertions.assertThrows(IllegalArgumentException::class.java) { + OrderedRuleSet("visitor-modifier", rule, ruleWithRunAfterRule) + } + // validate that first rule which won't be modified doesn't contain VisitorModifier.RunAfterRule + Assertions.assertThrows(IllegalArgumentException::class.java) { + OrderedRuleSet("visitor-modifier", ruleWithRunAfterRule, rule) + } + } + + @Test + fun `check OrderedRule`() { + val rule1 = mockRule("rule-first") + val rule2 = mockRule("rule-second") + + val ruleSetId = "id" + val orderedRuleSet = OrderedRuleSet(ruleSetId, rule1, rule2) + + val orderedRuleSetIterator = orderedRuleSet.iterator() + val orderedRule1 = orderedRuleSetIterator.next() + val orderedRule2 = orderedRuleSetIterator.next() + Assertions.assertFalse(orderedRuleSetIterator.hasNext(), "Extra elements after ordering") + + Assertions.assertEquals(rule1, orderedRule1, "First rule is modified") + + orderedRule2.visitorModifiers + .filterIsInstance() + .also { + Assertions.assertEquals(1, it.size, + "Found invalid count of Rule.VisitorModifier.RunAfterRule") + } + .first() + .let { + Assertions.assertEquals(ruleSetId + ":" + rule1.id, it.ruleId, + "Invalid ruleId in Rule.VisitorModifier.RunAfterRule") + } + } + + @Test + @OptIn(FeatureInAlphaState::class) + fun `KtLint keeps order with RuleVisitorModifierRunAfterRule`() { + val ruleIdOrder: MutableList = mutableListOf() + val onVisit: (Rule) -> Unit = { + ruleIdOrder.add(it.id) + } + val rule1 = mockRule("ccc", onVisit = onVisit) + val rule2 = mockRule("bbb", onVisit = onVisit) + val rule3 = mockRule("aaa", onVisit = onVisit) + val expectedRuleIdOrder = listOf(rule1, rule2, rule3).map { it.id } + + val ruleSet = OrderedRuleSet("id", rule1, rule2, rule3) + + KtLint.lint( + KtLint.ExperimentalParams( + fileName = TEST_FILE_NAME, + text = "fun foo() { }", + ruleSets = listOf(ruleSet), + cb = { _, _ -> }, + ) + ) + + val rulesSize = expectedRuleIdOrder.size + Assertions.assertTrue(ruleIdOrder.size % rulesSize == 0, "Rules are called several times but together") + for (repeat in 0 until (ruleIdOrder.size / rulesSize)) { + // check each run for each node + Assertions.assertEquals(expectedRuleIdOrder, ruleIdOrder.subList(repeat * rulesSize, (repeat + 1) * rulesSize)) + } + } + + companion object { + private fun mockRule( + id: String, + visitorModifiers: Set = emptySet(), + onVisit: (Rule) -> Unit = { } + ) = object : Rule(id, visitorModifiers) { + override fun visit( + node: ASTNode, + autoCorrect: Boolean, + emit: EmitType + ) { + onVisit(this) + } + } + } +} diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/SuppressTest.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/SuppressTest.kt index 349251d49e..e9e9bb8b55 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/SuppressTest.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/ruleset/utils/SuppressTest.kt @@ -140,7 +140,7 @@ class SuppressTest : LintTestBase(::IdentifierNaming) { } """.trimIndent() lintMethod(code, - LintError(3, 15, "$DIKTAT_RULE_SET_ID:aai-identifier-naming", + LintError(3, 15, "$DIKTAT_RULE_SET_ID:${IdentifierNaming.NAME_ID}", "${Warnings.FUNCTION_NAME_INCORRECT_CASE.warnText()} methODTREE", true)) } } diff --git a/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/DiktatRuleSetProvider4Test.kt b/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/DiktatRuleSetProvider4Test.kt index 8f440abf57..e937a6cb00 100644 --- a/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/DiktatRuleSetProvider4Test.kt +++ b/diktat-rules/src/test/kotlin/org/cqfn/diktat/util/DiktatRuleSetProvider4Test.kt @@ -6,15 +6,14 @@ package org.cqfn.diktat.util import org.cqfn.diktat.common.config.rules.RulesConfig import org.cqfn.diktat.common.config.rules.RulesConfigReader -import org.cqfn.diktat.ruleset.constants.EmitType import org.cqfn.diktat.ruleset.rules.DIKTAT_RULE_SET_ID import org.cqfn.diktat.ruleset.rules.DiktatRuleSetProvider +import org.cqfn.diktat.ruleset.rules.OrderedRuleSet.Companion.delegatee import com.pinterest.ktlint.core.Rule import com.pinterest.ktlint.core.RuleSet import com.pinterest.ktlint.core.RuleSetProvider import org.assertj.core.api.Assertions.assertThat -import org.jetbrains.kotlin.com.intellij.lang.ASTNode import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @@ -53,81 +52,18 @@ class DiktatRuleSetProviderTest { ) } } - .map { (it as? DiktatRuleSetProvider.OrderedRule)?.rule ?: it } + .map { it.delegatee() } .map { it::class.simpleName!! } .filterNot { it == "DummyWarning" } .toList() assertThat(rulesName.sorted()).containsExactlyElementsOf(filesName.sorted().toList()) } - @Test - fun `check OrderedRule with VisitorModifier RunAfterRule`() { - val rule = object : Rule("rule") { - override fun visit( - node: ASTNode, - autoCorrect: Boolean, - emit: EmitType - ) { - // do nothing - } - } - Assertions.assertThrows(IllegalArgumentException::class.java) { - DiktatRuleSetProvider.OrderedRule(rule, rule) - } - - val ruleWithRunAfterRule = object : Rule("invalid-rule", setOf(VisitorModifier.RunAfterRule("another-rule"))) { - override fun visit( - node: ASTNode, - autoCorrect: Boolean, - emit: EmitType - ) { - // do nothing - } - } - Assertions.assertThrows(IllegalArgumentException::class.java) { - DiktatRuleSetProvider.OrderedRule(ruleWithRunAfterRule, rule) - } - } - - @Test - fun `check OrderedRule`() { - val rule1 = object : Rule("rule-first") { - override fun visit( - node: ASTNode, - autoCorrect: Boolean, - emit: EmitType - ) { - // do nothing - } - } - val rule2 = object : Rule("rule-second") { - override fun visit( - node: ASTNode, - autoCorrect: Boolean, - emit: EmitType - ) { - // do nothing - } - } - - val orderedRule = DiktatRuleSetProvider.OrderedRule(rule2, rule1) - orderedRule.visitorModifiers - .filterIsInstance() - .also { - Assertions.assertEquals(1, it.size, - "Found invalid count of Rule.VisitorModifier.RunAfterRule") - } - .first() - .let { - Assertions.assertEquals(rule1.id, it.ruleId, - "Invalid ruleId in Rule.VisitorModifier.RunAfterRule") - } - } - companion object { private val ignoreFile = listOf( "DiktatRuleSetProvider", "DiktatRule", - "IndentationError") + "IndentationError", + "OrderedRuleSet") } }