
Facilitates determination and enforcement of pure and readonly functions through compiler plugin annotations, ensuring functions adhere to strict immutability rules and enhancing code reliability.
A Kotlin Compiler Plugin for determining and enforcing Pure and Readonly functions.
Install the plugin by adding the following to your build.gradle.kts:
plugins {
id("io.github.yairm210.purity-plugin") version "1.3.4"
}
dependencies {
implementation("io.github.yairm210:purity-annotations:1.3.4")
}Mark pure functions using @Pure, and readonly functions using @Readonly:
import yairm210.purity.annotations.Pure
import yairm210.purity.annotations.Readonly
@Pure
fun pureFunction(x: Int): Int {
return x * 2
}
@Readonly
fun readonlyFunction(list: List<String>): Int {
return list.size
}Further details are available in the documentation
Pure functions may not:
Readonly functions may not:
Any violation of these rules creates a compilation error.
Development instructions here
Projects that helped me understand how to setup the project:
A Kotlin Compiler Plugin for determining and enforcing Pure and Readonly functions.
Install the plugin by adding the following to your build.gradle.kts:
plugins {
id("io.github.yairm210.purity-plugin") version "1.3.4"
}
dependencies {
implementation("io.github.yairm210:purity-annotations:1.3.4")
}Mark pure functions using @Pure, and readonly functions using @Readonly:
import yairm210.purity.annotations.Pure
import yairm210.purity.annotations.Readonly
@Pure
fun pureFunction(x: Int): Int {
return x * 2
}
@Readonly
fun readonlyFunction(list: List<String>): Int {
return list.size
}Further details are available in the documentation
Pure functions may not:
Readonly functions may not:
Any violation of these rules creates a compilation error.
Development instructions here
Projects that helped me understand how to setup the project: