Private property name does not match regular expression

The following code returns this warning in a Kotlin project using Android studio 3.0 on a Mac.

private val REQUEST_CODE = 11 private val TAG = "RecentCallsActivity" 

The private property name 'REQUEST_CODE' does not match the regular expression ' _?[az][A-Za-z\d]* ' less ... (⌘F1) Reports private property names that do not conform to the recommended naming conventions.

What is the recommended naming convention?

I found a similar question that answers how to disable the same.

enter image description here

Update: In some examples, I saw this use, which removes the warning.

 class KotlinExampleActivity : Activity() { companion object { val TAG: String = KotlinExampleActivity::class.java.simpleName } 
+8
android android-studio kotlin
source share
2 answers

this is a warning and you can ignore it. It bothers you, declare them as private const

 private const val REQUEST_CODE = 11 private const val TAG = "RecentCallsActivity" class RecentCallsActivity : AppCompatActivity() { 
+13
source share

Kotlin uses Java coding conventions by default. Therefore, for Variables, the use of lowerCamelCase is suggested. For constant variables, it is proposed to use the full number of names. More details here https://kotlinlang.org/docs/reference/coding-conventions.html http://www.oracle.com/technetwork/java/codeconventions-135099.html

+3
source share

All Articles