Auto generate TAG in Intellij Idea and Android Studio

27 Views Asked by At

I have modified my Android Studio live templates to write the log directly from class name as following, but I am getting this warning message. How can I avoid it. Also, if I add constto the decleration I get another error:

Const 'val' initializer should be a constant value

Is there anyway that I can use SomeName::class.java.simpleName without getting any warning or error? I prefer this that writing hard-coded class name as a string.

enter image description here

1

There are 1 best solutions below

0
Mai3 On

The warning is not related to live-template or SomeName::class.java.simpleName, it is because of how 'TAG' variable is defined.

Mutable variables should be defined in camelCase, according to https://kotlinlang.org/docs/coding-conventions.html#property-names

Names of top-level or object properties which hold objects with behavior or mutable data should use camel case names