Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctred NAME_ID #1306

Merged
merged 5 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYS
::SingleInitRule,
::RangeConventionalRule,
::CustomLabel,
::ParameterNameInOuterLambdaRule,
::VariableGenericTypeDeclarationRule,
::LongNumericalValuesSeparatedRule,
::NestedFunctionBlock,
Expand Down Expand Up @@ -213,6 +212,7 @@ class DiktatRuleSetProvider(private var diktatConfigFile: String = DIKTAT_ANALYS
::ExtensionFunctionsSameNameRule,
::LambdaLengthRule,
::BooleanExpressionsRule,
::ParameterNameInOuterLambdaRule,
// formatting: moving blocks, adding line breaks, indentations etc.
::BlockStructureBraces,
::ConsecutiveSpacesRule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class HeaderCommentRule(configRules: List<RulesConfig>) : DiktatRule(
companion object {
private val log = LoggerFactory.getLogger(HeaderCommentRule::class.java)
const val CURR_YEAR_PATTERN = ";@currYear;"
const val NAME_ID = "acp-header-comment"
const val NAME_ID = "zcp-header-comment"
val hyphenRegex = Regex("""\d+-\d+""")
val afterCopyrightRegex = Regex("""((©|\([cC]\))+ *\d+)""")
val curYear = LocalDate.now().year
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,6 @@ class BlockStructureBraces(configRules: List<RulesConfig>) : DiktatRule(
}

companion object {
const val NAME_ID = "acn-block-structure"
const val NAME_ID = "zcn-block-structure"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ class ConsecutiveSpacesRule(configRules: List<RulesConfig>) : DiktatRule(

companion object {
private const val MAX_SPACES = 1
const val NAME_ID = "aco-too-many-spaces"
const val NAME_ID = "zco-too-many-spaces"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,6 @@ class FileStructureRule(configRules: List<RulesConfig>) : DiktatRule(
}

companion object {
const val NAME_ID = "acq-file-structure"
const val NAME_ID = "zcq-file-structure"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ class IndentationRule(configRules: List<RulesConfig>) : DiktatRule(
companion object {
private val log = LoggerFactory.getLogger(IndentationRule::class.java)
const val INDENT_SIZE = 4
const val NAME_ID = "act-indentation"
const val NAME_ID = "zct-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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ class NewlinesRule(configRules: List<RulesConfig>) : DiktatRule(
companion object {
private val log = LoggerFactory.getLogger(NewlinesRule::class.java)
const val MAX_CALLS_IN_ONE_LINE = 3
const val NAME_ID = "acr-newlines"
const val NAME_ID = "zcr-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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ class WhiteSpaceRule(configRules: List<RulesConfig>) : DiktatRule(

companion object {
private val log = LoggerFactory.getLogger(CompactInitialization::class.java)
const val NAME_ID = "acs-horizontal-whitespace"
const val NAME_ID = "zcs-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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ class ImmutableValNoVarRule(configRules: List<RulesConfig>) : DiktatRule(
}
}
companion object {
const val NAME_ID = "abt-accurate-calculations"
const val NAME_ID = "aci-no-var-rule"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.com.intellij.lang.ASTNode
* Rule 5.2.7 check parameter name in outer lambda
*/
class ParameterNameInOuterLambdaRule(configRules: List<RulesConfig>) : DiktatRule(
"parameter-name-in-outer-lambda",
NAME_ID,
configRules,
listOf(PARAMETER_NAME_IN_OUTER_LAMBDA)
) {
Expand All @@ -35,4 +35,7 @@ class ParameterNameInOuterLambdaRule(configRules: List<RulesConfig>) : DiktatRul
)
}
}
companion object {
const val NAME_ID = "acn-parameter-name-in-outer-lambda"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,6 @@ class StatelessClassesRule(configRules: List<RulesConfig>) : DiktatRule(
}

companion object {
const val NAME_ID = "abi-multiple-init-block"
const val NAME_ID = "aaz-stateless-class"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why aaz here?

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.cqfn.diktat.common.config.rules.RulesConfig
import org.cqfn.diktat.ruleset.constants.Warnings
import org.cqfn.diktat.ruleset.rules.DIKTAT_RULE_SET_ID
import org.cqfn.diktat.ruleset.rules.chapter5.ParameterNameInOuterLambdaRule
import org.cqfn.diktat.ruleset.rules.chapter6.classes.AbstractClassesRule
import org.cqfn.diktat.util.LintTestBase

import com.pinterest.ktlint.core.LintError
Expand All @@ -12,7 +13,7 @@ import org.junit.jupiter.api.Tag
import org.junit.jupiter.api.Test

class ParameterNameInOuterLambdaRuleWarnTest : LintTestBase(::ParameterNameInOuterLambdaRule) {
private val ruleId = "$DIKTAT_RULE_SET_ID:parameter-name-in-outer-lambda"
private val ruleId = "$DIKTAT_RULE_SET_ID:${ParameterNameInOuterLambdaRule.NAME_ID}"
private val rulesConfigList: List<RulesConfig> = listOf(
RulesConfig(Warnings.PARAMETER_NAME_IN_OUTER_LAMBDA.name, true)
)
Expand Down