dart-code-checker / dart-code-metrics

Software analytics tool that helps developers analyse and improve software quality.
https://dcm.dev
Other
860 stars 266 forks source link

[Rule change] prefer-moving-to-variable: skip copyWith methods #1200

Closed vicleonov closed 1 year ago

vicleonov commented 1 year ago

What rule do you want to change?

prefer-moving-to-variable

What change to do you want to make?

Implement suggestions

How do you think the change should be implemented?

A new default behavior

Example code

if (A) {
  emit(state.copyWith(counter: 1));
} else if (B) {
  emit(state.copyWith(counter: 2));
} else {
  emit(state.copyWith(counter: 3));
}

What does the rule currently do for this code?

Rule suggests moving state.copyWith to separate variable which looks strange. It requires using //ignore: prefer-moving-to-variable to avoid this situation.

What will the rule do after it's changed?

Rule should not count variables with copyWith method.

Participation

Additional comments

No response

incendial commented 1 year ago

@vicleonov is it a complete example? Coz based on the different counter value the rule should not even trigger.

github-actions[bot] commented 1 year ago

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this issue for now. Please don't hesitate to comment on the issue if you have any more information for us; we will reopen it right away! Thanks for your contribution!