Skip to content

Commit

Permalink
Change diagnostic location for `constructor_parameters_and_fields_sho…
Browse files Browse the repository at this point in the history
…uld_have_the_same_order` (#328)
  • Loading branch information
karolinaoparczyk authored Aug 5, 2024
1 parent ee4b4a2 commit 3454072
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,7 @@ class ConstructorParametersAndFieldsShouldHaveTheSameOrder
final constructors = node.members.whereType<ConstructorDeclaration>();
for (final constructor in constructors) {
if (!_hasValidOrder(constructor, fields)) {
final firstParameter = constructor.parameters.parameters.first;
final lastParameter = constructor.parameters.parameters.last;

reporter.reportErrorForOffset(
_getLintCode(),
firstParameter.offset,
lastParameter.offset +
lastParameter.length -
firstParameter.offset,
);
reporter.reportErrorForNode(_getLintCode(), constructor);
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
class ClassWithInvalidUnnamedParametersOrder {
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
const ClassWithInvalidUnnamedParametersOrder(
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
this.third,
this.second,
this.first,
this.fourth,
this.fifth,
);

// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
const ClassWithInvalidUnnamedParametersOrder.anotherConstructor(
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
this.third,
this.second,
this.first,
Expand All @@ -25,8 +25,8 @@ class ClassWithInvalidUnnamedParametersOrder {
}

class ClassWithInvalidNamedParametersOrder {
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
const ClassWithInvalidNamedParametersOrder({
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
required this.third,
required this.first,
required this.fourth,
Expand Down Expand Up @@ -90,8 +90,8 @@ class ClassWithValidNamedParametersOrder {
}

class ClassWithInvalidNamedParametersOrderAndWithNonThisParameter {
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
const ClassWithInvalidNamedParametersOrderAndWithNonThisParameter({
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
required this.first,
required this.second,
required String otherParameter,
Expand Down Expand Up @@ -131,8 +131,8 @@ class ClassWithValidNamedParametersOrderAndWithNonThisParameter {
}

class ClassWithInvalidUnnamedParametersOrderAndWithNonThisParameter {
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
const ClassWithInvalidUnnamedParametersOrderAndWithNonThisParameter(
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
this.third,
this.second,
String otherParameter,
Expand Down Expand Up @@ -217,8 +217,8 @@ class ClassWithMixedParametersWithValidOrder extends _AbstractClassWithField {
}

class ClassWithMixedParametersWithInvalidOrder extends _AbstractClassWithField {
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
const ClassWithMixedParametersWithInvalidOrder(
// expect_lint: constructor_parameters_and_fields_should_have_the_same_order
super.a,
this.second,
this.first, {
Expand Down

0 comments on commit 3454072

Please sign in to comment.