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

Bugfix. New lines rule(#748) #749

Merged
merged 24 commits into from
Feb 15, 2021
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 @@ -8,8 +8,14 @@ package org.cqfn.diktat.plugin.gradle

import groovy.lang.Closure

@Suppress("MISSING_KDOC_TOP_LEVEL", "MISSING_KDOC_CLASS_ELEMENTS", "KDOC_NO_CONSTRUCTOR_PROPERTY",
"MISSING_KDOC_ON_FUNCTION", "KDOC_WITHOUT_PARAM_TAG", "KDOC_WITHOUT_RETURN_TAG")
@Suppress(
"MISSING_KDOC_TOP_LEVEL",
"MISSING_KDOC_CLASS_ELEMENTS",
"KDOC_NO_CONSTRUCTOR_PROPERTY",
"MISSING_KDOC_ON_FUNCTION",
"KDOC_WITHOUT_PARAM_TAG",
"KDOC_WITHOUT_RETURN_TAG"
)
class KotlinClosure1<in T : Any?, V : Any>(
val function: T.() -> V?,
owner: Any? = null,
Expand All @@ -21,6 +27,11 @@ class KotlinClosure1<in T : Any?, V : Any>(

// These two are copy-pasted from `kotlin-dsl` plugin's groovy interop.
// Because `kotlin-dsl` depends on kotlin 1.3.x.
@Suppress("MISSING_KDOC_TOP_LEVEL", "MISSING_KDOC_ON_FUNCTION", "KDOC_WITHOUT_PARAM_TAG", "KDOC_WITHOUT_RETURN_TAG")
@Suppress(
"MISSING_KDOC_TOP_LEVEL",
"MISSING_KDOC_ON_FUNCTION",
"KDOC_WITHOUT_PARAM_TAG",
"KDOC_WITHOUT_RETURN_TAG"
)
fun <T> Any.closureOf(action: T.() -> Unit): Closure<Any?> =
KotlinClosure1(action, this, this)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ typealias ListOfPairs = MutableList<Pair<ASTNode, String>>
* @property canBeAutoCorrected whether this inspection can automatically fix the code
* @property ruleId number of the inspection according to []diktat code style](https://www.cqfn.org/diKTat/info/guide/diktat-coding-convention.html)
*/
@Suppress("ForbiddenComment", "MagicNumber", "WRONG_DECLARATIONS_ORDER", "MaxLineLength")
@Suppress(
"ForbiddenComment",
"MagicNumber",
"WRONG_DECLARATIONS_ORDER",
"MaxLineLength",
"WRONG_NEWLINES"
)
enum class Warnings(
val canBeAutoCorrected: Boolean,
val ruleId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import java.io.File
* Aggressive: In case file contains only one class on upper level - it should be named with the same name
*/
@Suppress("ForbiddenComment")
class FileNaming(configRules: List<RulesConfig>) : DiktatRule("file-naming", configRules, listOf(FILE_NAME_INCORRECT, FILE_NAME_MATCH_CLASS)) {
class FileNaming(configRules: List<RulesConfig>) : DiktatRule(
"file-naming",
configRules,
listOf(FILE_NAME_INCORRECT, FILE_NAME_MATCH_CLASS)) {
private lateinit var filePath: String

override fun logic(node: ASTNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
* // FixMe: because it fixes only declaration without the usages
*/
@Suppress("ForbiddenComment", "MISSING_KDOC_CLASS_ELEMENTS")
class IdentifierNaming(configRules: List<RulesConfig>) : DiktatRule("identifier-naming", configRules,
class IdentifierNaming(configRules: List<RulesConfig>) : DiktatRule(
"identifier-naming",
configRules,
listOf(BACKTICKS_PROHIBITED, VARIABLE_NAME_INCORRECT, VARIABLE_NAME_INCORRECT_FORMAT, CONSTANT_UPPERCASE,
VARIABLE_HAS_PREFIX, CONFUSING_IDENTIFIER_NAMING, GENERIC_NAME, CLASS_NAME_INCORRECT,
ENUM_VALUE, EXCEPTION_SUFFIX, FUNCTION_BOOLEAN_PREFIX, FUNCTION_NAME_INCORRECT_CASE,
Expand Down Expand Up @@ -148,7 +150,11 @@ class IdentifierNaming(configRules: List<RulesConfig>) : DiktatRule("identifier-
/**
* all checks for case and naming for vals/vars/constants
*/
@Suppress("SAY_NO_TO_VAR", "TOO_LONG_FUNCTION", "ComplexMethod")
@Suppress(
"SAY_NO_TO_VAR",
"TOO_LONG_FUNCTION",
"ComplexMethod"
)
private fun checkVariableName(node: ASTNode): List<ASTNode> {
// special case for Destructuring declarations that can be treated as parameters in lambda:
var namesOfVariables = extractVariableIdentifiers(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ import java.util.concurrent.atomic.AtomicInteger
* package a.b.c.D -> then class D should be placed in a/b/c/ directories
*/
@Suppress("ForbiddenComment", "TOO_MANY_LINES_IN_LAMBDA")
class PackageNaming(configRules: List<RulesConfig>) : DiktatRule("package-naming", configRules,
class PackageNaming(configRules: List<RulesConfig>) : DiktatRule(
"package-naming",
configRules,
listOf(INCORRECT_PACKAGE_SEPARATOR, PACKAGE_NAME_INCORRECT_CASE, PACKAGE_NAME_MISSING,
PACKAGE_NAME_INCORRECT_PATH, PACKAGE_NAME_INCORRECT_PREFIX, PACKAGE_NAME_INCORRECT_SYMBOLS)) {
private lateinit var domainName: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import org.jetbrains.kotlin.resolve.ImportPath
* No commented out code is allowed, including imports.
*/
@Suppress("ForbiddenComment")
class CommentsRule(configRules: List<RulesConfig>) : DiktatRule("comments", configRules, listOf(COMMENTED_OUT_CODE)) {
class CommentsRule(configRules: List<RulesConfig>) : DiktatRule(
"comments",
configRules,
listOf(COMMENTED_OUT_CODE)) {
private lateinit var ktPsiFactory: KtPsiFactory

override fun logic(node: ASTNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ import java.time.LocalDate
* 4) Ensure files with many or zero classes have proper description
*/
@Suppress("ForbiddenComment")
class HeaderCommentRule(configRules: List<RulesConfig>) : DiktatRule("header-comment", configRules,
class HeaderCommentRule(configRules: List<RulesConfig>) : DiktatRule(
"header-comment",
configRules,
listOf(HEADER_MISSING_IN_NON_SINGLE_CLASS_FILE, HEADER_MISSING_OR_WRONG_COPYRIGHT, HEADER_NOT_BEFORE_PACKAGE,
HEADER_NOT_BEFORE_PACKAGE, HEADER_WRONG_FORMAT, WRONG_COPYRIGHT_YEAR)) {
override fun logic(node: ASTNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl
* * Leave one single space between the comment on the right side of the code and the code.
* * Comments in if else should be inside code blocks. Exception: General if comment
*/
class CommentsFormatting(configRules: List<RulesConfig>) : DiktatRule("kdoc-comments-codeblocks-formatting", configRules,
class CommentsFormatting(configRules: List<RulesConfig>) : DiktatRule(
"kdoc-comments-codeblocks-formatting",
configRules,
listOf(COMMENT_WHITE_SPACE, FIRST_COMMENT_NO_BLANK_LINE,
IF_ELSE_COMMENTS, WRONG_NEWLINES_AROUND_KDOC)) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ import org.jetbrains.kotlin.psi.psiUtil.parents
* 2) All internal elements in class like class, property or function should be documented with KDoc
* 3) All properties declared in the primary constructor are documented using `@property` tag in class KDoc
*/
class KdocComments(configRules: List<RulesConfig>) : DiktatRule("kdoc-comments", configRules,
class KdocComments(configRules: List<RulesConfig>) : 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)) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ import java.time.temporal.ChronoField
* 7) ensuring @since tag contains only versions and not dates
*/
@Suppress("ForbiddenComment")
class KdocFormatting(configRules: List<RulesConfig>) : DiktatRule("kdoc-formatting", configRules,
class KdocFormatting(configRules: List<RulesConfig>) : 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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ import org.jetbrains.kotlin.psi.psiUtil.referenceExpression
* Currently only `throw` keyword from this methods body is supported for `@throws` check.
*/
@Suppress("ForbiddenComment")
class KdocMethods(configRules: List<RulesConfig>) : DiktatRule("kdoc-methods", configRules,
class KdocMethods(configRules: List<RulesConfig>) : 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)) {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ 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<RulesConfig>) : DiktatRule("annotation-new-line", configRules, listOf(ANNOTATION_NEW_LINE)) {
class AnnotationNewLineRule(configRules: List<RulesConfig>) : DiktatRule(
"annotation-new-line",
configRules,
listOf(ANNOTATION_NEW_LINE)) {
override fun logic(node: ASTNode) {
when (node.elementType) {
CLASS, FUN, PRIMARY_CONSTRUCTOR, SECONDARY_CONSTRUCTOR -> checkAnnotation(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ import org.jetbrains.kotlin.psi.KtTryExpression
* - opening brace of lambda
* - braces around `else`/`catch`/`finally`/`while` (in `do-while` loop)
*/
class BlockStructureBraces(configRules: List<RulesConfig>) : DiktatRule("block-structure", configRules, listOf(BRACES_BLOCK_STRUCTURE_ERROR)) {
class BlockStructureBraces(configRules: List<RulesConfig>) : DiktatRule(
"block-structure",
configRules,
listOf(BRACES_BLOCK_STRUCTURE_ERROR)) {
override fun logic(node: ASTNode) {
val configuration = BlockStructureBracesConfiguration(
configRules.getRuleConfig(BRACES_BLOCK_STRUCTURE_ERROR)?.configuration ?: emptyMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import org.jetbrains.kotlin.psi.psiUtil.astReplace
/**
* Rule that checks that all conditionals and loops have braces.
*/
class BracesInConditionalsAndLoopsRule(configRules: List<RulesConfig>) : DiktatRule("braces-rule", configRules, listOf(NO_BRACES_IN_CONDITIONALS_AND_LOOPS)) {
class BracesInConditionalsAndLoopsRule(configRules: List<RulesConfig>) : DiktatRule(
"braces-rule",
configRules,
listOf(NO_BRACES_IN_CONDITIONALS_AND_LOOPS)) {
override fun logic(node: ASTNode) {
when (node.elementType) {
IF -> checkIfNode(node)
Expand All @@ -47,7 +50,12 @@ class BracesInConditionalsAndLoopsRule(configRules: List<RulesConfig>) : DiktatR
/**
* Check braces in if-else statements. Check for both IF and ELSE needs to be done in one method to discover single-line if-else statements correctly.
*/
@Suppress("ForbiddenComment", "UnsafeCallOnNullableType", "ComplexMethod", "TOO_LONG_FUNCTION")
@Suppress(
"ForbiddenComment",
"UnsafeCallOnNullableType",
"ComplexMethod",
"TOO_LONG_FUNCTION"
)
private fun checkIfNode(node: ASTNode) {
val ifPsi = node.psi as KtIfExpression
val thenNode = ifPsi.then?.node
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings
/**
* Rule that checks order of declarations inside classes, interfaces and objects.
*/
class ClassLikeStructuresOrderRule(configRules: List<RulesConfig>) : DiktatRule("class-like-structures", configRules,
class ClassLikeStructuresOrderRule(configRules: List<RulesConfig>) : DiktatRule(
"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) {
Expand All @@ -51,7 +53,12 @@ class ClassLikeStructuresOrderRule(configRules: List<RulesConfig>) : DiktatRule(
}
}

@Suppress("UnsafeCallOnNullableType", "LongMethod", "ComplexMethod", "TOO_LONG_FUNCTION")
@Suppress(
"UnsafeCallOnNullableType",
"LongMethod",
"ComplexMethod",
"TOO_LONG_FUNCTION"
)
private fun checkDeclarationsOrderInClass(node: ASTNode) {
val allProperties = node.getChildren(TokenSet.create(PROPERTY))
val constProperties = allProperties.filter { it.findLeafWithSpecificType(CONST_KEYWORD) != null }.toMutableList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafElement
* 2) If saveInitialFormattingForEnums is true then white spaces in enums will not be affected
*
*/
class ConsecutiveSpacesRule(configRules: List<RulesConfig>) : DiktatRule("too-many-spaces", configRules, listOf(TOO_MANY_CONSECUTIVE_SPACES)) {
class ConsecutiveSpacesRule(configRules: List<RulesConfig>) : DiktatRule(
"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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ 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<RulesConfig>) : DiktatRule("empty-block-structure", configRules, listOf(EMPTY_BLOCK_STRUCTURE_ERROR)) {
class EmptyBlock(configRules: List<RulesConfig>) : DiktatRule(
"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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl
/**
* Rule that checks enum classes formatting
*/
class EnumsSeparated(configRules: List<RulesConfig>) : DiktatRule("enum-separated", configRules, listOf(ENUMS_SEPARATED)) {
class EnumsSeparated(configRules: List<RulesConfig>) : DiktatRule(
"enum-separated",
configRules,
listOf(ENUMS_SEPARATED)) {
override fun logic(node: ASTNode) {
if (node.elementType == CLASS && node.hasChildOfType(CLASS_BODY)) {
if (node.isClassEnum()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ import java.net.URL
* Rule can fix long binary expressions in condition inside `if` and in property declarations and one line functions
*/
@Suppress("ForbiddenComment")
class LineLength(configRules: List<RulesConfig>) : DiktatRule("line-length", configRules, listOf(LONG_LINE)) {
class LineLength(configRules: List<RulesConfig>) : DiktatRule(
"line-length",
configRules,
listOf(LONG_LINE)) {
private lateinit var positionByOffset: (Int) -> Pair<Int, Int>

override fun logic(node: ASTNode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import java.lang.StringBuilder
/**
* Rule that checks if numerical separators (`_`) are used for long numerical literals
*/
class LongNumericalValuesSeparatedRule(configRules: List<RulesConfig>) : DiktatRule("long-numerical-values", configRules, listOf(LONG_NUMERICAL_VALUES_SEPARATED)) {
class LongNumericalValuesSeparatedRule(configRules: List<RulesConfig>) : DiktatRule(
"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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import org.jetbrains.kotlin.psi.psiUtil.children
/**
* @property configRules
*/
class MultipleModifiersSequence(configRules: List<RulesConfig>) : DiktatRule("multiple-modifiers", configRules, listOf(WRONG_MULTIPLE_MODIFIERS_ORDER)) {
class MultipleModifiersSequence(configRules: List<RulesConfig>) : DiktatRule(
"multiple-modifiers",
configRules,
listOf(WRONG_MULTIPLE_MODIFIERS_ORDER)) {
override fun logic(node: ASTNode) {
if (node.elementType == MODIFIER_LIST) {
checkModifierList(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ 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<RulesConfig>) : DiktatRule("nullable-type", configRules, listOf(NULLABLE_PROPERTY_TYPE)) {
class NullableTypeRule(configRules: List<RulesConfig>) : DiktatRule(
"nullable-type",
configRules,
listOf(NULLABLE_PROPERTY_TYPE)) {
override fun logic(node: ASTNode) {
if (node.elementType == PROPERTY) {
checkProperty(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ 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<RulesConfig>) : DiktatRule("statement", configRules, listOf(MORE_THAN_ONE_STATEMENT_PER_LINE)) {
class SingleLineStatementsRule(configRules: List<RulesConfig>) : DiktatRule(
"statement",
configRules,
listOf(MORE_THAN_ONE_STATEMENT_PER_LINE)) {
override fun logic(node: ASTNode) {
checkSemicolon(node)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings
/**
* Rule that sorts class properties and enum members alphabetically
*/
class SortRule(configRules: List<RulesConfig>) : DiktatRule("sort-rule", configRules, listOf(WRONG_DECLARATIONS_ORDER)) {
class SortRule(configRules: List<RulesConfig>) : DiktatRule(
"sort-rule",
configRules,
listOf(WRONG_DECLARATIONS_ORDER)) {
override fun logic(node: ASTNode) {
val configuration = SortRuleConfiguration(
configRules.getRuleConfig(WRONG_DECLARATIONS_ORDER)?.configuration ?: emptyMap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import org.jetbrains.kotlin.com.intellij.lang.ASTNode
* // FixMe: fixes will be added
* // FixMe: .toString() method and functions that return strings are not supported
*/
class StringConcatenationRule(configRules: List<RulesConfig>) : DiktatRule("string-concatenation", configRules, listOf(STRING_CONCATENATION)) {
class StringConcatenationRule(configRules: List<RulesConfig>) : DiktatRule(
"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" (+)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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<RulesConfig>) : DiktatRule("string-template-format", configRules,
class StringTemplateFormatRule(configRules: List<RulesConfig>) : DiktatRule(
"string-template-format",
configRules,
listOf(STRING_TEMPLATE_CURLY_BRACES, STRING_TEMPLATE_QUOTES)) {
override fun logic(node: ASTNode) {
when (node.elementType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings
* [12] Destructuring declarations
*/
@Suppress("TOO_LONG_FUNCTION")
class TrailingCommaRule(configRules: List<RulesConfig>) : DiktatRule("trailing-comma", configRules, listOf(TRAILING_COMMA)) {
class TrailingCommaRule(configRules: List<RulesConfig>) : DiktatRule(
"trailing-comma",
configRules,
listOf(TRAILING_COMMA)) {
private val commonConfig = configRules.getCommonConfiguration()
private val trailingConfig = this.configRules.getRuleConfig(TRAILING_COMMA)?.configuration ?: emptyMap()
private val configuration by lazy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ import org.jetbrains.kotlin.psi.KtWhenExpression
* The compiler can issue a warning when it is missing.
*/
@Suppress("ForbiddenComment")
class WhenMustHaveElseRule(configRules: List<RulesConfig>) : DiktatRule("no-else-in-when", configRules, listOf(WHEN_WITHOUT_ELSE)) {
class WhenMustHaveElseRule(configRules: List<RulesConfig>) : DiktatRule(
"no-else-in-when",
configRules,
listOf(WHEN_WITHOUT_ELSE)) {
override fun logic(node: ASTNode) {
if (node.elementType == ElementType.WHEN && isStatement(node)) {
checkEntries(node)
Expand Down
Loading