Files
openide/plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/LocalVariableName.html
Ilya Kirillov 3386f8f5a9 [kotlin] move inspection descriptions to separate module to reuse in K2
GitOrigin-RevId: e9d7382f4d640e27b1958d1bf2d4c3e639915137
2022-07-13 09:59:31 +00:00

28 lines
1.1 KiB
HTML

<html>
<body>
Reports local variables that do not follow the naming conventions.
<p>You can specify the required pattern in the inspection options.</p>
<p><a href="https://kotlinlang.org/docs/coding-conventions.html#function-names">Recommended naming conventions</a>: it has to start with a lowercase letter, use camel case and no underscores.</p>
<p><b>Example:</b></p>
<pre><code>
fun fibonacciNumber(index: Int): Long = when(index) {
0 -> 0
else -> {
// does not follow naming conventions: contains underscore symbol (`_`)
var number_one: Long = 0
// does not follow naming conventions: starts with an uppercase letter
var NUMBER_TWO: Long = 1
// follow naming conventions: starts with a lowercase letter, use camel case and no underscores.
var numberThree: Long = number_one + NUMBER_TWO
for(currentIndex in 2..index) {
numberThree = number_one + NUMBER_TWO
number_one = NUMBER_TWO
NUMBER_TWO = numberThree
}
numberThree
}
}
</code></pre>
</body>
</html>