File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
lib/lints/no_magic_number Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,8 @@ class NoMagicNumberRule extends SolidLintRule<NoMagicNumberParameters> {
70
70
.where (_isNotInDateTime)
71
71
.where (_isNotInsideIndexExpression)
72
72
.where (_isNotInsideEnumConstantArguments)
73
- .where (_isNotDefaultValue);
73
+ .where (_isNotDefaultValue)
74
+ .where (_isNotConstructorInitializer);
74
75
75
76
for (final magicNumber in magicNumbers) {
76
77
reporter.reportErrorForNode (code, magicNumber);
@@ -127,4 +128,8 @@ class NoMagicNumberRule extends SolidLintRule<NoMagicNumberParameters> {
127
128
bool _isNotDefaultValue (Literal literal) {
128
129
return literal.thisOrAncestorOfType <DefaultFormalParameter >() == null ;
129
130
}
131
+
132
+ bool _isNotConstructorInitializer (Literal literal) {
133
+ return literal.thisOrAncestorOfType <ConstructorInitializer >() == null ;
134
+ }
130
135
}
Original file line number Diff line number Diff line change @@ -79,3 +79,10 @@ class DefaultValues {
79
79
void topLevelFunctionWithDefaultParam ({int value = 6 }) {
80
80
({int value = 7 }) {};
81
81
}
82
+
83
+ // Allowed for numbers in constructor initializer.
84
+ class ConstructorInitializer {
85
+ final int value;
86
+
87
+ ConstructorInitializer () : value = 10 ;
88
+ }
You can’t perform that action at this time.
0 commit comments