Skip to content

Latest commit

 

History

History
85 lines (63 loc) · 2.63 KB

CONTRIBUTING.md

File metadata and controls

85 lines (63 loc) · 2.63 KB

How to contribute to Clay

Pull requests are always welcome

First of all, thank you so much for taking your time to contribute! We always welcome your ideas and feedback. Please feel free to make any pull requests.

Contributor license agreement

If you are sending a pull request and it's a non-trivial change beyond fixing typos, make sure to sign ICLA (individual contributor license agreement). Contact us if you need CCLA (corporate contributor license agreement).

Coding conventions

Clay follows Kotlin coding conventions. Class members are declared in the following order.

  • Properties (var, val)
  • Initialization block (init)
  • Secondary constructors (constructor)
  • Functions (fun)
  • Extensions of properties (val T.x or var T.x)
  • Extensions of functions (fun T.foo())
  • Nested or inner classes, enums, interfaces, and objects
  • Companion objects (companion object)

Here is an example.

class Klass(val parameter: Value) {

    // Read-only properties
    val publicValue: Value = Value()
    private val value: Value = Value()

    // Read-write properties
    var publicVariable: Value = Value()
    private var variable: Value = Value()

    // Initialization block
    init {
        // ...
    }

    // Other constructors
    constructor(firstValue: Int, secondValue: Int) : this(Value())

    // Functions
    fun publicFunction() = {}

    private fun privateFunction() = {}

    // Extensions of read-only properties
    val <T> T.publicReadonly: Value get() = Value()
    private val <T> T.readonly: Value get() = Value()

    // Extensions of read-write properties
    var <T> T.publicReadWrite: Value
        get()
        set()
    private var <T> T.readWrite: Value
        get()
        set()

    // Extensions of functions
    fun <T> T.publicFunction() {}

    private fun <T>.privateFunction() {}
    // Nested or inner classes, enums, interfaces, and objects
    enum class EnumType private constructor(val enumField: Int) {
        DEFAULT(1),
        A_ENUM_TYPE(2),
    }

    private data class NestedDataClass(val int: Int)

    // Constants
    companion object {
        const val PRIMITIVE_CONSTANT = 0

        @JvmField
        val NON_PRIMITIVE_CONSTANT: OtherClass = OtherClass()
    }
}

When you add comments to public properties and methods, make sure to follow the Javadoc standard format.