Verify Interfaces
Last updated
Last updated
Konsist enables development teams to enforce structural rules for interfaces ensuring code consistency across projects.
To verify interfaces start by querying all interface present in the project:
Konsist allows you to verify multiple aspects of a interfaces. For a complete understanding of the available APIs, refer to the language reference documentation for .
Let's look at few examples.
Interface names can be validated to ensure they follow project naming conventions and patterns.
Check if interface name ends with Repository
:
Interface modifiers can be validated to ensure proper encapsulation and access control.
Check if interface has internal
modifier:
Interface-level and member annotations can be verified for presence, correct usage, and required attribute values.
Check if interface is annotated with Service
annotation:
Package declarations can be validated to ensure classes are located in the correct package structure according to architectural guidelines.
Check if interface has model
package or sub-packages (..
means include sub-packages):
Methods can be validated for their signatures, modifiers, annotations, naming patterns, return types, and parameter structures.
Check if methods (functions defined inside interface) have name starting with Local
:
See .
Properties can be checked for proper access modifiers, type declarations, and initialization patterns.
Check if all properties (defined inside interface) has val
modifiers:
See Verify Properties.
Generic type parameters and constraints can be checked for correct usage and bounds declarations.
Check if interface has not type parameters:
Generic type arguments can be checked for correct usage.
Check if parent has no type arguments:
Inheritance hierarchies, interfaces implementations, and superclass relationships can be validated.
Check if interface extends CrudRepository
:
Companion object declarations, their contents, and usage patterns can be verified for compliance.
Check if interface has companion object
:
The sequential arrangement of interface members can be enforced according to defined organizational rules.
Check if interface properties are defined before functions: