prefer-correct-identifier-length
added in: 4.5.0
style
The rule checks the length of variable names in classes, functions, extensions, mixins, and also checks the value of enum.
The rule can be configured using fields max-identifier-length
and min-identifier-length
. By
default max-identifier-length = 300
and min-identifier-length = 3
. You can also add
exceptions exceptions
.
⚙️ Config example
dart_code_metrics:
...
rules:
...
- prefer-correct-identifier-length:
exceptions: [ 'a' ]
max-identifier-length: 30
min-identifier-length: 4
Example
❌ Bad:
var x = 0; // length equals 1
var multiplatformConfigurationPoint = 0; // length equals 31
✅ Good:
var property = 0; // length equals 8
var multiplatformConfiguration = 0; // length equals 26