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 should spot misnamed constructors #19952

Closed
DartBot opened this issue Jul 10, 2014 · 4 comments
Closed

Analyzer should spot misnamed constructors #19952

DartBot opened this issue Jul 10, 2014 · 4 comments
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jul 10, 2014

This issue was originally filed by olivier.chafik@gmail.com


When doing manual refactorings of class name, I often forget to rename the constructor, which yields hard-to-detect bugs:

import 'package:di/di.dart';
class ModuleWithNewName extends Module {
  ModuleWithOldName() {
    bind(MyClass); // No, you will never be bound.
  }
}

I think the analyzer should issue an info (if not a warning) when a capitalized method has no return type, to prevent these cases.

@bwilkerson
Copy link
Member

Added this to the Later milestone.
Removed Priority-Unassigned label.
Added Priority-Medium, Area-Analyzer, Analyzer-Hint, Triaged labels.

@bwilkerson
Copy link
Member

Removed this from the Later milestone.

@DartBot
Copy link
Author

DartBot commented Jul 10, 2014

This comment was originally written by @zoechi


This caused lot of troubles for me too.
I didn't file a feature request yet because I thought there is now way to recognize a constructor when the name deviates from the class name.

I find the uppercase is a quite good option to identify (misnamed) constructors

(don't forget private classes)

class _MyClass {
  _MyOldName() {}
}

@DartBot DartBot added Type-Enhancement area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-warning Issues with the analyzer's Warning codes labels Jul 10, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@natebosch
Copy link
Member

I find the uppercase is a quite good option to identify (misnamed) constructors

+1 I think the lint non_constant_identifier_names is enough to solve this problem as long as you are following Dart conventions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-warning Issues with the analyzer's Warning codes area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants