Name warning for constant property


#1

AndroidStudio gives me the following warning…

Private property name DEFAULT_CIPHER_TRANSFORMATION should not contain underscores in the middle or the end

…for the following code:

class Secretify {

private val DEFAULT_CIPHER_TRANSFORMATION = “RSA/ECB/PKCS1Padding”

But according to the Kotlin naming conventions it should be correct:

Property names
Names of constants (properties marked with const, or top-level or object val properties with no custom get function that hold deeply immutable data) should use uppercase underscore-separated names:

const val MAX_COUNT = 8
val USER_NAME_FIELD = “UserName”

https://kotlinlang.org/docs/reference/coding-conventions.html#naming-rules

Do I understand the naming conventions wrong?


#2

Might it be the missing const modifier?


#3

const is also not used in the example from the coding conventions.


#4

After all, you are actually defining a strong that is stored in every new instance of the class.
Have you tried using object companion object or the global scope?


#5

Both works without warning and I will use a companion object.
After reading the coding conventions again I found my problem. I misinterpreted the term “top-level”.