KontureScope

class KontureScope(val classes: List<ClassDeclaration>)

Represents a scope containing a set of classes for writing architecture rules in a Konsist-inspired fluent DSL.

A scope acts as the starting point or container for filtering, querying, and running assertions against Kotlin class declarations in your codebase.

Constructors

Link copied to clipboard
constructor(classes: List<ClassDeclaration>)

Types

Link copied to clipboard
object Companion

Factory methods for constructing class scopes.

Properties

Link copied to clipboard

Filter or assertion criteria for classes.

Functions

Link copied to clipboard

Asserts that all class declarations in the scope represent abstract classes or interfaces.

Link copied to clipboard
fun KontureScope.assertAreAssignableTo(vararg superTypes: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that all class declarations in the scope extend or implement any of the specified supertypes.

fun KontureScope.assertAreAssignableTo(first: KClass<*>, vararg additional: KClass<*>, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that classes in a KontureScope are assignable to first and additional supertypes.

Link copied to clipboard
inline fun <T : Any> KontureScope.assertAreAssignableToType(vararg additional: KClass<*>, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that classes in a KontureScope are assignable to type parameter T.

Link copied to clipboard

Asserts that all class declarations in the scope are data classes.

Link copied to clipboard

Asserts that all class declarations in the scope represent enum classes.

Link copied to clipboard

Asserts that all class declarations in the scope are inline/value classes.

Link copied to clipboard

Asserts that all class declarations in the scope represent interfaces.

Link copied to clipboard

Asserts that all class declarations in the scope are internal.

Link copied to clipboard

Asserts that all class declarations in the scope are private.

Link copied to clipboard

Asserts that all class declarations in the scope are protected.

Link copied to clipboard

Asserts that all class declarations in the scope are public.

Link copied to clipboard

Asserts that all class declarations in the scope are sealed classes.

Link copied to clipboard
fun KontureScope.assertHasKDoc(additionalMessage: String? = null)

Asserts that all classes in this scope have KDoc documentation.

Link copied to clipboard
fun KontureScope.assertHaveAnnotationOf(vararg annotationFqNames: String)

Asserts that all class declarations in the scope have at least one of the specified annotations. Matches either the annotation's simple name or its fully qualified name (FQN).

Asserts that classes in a KontureScope have the specified annotations.

Link copied to clipboard

Asserts that classes in a KontureScope have annotation type parameter T.

Link copied to clipboard

Asserts that all class declarations in the scope have the specified visibility.

Link copied to clipboard

Asserts that all class declarations in the scope have names ending with any of the specified suffixes.

Link copied to clipboard
fun KontureScope.assertNameMatching(vararg patterns: String)

Asserts that all class declarations in the scope have names matching any of the specified glob patterns. Supports '*' wildcards.

Link copied to clipboard

Asserts that all class declarations in the scope have names starting with any of the specified prefixes.

Link copied to clipboard
fun KontureScope.assertNotBeAccessedByAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes in the scope are not accessed by any class residing in packages matching the specified patterns.

Link copied to clipboard
fun KontureScope.assertNotDependOnClassesInAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes in the scope do not depend on classes residing in packages matching the specified patterns.

Link copied to clipboard
fun KontureScope.assertOnlyBeAccessedByAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes in the scope are only accessed by classes residing in packages matching the specified patterns.

Link copied to clipboard
fun KontureScope.assertOnlyDependOnClassesInAnyPackage(vararg packagePatterns: String, allClasses: List<ClassDeclaration> = Konture.projectGraph.getAllModules().flatMap { it.classes })

Asserts that the selected classes in the scope depend only on classes residing in packages matching the specified patterns.

Link copied to clipboard
fun KontureScope.assertResideInAPackage(vararg packagePatterns: String)

Asserts that all class declarations in the scope reside in packages matching any of the specified patterns. Matches using standard Kotlin package wildcard matching (e.g. "..domain..").

Link copied to clipboard
fun KontureScope.assertTrue(additionalMessage: String? = null, predicate: (ClassDeclaration) -> Boolean)

Asserts that all classes in this scope satisfy predicate.

Link copied to clipboard

Filters classes in this scope to normal classes.

Link copied to clipboard

Filters classes in this scope to data classes.

Link copied to clipboard

Filters classes in this scope ending with suffix.

Link copied to clipboard

Filters classes in this scope starting with prefix.

Link copied to clipboard

Filters classes in this scope to inline/value classes.

Link copied to clipboard

Filters this class selector to include classes residing in packages matching the specified pattern.

Link copied to clipboard

Filters classes in this scope to interfaces.

Link copied to clipboard

Filters classes in this scope to internal classes.

Link copied to clipboard

Subtracts classes present in other scope from this scope.

Link copied to clipboard

Combines two KontureScope instances into a new scope containing classes from both.

Link copied to clipboard

Filters classes in this scope to private classes.

Link copied to clipboard

Filters classes in this scope to protected classes.

Link copied to clipboard

Filters classes in this scope to public classes.

Link copied to clipboard

Filters classes in this scope residing in packages matching packagePattern.

Link copied to clipboard

Filters classes in this scope to sealed classes.

Link copied to clipboard

Returns a fluent assertion scope for sequential assertions on this ClassSelector.

Link copied to clipboard

Filters classes in a KontureScope returning those with annotation type parameter T.

Filters classes in this scope with annotation annotationFqName.

Filters classes in a KontureScope returning those with annotation annotation.

Link copied to clipboard

Filters classes in this scope with modifier.

Link copied to clipboard
fun KontureScope.withModule(modulePath: String, graph: ProjectGraph = Konture.projectGraph): KontureScope

Filters classes in this scope residing in module modulePath.

Link copied to clipboard

Filters this class selector to include classes whose simple names match the specified pattern.

Link copied to clipboard

Filters classes in this scope matching name pattern pattern.

Link copied to clipboard

Filters classes in a KontureScope returning those without annotation type parameter T.

Filters classes in this scope without annotation annotationFqName.

Filters classes in a KontureScope returning those without annotation annotation.

Link copied to clipboard

Filters classes in a KontureScope returning those with parent type parameter T.

Filters classes in this scope with parent fqName.

Filters classes in a KontureScope returning those with parent type.

Link copied to clipboard

Filters classes in this scope with visibility.