charlescyt / pyramid_lint

Linting tool for Dart and Flutter projects.

Home Page:https://pub.dev/packages/pyramid_lint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prefer_declaring_const_constructors lint showing for the constructors with a super initializer that is not a const

imsamgarg opened this issue · comments

Is there an existing issue for this bug?

Bug Description

prefer_declaring_const_constructors lint showing for the constructors with a super initializer that is not a const.

Screenshot 2024-01-12 211746

Steps to Reproduce

Just create any constructor in any class that has a super initializer that is not const.

Additional Information

No response

That's because the constructor of Temp is not a const constructor.

There are a few edge cases that I didn't consider when I implemented the lint. I will spend some time improving it.
Thanks for raising the issue!

The lint should not be triggered when the redirecting/super constructor is not a const constructor.

class Point {
  final double x;
  final double y;

  Point(this.x, this.y);

  Point.origin() : this(0, 0); // Redirecting constructor is not const
}

class Point3D extends Point {
  final double z;

  Point3D(double x, double y, this.z) : super(x, y); // Super constructor is not const

  // Point3D(super.x, super.y, this.z); // Need to handle super parameters as well

  Point3D.origin() // Super constructor is not const
      : z = 0,
        super.origin();
}

Fixed false positive when redirecting/super constructor is not a const constructor in #29.
Still need to come up with a way to check for super parameters.

Now i'm getting error on const constructors too
image

It's also showing all over the place
image

Hello!
Is NativeFileType.fromPath a factory constructor?
Could you provide a minimum reproducible example for me to work on?

For some reason, it's not showing anymore even though I didn't change anything.