Package-level declarations

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class ActiveByDefault(val since: String)
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class Alias(val values: String)

Provides alias for the annotated rule

Link copied to clipboard
open class CodeSmell(val entity: Entity, val message: String, val references: List<Entity> = emptyList(), val suppressReasons: List<String> = emptyList()) : Finding

A code smell indicates any possible design problem inside a program's source code. The type of a code smell is described by an Issue.

Link copied to clipboard
class CompilerResources(val languageVersionSettings: LanguageVersionSettings, val dataFlowValueFactory: DataFlowValueFactory)

Provides compiler resources.

Link copied to clipboard
interface Config

A configuration holds information about how to configure specific rules.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.PROPERTY])
annotation class Configuration(val description: String)

Annotate the target to specify a configuration for io.gitlab.arturbosch.detekt.api.Rule or io.gitlab.arturbosch.detekt.api.RuleSetProvider.

Link copied to clipboard

An extension which allows users to validate parts of the configuration.

Link copied to clipboard

Extension point which describes how findings should be printed on the console.

Link copied to clipboard
interface Detektion : UserDataHolder

Storage for all kinds of findings and additional information which needs to be transferred from the detekt engine to the user.

Link copied to clipboard
open class DetektVisitor : KtTreeVisitorVoid

Basic visitor which is used inside detekt. Guarantees a better looking name as the extended base class :).

Link copied to clipboard
class Entity(val signature: String, val location: Location, val ktElement: KtElement)

Stores information about a specific code fragment.

Link copied to clipboard
interface Extension

Defines extension points in detekt. Currently supported extensions are:

Link copied to clipboard

Gather additional metrics about the analyzed kotlin file. Pay attention to the thread policy of each function!

Link copied to clipboard
interface Finding

Represents a detected problem in the source code.

Link copied to clipboard
class Issue(val ruleInstance: RuleInstance, val entity: Issue.Entity, val references: List<Issue.Entity>, val message: String, val severity: Severity, val suppressReasons: List<String>)

Represents a problem detected by detekt on the source code

Link copied to clipboard
class Location(val source: SourceLocation, val endSource: SourceLocation, val text: TextLocation, val path: Path)

Specifies a position within a source code fragment.

Link copied to clipboard
interface Notification

Any kind of notification which should be printed to the console. For example when using the formatting rule set, any change to your kotlin file is a notification.

Link copied to clipboard
abstract class OutputReport : Extension

Translates detekt's result container - Detektion - into an output report which is written inside a file.

Link copied to clipboard
open class ProjectMetric(val type: String, val value: Int, val priority: Int = -1, val isDouble: Boolean = false, val conversionFactor: Int = DEFAULT_FLOAT_CONVERSION_FACTOR)

Anything that can be expressed as a numeric value for projects.

Link copied to clipboard
interface PropertiesAware

Properties holder. Allows to store and retrieve any data.

Link copied to clipboard

Allows to intercept detekt's result container by listening to the initial and final state and manipulate the reported issues.

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class RequiresFullAnalysis

Annotated Rule requires type resolution to work.

Link copied to clipboard
open class Rule(val config: Config, val description: String) : DetektVisitor

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.

Link copied to clipboard
class RuleInstance(val id: String, val name: Rule.Name, val ruleSetId: RuleSet.Id, val description: String)
Link copied to clipboard
class RuleSet(val id: RuleSet.Id, val rules: Map<Rule.Name, (Config) -> Rule>)

A rule set is a collection of rules and must be defined within a rule set provider implementation.

Link copied to clipboard
interface RuleSetProvider

A rule set provider, as the name states, is responsible for creating rule sets.

Link copied to clipboard

Context providing useful processing settings to initialize extensions.

Link copied to clipboard

The severity for each Issue. This will be printed to the output, such as XML or Sarif. Depending on the severity of the issues found, the build process result is determined.

Link copied to clipboard
class SourceLocation(val line: Int, val column: Int) : Comparable<SourceLocation>

Stores line and column information of a location.

Link copied to clipboard
class TextLocation(val start: Int, val end: Int)

Stores character start and end positions of a text file.

Link copied to clipboard

ValuesWithReason is essentially the same as List of ValueWithReason. Due to type erasure we cannot use the list directly. Instances of this type should always created using the valuesWithReason factory method.

Link copied to clipboard
class ValueWithReason(val value: String, val reason: String? = null)

A ValueWithReason represents a single configuration value that may have an explanation as to why it is used.

Properties

Link copied to clipboard
var KtFile.modifiedText: String?
Link copied to clipboard

Functions

Link copied to clipboard
fun <T : Any> config(defaultValue: T): ReadOnlyProperty<Rule, T>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. The value of the property is evaluated only once.

fun <T : Any, U : Any> config(defaultValue: T, transformer: (T) -> U): ReadOnlyProperty<Rule, U>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. The value of the property is evaluated and transformed only once.

Link copied to clipboard
fun <T : Any> configWithAndroidVariants(defaultValue: T, defaultAndroidValue: T): ReadOnlyProperty<Rule, T>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. The value of the property is evaluated only once.

fun <T : Any, U : Any> configWithAndroidVariants(defaultValue: T, defaultAndroidValue: T, transformer: (T) -> U): ReadOnlyProperty<Rule, U>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. The value of the property is evaluated and transformed only once.

Link copied to clipboard
fun <T : Any> configWithFallback(fallbackProperty: KProperty0<T>, defaultValue: T): ReadOnlyProperty<Rule, T>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. If there is no such property, the value of the supplied fallbackProperty is also considered before using the defaultValue. The value of the property is evaluated only once.

fun <T : Any, U : Any> configWithFallback(fallbackProperty: KProperty0<U>, defaultValue: T, transformer: (T) -> U): ReadOnlyProperty<Rule, U>

Creates a delegated read-only property that can be used in ConfigAware objects. The name of the property is the key that is used during configuration lookup. If there is no such property, the value of the supplied fallbackProperty is also considered before using the defaultValue. The value of the property is evaluated and transformed only once.

Link copied to clipboard
inline fun <T : Any> PropertiesAware.getOrNull(key: String): T?

Allows to retrieve stored properties in a type safe way.

Link copied to clipboard

Convert a simple pattern String to a Regex

Link copied to clipboard

This factory method can be used by rule authors to specify one or many configuration values along with an explanation for each value. For example:

This factory method can be used by rule authors to specify one or many configuration values along with an explanation for each value.