Package-level declarations

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class ActiveByDefault(val since: String)
Link copied to clipboard
class AnnotationExcluder(root: KtFile, excludes: List<Regex>, context: BindingContext)

Primary use case for an AnnotationExcluder is to decide if a KtElement should be excluded from further analysis. This is done by checking if a special annotation is present over the element.

Link copied to clipboard
open class CodeSmell(val entity: Entity, val message: String, val references: List<Entity> = 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
interface Compactable

Provides a compact string representation.

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
abstract class ConsoleReport : Extension

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

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

Represents a code smell that can be auto-corrected.

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 name: String, val signature: String, val location: Location, val ktElement: KtElement? = null) : Compactable

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 : HasEntity

Represents a problem detected by a rule on the source code

Link copied to clipboard
interface Finding2 : HasEntity

Represents a problem detected by detekt on the source code

Link copied to clipboard
interface HasEntity

Describes a source code position.

Link copied to clipboard
class Issue(val id: Rule.Id, val description: String)

An issue represents a problem in the codebase.

Link copied to clipboard
class Location(val source: SourceLocation, val endSource: SourceLocation = source, val text: TextLocation, val filePath: FilePath) : Compactable

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 findings.

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

Annotated Rule requires type resolution to work.

Link copied to clipboard
open class Rule(val config: Config, 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 RuleSet(val id: RuleSet.Id, val rules: Map<Rule.Id, (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)

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.

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.