Rule

abstract class Rule(val ruleSetConfig: Config = Config.empty, ruleContext: Context = DefaultContext()) : BaseRule, ConfigAware

A rule defines how one specific code structure should look like. If code is found which does not meet this structure, it is considered as harmful regarding maintainability or readability.

A rule is implemented using the visitor pattern and should be started using the visit(KtFile) function. If calculations must be done before or after the visiting process, here are two predefined (preVisit/postVisit) functions which can be overridden to setup/teardown additional data.

Inheritors

Constructors

Link copied to clipboard
constructor(ruleSetConfig: Config = Config.empty, ruleContext: Context = DefaultContext())

Functions

Link copied to clipboard
open override fun clearFindings()

Clears previous findings. Normally this is done on every new KtFile analyzed and should be called by clients.

Link copied to clipboard
Link copied to clipboard
open override fun report(finding: Finding, aliases: Set<String>, ruleSetId: RuleSetId?)

Reports a single new violation. By contract the implementation can check if this finding is already suppressed and should not get reported. An alias set can be given to additionally check if an alias was used when suppressing. Additionally suppression by rule set id is supported.

open override fun report(findings: List<Finding>, aliases: Set<String>, ruleSetId: RuleSetId?)

Same as report but reports a list of findings.

fun report(finding: Finding)
fun report(findings: List<Finding>)

Simplified version of Context.report with rule defaults.

Link copied to clipboard
open override fun subConfig(key: String): Config

Tries to retrieve part of the configuration based on given key.

Link copied to clipboard
open override fun <T : Any> valueOrDefault(key: String, default: T): T

Retrieves a sub configuration or value based on given key. If configuration property cannot be found the specified default value is returned.

Link copied to clipboard
open override fun <T : Any> valueOrNull(key: String): T?

Retrieves a sub configuration or value based on given key. If the configuration property cannot be found, null is returned.

Link copied to clipboard
open fun visit(root: KtFile)

Init function to start visiting the KtFile. Can be overridden to start a different visiting process.

Link copied to clipboard
open fun visitAnnotatedExpression(@NotNull p0: KtAnnotatedExpression)
override fun visitAnnotatedExpression(@NotNull p0: KtAnnotatedExpression, p1: Void): Void
Link copied to clipboard
open fun visitAnnotation(@NotNull p0: KtAnnotation)
override fun visitAnnotation(@NotNull p0: KtAnnotation, p1: Void): Void
Link copied to clipboard
open fun visitAnnotationEntry(@NotNull p0: KtAnnotationEntry)
override fun visitAnnotationEntry(@NotNull p0: KtAnnotationEntry, p1: Void): Void
Link copied to clipboard
open fun visitAnnotationUseSiteTarget(@NotNull p0: KtAnnotationUseSiteTarget, p1: Void): Void
Link copied to clipboard
open fun visitAnonymousInitializer(@NotNull p0: KtAnonymousInitializer)
override fun visitAnonymousInitializer(@NotNull p0: KtAnonymousInitializer, p1: Void): Void
Link copied to clipboard
open fun visitArgument(@NotNull p0: KtValueArgument)
override fun visitArgument(@NotNull p0: KtValueArgument, p1: Void): Void
Link copied to clipboard
open fun visitArrayAccessExpression(@NotNull p0: KtArrayAccessExpression)
override fun visitArrayAccessExpression(@NotNull p0: KtArrayAccessExpression, p1: Void): Void
Link copied to clipboard
open fun visitBackingField(@NotNull p0: KtBackingField, p1: Void): Void
Link copied to clipboard
open fun visitBinaryExpression(@NotNull p0: KtBinaryExpression)
override fun visitBinaryExpression(@NotNull p0: KtBinaryExpression, p1: Void): Void
Link copied to clipboard
open fun visitBinaryFile(@NotNull p0: @NotNull PsiBinaryFile)
Link copied to clipboard
open fun visitBinaryWithTypeRHSExpression(@NotNull p0: KtBinaryExpressionWithTypeRHS)
override fun visitBinaryWithTypeRHSExpression(@NotNull p0: KtBinaryExpressionWithTypeRHS, p1: Void): Void
Link copied to clipboard
open fun visitBlockExpression(@NotNull p0: KtBlockExpression)
override fun visitBlockExpression(@NotNull p0: KtBlockExpression, p1: Void): Void
Link copied to clipboard
open fun visitBlockStringTemplateEntry(@NotNull p0: KtBlockStringTemplateEntry)
override fun visitBlockStringTemplateEntry(@NotNull p0: KtBlockStringTemplateEntry, p1: Void): Void
Link copied to clipboard
open fun visitBreakExpression(@NotNull p0: KtBreakExpression)
override fun visitBreakExpression(@NotNull p0: KtBreakExpression, p1: Void): Void
Link copied to clipboard
open fun visitCallableReferenceExpression(@NotNull p0: KtCallableReferenceExpression)
override fun visitCallableReferenceExpression(@NotNull p0: KtCallableReferenceExpression, p1: Void): Void
Link copied to clipboard
open fun visitCallExpression(@NotNull p0: KtCallExpression)
override fun visitCallExpression(@NotNull p0: KtCallExpression, p1: Void): Void
Link copied to clipboard
open fun visitCatchSection(@NotNull p0: KtCatchClause)
override fun visitCatchSection(@NotNull p0: KtCatchClause, p1: Void): Void
Link copied to clipboard
open fun visitClass(@NotNull p0: KtClass)
override fun visitClass(@NotNull p0: KtClass, p1: Void): Void
Link copied to clipboard
open fun visitClassBody(@NotNull p0: KtClassBody)
override fun visitClassBody(@NotNull p0: KtClassBody, p1: Void): Void
Link copied to clipboard
open fun visitClassInitializer(@NotNull p0: KtClassInitializer)
open override fun visitClassInitializer(@NotNull p0: KtClassInitializer, p1: Void): Void
Link copied to clipboard
open fun visitClassLiteralExpression(@NotNull p0: KtClassLiteralExpression)
override fun visitClassLiteralExpression(@NotNull p0: KtClassLiteralExpression, p1: Void): Void
Link copied to clipboard
open fun visitClassOrObject(@NotNull p0: KtClassOrObject)
override fun visitClassOrObject(@NotNull p0: KtClassOrObject, p1: Void): Void
Link copied to clipboard
open fun visitCollectionLiteralExpression(@NotNull p0: KtCollectionLiteralExpression)
override fun visitCollectionLiteralExpression(@NotNull p0: KtCollectionLiteralExpression, p1: Void): Void
Link copied to clipboard
open fun visitComment(@NotNull p0: @NotNull PsiComment)
Link copied to clipboard
open override fun visitCondition(root: KtFile): Boolean

Basic mechanism to decide if a rule should run or not.

Link copied to clipboard
open fun visitConstantExpression(@NotNull p0: KtConstantExpression)
override fun visitConstantExpression(@NotNull p0: KtConstantExpression, p1: Void): Void
Link copied to clipboard
open fun visitConstructorCalleeExpression(@NotNull p0: KtConstructorCalleeExpression)
override fun visitConstructorCalleeExpression(@NotNull p0: KtConstructorCalleeExpression, p1: Void): Void
Link copied to clipboard
open fun visitConstructorDelegationCall(@NotNull p0: KtConstructorDelegationCall)
override fun visitConstructorDelegationCall(@NotNull p0: KtConstructorDelegationCall, p1: Void): Void
Link copied to clipboard
open fun visitContextReceiverList(@NotNull p0: KtContextReceiverList, p1: Void): Void
open fun visitContextReceiverList(@NotNull p0: KtContextReceiverList)
Link copied to clipboard
open fun visitContinueExpression(@NotNull p0: KtContinueExpression)
override fun visitContinueExpression(@NotNull p0: KtContinueExpression, p1: Void): Void
Link copied to clipboard
open fun visitDeclaration(@NotNull p0: KtDeclaration)
override fun visitDeclaration(@NotNull p0: KtDeclaration, p1: Void): Void
Link copied to clipboard
open fun visitDelegatedSuperTypeEntry(@NotNull p0: KtDelegatedSuperTypeEntry)
override fun visitDelegatedSuperTypeEntry(@NotNull p0: KtDelegatedSuperTypeEntry, p1: Void): Void
Link copied to clipboard
open fun visitDestructuringDeclaration(@NotNull p0: KtDestructuringDeclaration)
override fun visitDestructuringDeclaration(@NotNull p0: KtDestructuringDeclaration, p1: Void): Void
Link copied to clipboard
open fun visitDestructuringDeclarationEntry(@NotNull p0: KtDestructuringDeclarationEntry)
override fun visitDestructuringDeclarationEntry(@NotNull p0: KtDestructuringDeclarationEntry, p1: Void): Void
Link copied to clipboard
open fun visitDirectory(@NotNull p0: @NotNull PsiDirectory)
Link copied to clipboard
open fun visitDotQualifiedExpression(@NotNull p0: KtDotQualifiedExpression)
override fun visitDotQualifiedExpression(@NotNull p0: KtDotQualifiedExpression, p1: Void): Void
Link copied to clipboard
open fun visitDoubleColonExpression(@NotNull p0: KtDoubleColonExpression)
override fun visitDoubleColonExpression(@NotNull p0: KtDoubleColonExpression, p1: Void): Void
Link copied to clipboard
open fun visitDoWhileExpression(@NotNull p0: KtDoWhileExpression)
override fun visitDoWhileExpression(@NotNull p0: KtDoWhileExpression, p1: Void): Void
Link copied to clipboard
open fun visitDynamicType(@NotNull p0: KtDynamicType)
open override fun visitDynamicType(@NotNull p0: KtDynamicType, p1: Void): Void
Link copied to clipboard
open override fun visitElement(@NotNull p0: PsiElement)
Link copied to clipboard
open fun visitEnumEntry(@NotNull p0: KtEnumEntry)
override fun visitEnumEntry(@NotNull p0: KtEnumEntry, p1: Void): Void
Link copied to clipboard
open fun visitErrorElement(@NotNull p0: @NotNull PsiErrorElement)
Link copied to clipboard
open fun visitEscapeStringTemplateEntry(@NotNull p0: KtEscapeStringTemplateEntry)
override fun visitEscapeStringTemplateEntry(@NotNull p0: KtEscapeStringTemplateEntry, p1: Void): Void
Link copied to clipboard
open fun visitExpression(@NotNull p0: KtExpression)
override fun visitExpression(@NotNull p0: KtExpression, p1: Void): Void
Link copied to clipboard
open fun visitExpressionWithLabel(@NotNull p0: KtExpressionWithLabel)
override fun visitExpressionWithLabel(@NotNull p0: KtExpressionWithLabel, p1: Void): Void
Link copied to clipboard
fun visitFile(root: KtFile, bindingContext: BindingContext = BindingContext.EMPTY, compilerResources: CompilerResources? = null)

Before starting visiting kotlin elements, a check is performed if this rule should be triggered. Pre- and post-visit-hooks are executed before/after the visiting process. BindingContext holds the result of the semantic analysis of the source code by the Kotlin compiler. Rules that rely on symbols and types being resolved can use the BindingContext for this analysis. Note that detekt must receive the correct compile classpath for the code being analyzed otherwise the default value BindingContext.EMPTY will be used and it will not be possible for detekt to resolve types or symbols.

open fun visitFile(@NotNull p0: @NotNull PsiFile)
Link copied to clipboard
open fun visitFileAnnotationList(@NotNull p0: KtFileAnnotationList, p1: Void): Void
Link copied to clipboard
open fun visitFinallySection(@NotNull p0: KtFinallySection)
override fun visitFinallySection(@NotNull p0: KtFinallySection, p1: Void): Void
Link copied to clipboard
open fun visitForExpression(@NotNull p0: KtForExpression)
override fun visitForExpression(@NotNull p0: KtForExpression, p1: Void): Void
Link copied to clipboard
open fun visitFunctionType(@NotNull p0: KtFunctionType)
override fun visitFunctionType(@NotNull p0: KtFunctionType, p1: Void): Void
Link copied to clipboard
open fun visitIfExpression(@NotNull p0: KtIfExpression)
override fun visitIfExpression(@NotNull p0: KtIfExpression, p1: Void): Void
Link copied to clipboard
open fun visitImportAlias(@NotNull p0: KtImportAlias, p1: Void): Void
open fun visitImportAlias(@NotNull p0: KtImportAlias)
Link copied to clipboard
open fun visitImportDirective(@NotNull p0: KtImportDirective)
override fun visitImportDirective(@NotNull p0: KtImportDirective, p1: Void): Void
Link copied to clipboard
open fun visitImportList(@NotNull p0: KtImportList)
override fun visitImportList(@NotNull p0: KtImportList, p1: Void): Void
Link copied to clipboard
open fun visitInitializerList(@NotNull p0: KtInitializerList)
override fun visitInitializerList(@NotNull p0: KtInitializerList, p1: Void): Void
Link copied to clipboard
open fun visitIntersectionType(@NotNull p0: KtIntersectionType)
open override fun visitIntersectionType(@NotNull p0: KtIntersectionType, p1: Void): Void
Link copied to clipboard
open fun visitIsExpression(@NotNull p0: KtIsExpression)
override fun visitIsExpression(@NotNull p0: KtIsExpression, p1: Void): Void
Link copied to clipboard
open fun visitKtElement(@NotNull p0: KtElement)
override fun visitKtElement(@NotNull p0: KtElement, p1: Void): Void
Link copied to clipboard
open fun visitKtFile(@NotNull p0: KtFile)
override fun visitKtFile(@NotNull p0: KtFile, p1: Void): Void
Link copied to clipboard
open fun visitLabeledExpression(@NotNull p0: KtLabeledExpression)
override fun visitLabeledExpression(@NotNull p0: KtLabeledExpression, p1: Void): Void
Link copied to clipboard
open fun visitLambdaExpression(@NotNull p0: KtLambdaExpression)
override fun visitLambdaExpression(@NotNull p0: KtLambdaExpression, p1: Void): Void
Link copied to clipboard
open fun visitLiteralStringTemplateEntry(@NotNull p0: KtLiteralStringTemplateEntry)
override fun visitLiteralStringTemplateEntry(@NotNull p0: KtLiteralStringTemplateEntry, p1: Void): Void
Link copied to clipboard
open fun visitLoopExpression(@NotNull p0: KtLoopExpression)
override fun visitLoopExpression(@NotNull p0: KtLoopExpression, p1: Void): Void
Link copied to clipboard
open fun visitModifierList(@NotNull p0: KtModifierList)
override fun visitModifierList(@NotNull p0: KtModifierList, p1: Void): Void
Link copied to clipboard
open fun visitNamedDeclaration(@NotNull p0: KtNamedDeclaration)
override fun visitNamedDeclaration(@NotNull p0: KtNamedDeclaration, p1: Void): Void
Link copied to clipboard
open fun visitNamedFunction(@NotNull p0: KtNamedFunction)
override fun visitNamedFunction(@NotNull p0: KtNamedFunction, p1: Void): Void
Link copied to clipboard
open fun visitNullableType(@NotNull p0: KtNullableType)
override fun visitNullableType(@NotNull p0: KtNullableType, p1: Void): Void
Link copied to clipboard
open fun visitObjectDeclaration(@NotNull p0: KtObjectDeclaration)
override fun visitObjectDeclaration(@NotNull p0: KtObjectDeclaration, p1: Void): Void
Link copied to clipboard
open fun visitObjectLiteralExpression(@NotNull p0: KtObjectLiteralExpression)
override fun visitObjectLiteralExpression(@NotNull p0: KtObjectLiteralExpression, p1: Void): Void
Link copied to clipboard
open fun visitOuterLanguageElement(@NotNull p0: @NotNull OuterLanguageElement)
Link copied to clipboard
open fun visitPackageDirective(@NotNull p0: KtPackageDirective)
open override fun visitPackageDirective(@NotNull p0: KtPackageDirective, p1: Void): Void
Link copied to clipboard
open fun visitParameter(@NotNull p0: KtParameter)
override fun visitParameter(@NotNull p0: KtParameter, p1: Void): Void
Link copied to clipboard
open fun visitParameterList(@NotNull p0: KtParameterList)
override fun visitParameterList(@NotNull p0: KtParameterList, p1: Void): Void
Link copied to clipboard
open fun visitParenthesizedExpression(@NotNull p0: KtParenthesizedExpression)
override fun visitParenthesizedExpression(@NotNull p0: KtParenthesizedExpression, p1: Void): Void
Link copied to clipboard
open fun visitPlainText(@NotNull p0: @NotNull PsiPlainText)
Link copied to clipboard
open fun visitPlainTextFile(@NotNull p0: @NotNull PsiPlainTextFile)
Link copied to clipboard
open fun visitPostfixExpression(@NotNull p0: KtPostfixExpression)
override fun visitPostfixExpression(@NotNull p0: KtPostfixExpression, p1: Void): Void
Link copied to clipboard
open fun visitPrefixExpression(@NotNull p0: KtPrefixExpression)
override fun visitPrefixExpression(@NotNull p0: KtPrefixExpression, p1: Void): Void
Link copied to clipboard
open fun visitPrimaryConstructor(@NotNull p0: KtPrimaryConstructor)
override fun visitPrimaryConstructor(@NotNull p0: KtPrimaryConstructor, p1: Void): Void
Link copied to clipboard
open fun visitProperty(@NotNull p0: KtProperty)
override fun visitProperty(@NotNull p0: KtProperty, p1: Void): Void
Link copied to clipboard
open fun visitPropertyAccessor(@NotNull p0: KtPropertyAccessor)
override fun visitPropertyAccessor(@NotNull p0: KtPropertyAccessor, p1: Void): Void
Link copied to clipboard
open fun visitPropertyDelegate(@NotNull p0: KtPropertyDelegate)
override fun visitPropertyDelegate(@NotNull p0: KtPropertyDelegate, p1: Void): Void
Link copied to clipboard
open fun visitQualifiedExpression(@NotNull p0: KtQualifiedExpression)
override fun visitQualifiedExpression(@NotNull p0: KtQualifiedExpression, p1: Void): Void
Link copied to clipboard
open fun visitReferenceExpression(@NotNull p0: KtReferenceExpression)
override fun visitReferenceExpression(@NotNull p0: KtReferenceExpression, p1: Void): Void
Link copied to clipboard
open fun visitReturnExpression(@NotNull p0: KtReturnExpression)
override fun visitReturnExpression(@NotNull p0: KtReturnExpression, p1: Void): Void
Link copied to clipboard
open fun visitSafeQualifiedExpression(@NotNull p0: KtSafeQualifiedExpression)
override fun visitSafeQualifiedExpression(@NotNull p0: KtSafeQualifiedExpression, p1: Void): Void
Link copied to clipboard
open fun visitScript(@NotNull p0: KtScript)
override fun visitScript(@NotNull p0: KtScript, p1: Void): Void
Link copied to clipboard
open fun visitScriptInitializer(@NotNull p0: KtScriptInitializer)
open override fun visitScriptInitializer(@NotNull p0: KtScriptInitializer, p1: Void): Void
Link copied to clipboard
open fun visitSecondaryConstructor(@NotNull p0: KtSecondaryConstructor)
override fun visitSecondaryConstructor(@NotNull p0: KtSecondaryConstructor, p1: Void): Void
Link copied to clipboard
open fun visitSelfType(@NotNull p0: KtSelfType)
override fun visitSelfType(@NotNull p0: KtSelfType, p1: Void): Void
Link copied to clipboard
open fun visitSimpleNameExpression(@NotNull p0: KtSimpleNameExpression)
override fun visitSimpleNameExpression(@NotNull p0: KtSimpleNameExpression, p1: Void): Void
Link copied to clipboard
open fun visitSimpleNameStringTemplateEntry(@NotNull p0: KtSimpleNameStringTemplateEntry)
override fun visitSimpleNameStringTemplateEntry(@NotNull p0: KtSimpleNameStringTemplateEntry, p1: Void): Void
Link copied to clipboard
open fun visitStringTemplateEntry(@NotNull p0: KtStringTemplateEntry)
override fun visitStringTemplateEntry(@NotNull p0: KtStringTemplateEntry, p1: Void): Void
Link copied to clipboard
open fun visitStringTemplateEntryWithExpression(@NotNull p0: KtStringTemplateEntryWithExpression)
override fun visitStringTemplateEntryWithExpression(@NotNull p0: KtStringTemplateEntryWithExpression, p1: Void): Void
Link copied to clipboard
open fun visitStringTemplateExpression(@NotNull p0: KtStringTemplateExpression)
override fun visitStringTemplateExpression(@NotNull p0: KtStringTemplateExpression, p1: Void): Void
Link copied to clipboard
open fun visitSuperExpression(@NotNull p0: KtSuperExpression)
override fun visitSuperExpression(@NotNull p0: KtSuperExpression, p1: Void): Void
Link copied to clipboard
open fun visitSuperTypeCallEntry(@NotNull p0: KtSuperTypeCallEntry)
override fun visitSuperTypeCallEntry(@NotNull p0: KtSuperTypeCallEntry, p1: Void): Void
Link copied to clipboard
open fun visitSuperTypeEntry(@NotNull p0: KtSuperTypeEntry)
override fun visitSuperTypeEntry(@NotNull p0: KtSuperTypeEntry, p1: Void): Void
Link copied to clipboard
open fun visitSuperTypeList(@NotNull p0: KtSuperTypeList)
override fun visitSuperTypeList(@NotNull p0: KtSuperTypeList, p1: Void): Void
Link copied to clipboard
open fun visitSuperTypeListEntry(@NotNull p0: KtSuperTypeListEntry)
override fun visitSuperTypeListEntry(@NotNull p0: KtSuperTypeListEntry, p1: Void): Void
Link copied to clipboard
open fun visitThisExpression(@NotNull p0: KtThisExpression)
override fun visitThisExpression(@NotNull p0: KtThisExpression, p1: Void): Void
Link copied to clipboard
open fun visitThrowExpression(@NotNull p0: KtThrowExpression)
override fun visitThrowExpression(@NotNull p0: KtThrowExpression, p1: Void): Void
Link copied to clipboard
open fun visitTryExpression(@NotNull p0: KtTryExpression)
override fun visitTryExpression(@NotNull p0: KtTryExpression, p1: Void): Void
Link copied to clipboard
open fun visitTypeAlias(@NotNull p0: KtTypeAlias)
override fun visitTypeAlias(@NotNull p0: KtTypeAlias, p1: Void): Void
Link copied to clipboard
open fun visitTypeArgumentList(@NotNull p0: KtTypeArgumentList)
override fun visitTypeArgumentList(@NotNull p0: KtTypeArgumentList, p1: Void): Void
Link copied to clipboard
open fun visitTypeConstraint(@NotNull p0: KtTypeConstraint)
override fun visitTypeConstraint(@NotNull p0: KtTypeConstraint, p1: Void): Void
Link copied to clipboard
open fun visitTypeConstraintList(@NotNull p0: KtTypeConstraintList)
override fun visitTypeConstraintList(@NotNull p0: KtTypeConstraintList, p1: Void): Void
Link copied to clipboard
open fun visitTypeParameter(@NotNull p0: KtTypeParameter)
override fun visitTypeParameter(@NotNull p0: KtTypeParameter, p1: Void): Void
Link copied to clipboard
open fun visitTypeParameterList(@NotNull p0: KtTypeParameterList)
override fun visitTypeParameterList(@NotNull p0: KtTypeParameterList, p1: Void): Void
Link copied to clipboard
open fun visitTypeProjection(@NotNull p0: KtTypeProjection)
override fun visitTypeProjection(@NotNull p0: KtTypeProjection, p1: Void): Void
Link copied to clipboard
open fun visitTypeReference(@NotNull p0: KtTypeReference)
override fun visitTypeReference(@NotNull p0: KtTypeReference, p1: Void): Void
Link copied to clipboard
open fun visitUnaryExpression(@NotNull p0: KtUnaryExpression)
override fun visitUnaryExpression(@NotNull p0: KtUnaryExpression, p1: Void): Void
Link copied to clipboard
open fun visitUserType(@NotNull p0: KtUserType)
override fun visitUserType(@NotNull p0: KtUserType, p1: Void): Void
Link copied to clipboard
open fun visitValueArgumentList(@NotNull p0: KtValueArgumentList)
override fun visitValueArgumentList(@NotNull p0: KtValueArgumentList, p1: Void): Void
Link copied to clipboard
open fun visitWhenConditionInRange(@NotNull p0: KtWhenConditionInRange)
override fun visitWhenConditionInRange(@NotNull p0: KtWhenConditionInRange, p1: Void): Void
Link copied to clipboard
open fun visitWhenConditionIsPattern(@NotNull p0: KtWhenConditionIsPattern)
override fun visitWhenConditionIsPattern(@NotNull p0: KtWhenConditionIsPattern, p1: Void): Void
Link copied to clipboard
open fun visitWhenConditionWithExpression(@NotNull p0: KtWhenConditionWithExpression)
override fun visitWhenConditionWithExpression(@NotNull p0: KtWhenConditionWithExpression, p1: Void): Void
Link copied to clipboard
open fun visitWhenEntry(@NotNull p0: KtWhenEntry)
override fun visitWhenEntry(@NotNull p0: KtWhenEntry, p1: Void): Void
Link copied to clipboard
open fun visitWhenExpression(@NotNull p0: KtWhenExpression)
override fun visitWhenExpression(@NotNull p0: KtWhenExpression, p1: Void): Void
Link copied to clipboard
open fun visitWhileExpression(@NotNull p0: KtWhileExpression)
override fun visitWhileExpression(@NotNull p0: KtWhileExpression, p1: Void): Void
Link copied to clipboard
open fun visitWhiteSpace(@NotNull p0: @NotNull PsiWhiteSpace)
Link copied to clipboard
open fun withAutoCorrect(block: () -> Unit)

If your rule supports to automatically correct the misbehaviour of underlying smell, specify your code inside this method call, to allow the user of your rule to trigger auto correction only when needed.

Properties

Link copied to clipboard
open val active: Boolean

Is this rule specified as active in configuration? If a rule is not specified in the underlying configuration, we assume it should not be run.

Link copied to clipboard

List of rule ids which can optionally be used in suppress annotations to refer to this rule.

Link copied to clipboard

Does this rule have auto correct specified in configuration? For auto correction to work the rule set itself enable it.

Link copied to clipboard
var bindingContext: BindingContext
Link copied to clipboard
Link copied to clipboard

The default names which can be used instead of this ruleId to refer to this rule in suppression's.

Link copied to clipboard
open val filters: PathFilters?

Rules are aware of the paths they should run on via configuration properties.

Link copied to clipboard
open override val findings: List<Finding>
Link copied to clipboard
abstract val issue: Issue

A rule is motivated to point out a specific issue in the code base.

Link copied to clipboard
open val parentPath: String?

Keeps track of which key was taken to subConfig this configuration. Sub-sequential calls to subConfig are tracked with '>' as a separator.

Link copied to clipboard
override val ruleId: RuleId

An id this rule is identified with. Conventionally the rule id is derived from the issue id as these two classes have a coexistence.

Link copied to clipboard
open override val ruleSetConfig: Config

Wrapped configuration of the ruleSet this rule is in. Use valueOrDefault function to retrieve properties specified for the rule implementing this interface instead. Only use this property directly if you need a specific rule set property.