Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Analyzer] Lint avoid_classes_with_only_static_members is not working as intended #58439

Closed
Giuspepe opened this issue Jun 22, 2021 · 0 comments · Fixed by dart-lang/linter#2754
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-negative

Comments

@Giuspepe
Copy link

The lint avoid_classes_with_only_static_members does not work if a class has only static methods.
If I run flutter analyze on a file with the example from https://dart-lang.github.io/linter/lints/avoid_classes_with_only_static_members.html, the lint avoid_classes_with_only_static_members is not triggered:

class DateUtils {
  static DateTime mostRecent(List<DateTime> dates) {
    return dates.reduce((a, b) => a.isAfter(b) ? a : b);
  }
}

However, if I add a static property to the class, the lint triggers as intended.

class DateUtils {
  static int i = 123;
  static DateTime mostRecent(List<DateTime> dates) {
    return dates.reduce((a, b) => a.isAfter(b) ? a : b);
  }
}

I'm on MacOS and my Dart version is 2.13.1 (stable).

@bwilkerson bwilkerson transferred this issue from dart-lang/sdk Jun 22, 2021
@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-negative
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants