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

Linter rules such as enable_null_safety don't show diagnostic anymore #59869

Open
FMorschel opened this issue Jan 8, 2025 · 5 comments
Open
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@FMorschel
Copy link
Contributor

My pubspec.yaml:

environment:
  sdk: ^3.6.0

I'm creating a new flutter project with the latest stable.

I saw the following doesn't have any warnings:

linter:
  rules:
    - enable_null_safety

I'd expect this to give a warning as is not needed. This is on the lint docs:

NOTE: This rule is removed in Dart 3.0.0; it is no longer functional.

Some other rules such as always_require_non_null_named_parameters are also not showing any diagnostics.

Tested by changing my pubspec.yaml to:

environment:
  sdk: ^3.3.0

And the diagnostic for always_require_non_null_named_parameters did show up. So I guess something is not working as intended.

@FMorschel FMorschel added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Jan 8, 2025
@FMorschel
Copy link
Contributor Author

FMorschel commented Jan 8, 2025

I also feel like these rules could show up as deprecated on auto-complete in these cases or something similar.

WDYT @bwilkerson and @DanTup? I'm unsure if that is possible, to show deprecation only when dependencies are above a certain version.

@DanTup
Copy link
Collaborator

DanTup commented Jan 9, 2025

It looks like there is some existing code that handles removed lints:

} else if (state is RemovedState) {
var since = state.since.toString();
var replacedBy = state.replacedBy;
if (replacedBy != null) {
reporter.reportErrorForSpan(AnalysisOptionsWarningCode.REPLACED_LINT,
node.span, [value, since, replacedBy]);
} else {
reporter.reportErrorForSpan(AnalysisOptionsWarningCode.REMOVED_LINT,
node.span, [value, since]);
}
}

And that lint is marked removed since 3.0:

state: State.removed(since: dart3),

So perhaps there is a bug/regression here somewhere (I'm assuming by the word "anymore" in the title, that this worked in the past but doesn't now?).

@bwilkerson
Copy link
Member

Yes, there should be a diagnostic displayed in the analysis_options.yaml file if there is a removed lint being enabled. The fact that it isn't there is a regression and a bug.

As for code completion, the intention was to not display removed lints at all (rather than marking them as deprecated). If removed lints are being suggested in code completion then that's also a bug (and might have a different cause).

@FMorschel
Copy link
Contributor Author

I'm assuming by the word "anymore" in the title, that this worked in the past but doesn't now?

That's what I assumed. I'm not 100% sure. I've not tested with other versions of the SDK yet but that is what I would expect.

As for code completion, the intention was to not display removed lints at all (rather than marking them as deprecated). If removed lints are being suggested in code completion then that's also a bug (and might have a different cause).

I'll open a second issue about it then. Thanks.

@FMorschel
Copy link
Contributor Author

FMorschel commented Jan 9, 2025

I've just tested both with the latest master. The auto-completion (for removed lints) is not happening on master (so I won't open an issue on it) but there is no diagnostic on the lints when adding them manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

3 participants