From 2b8c0ee20a44d46973e72c8b46b7a5cd86d11bb5 Mon Sep 17 00:00:00 2001 From: Parker Lougheed Date: Tue, 1 Apr 2025 10:51:19 -0700 Subject: [PATCH] [analyzer] Mark latest diagnostic docs as published Change-Id: I288dcf8c997819bc2e48bf7b4479c37dcba35485 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419681 Reviewed-by: Phil Quitslund Reviewed-by: Brian Wilkerson Auto-Submit: Parker Lougheed Commit-Queue: Brian Wilkerson --- pkg/analyzer/lib/src/error/codes.g.dart | 1 + pkg/analyzer/messages.yaml | 21 ++++++++------- pkg/linter/lib/src/lint_codes.g.dart | 17 +++++++++++++ pkg/linter/messages.yaml | 34 ++++++++++++------------- pkg/linter/tool/machine/rules.json | 2 +- 5 files changed, 48 insertions(+), 27 deletions(-) diff --git a/pkg/analyzer/lib/src/error/codes.g.dart b/pkg/analyzer/lib/src/error/codes.g.dart index 51136bd18f7..2ea51eb2bcc 100644 --- a/pkg/analyzer/lib/src/error/codes.g.dart +++ b/pkg/analyzer/lib/src/error/codes.g.dart @@ -7049,6 +7049,7 @@ class WarningCode extends ErrorCode { "Using multiple 'hide' or 'show' combinators is never necessary and often " "produces surprising results.", correctionMessage: "Try using a single combinator.", + hasPublishedDocs: true, ); /// Generates a warning for classes that inherit from classes annotated with diff --git a/pkg/analyzer/messages.yaml b/pkg/analyzer/messages.yaml index 823165ca487..3d982f42211 100644 --- a/pkg/analyzer/messages.yaml +++ b/pkg/analyzer/messages.yaml @@ -27707,7 +27707,7 @@ WarningCode: MULTIPLE_COMBINATORS: problemMessage: "Using multiple 'hide' or 'show' combinators is never necessary and often produces surprising results." correctionMessage: "Try using a single combinator." - hasPublishedDocs: false + hasPublishedDocs: true comment: No parameters. documentation: |- #### Description @@ -27726,8 +27726,8 @@ WarningCode: var x = Future.value(1); ``` - The following code produces this diagnostic because the second `hide` combinator - is redundant: + The following code produces this diagnostic because + the second `hide` combinator is redundant: ```dart import 'dart:math' [!hide Random, max, min hide min!]; @@ -27735,8 +27735,8 @@ WarningCode: var x = pi; ``` - The following codes produce this diagnostic because the `hide` combinator - is redundant: + The following codes produce this diagnostic because + the `hide` combinator is redundant: ```dart import 'dart:math' [!show Random, max hide min!]; @@ -27745,8 +27745,9 @@ WarningCode: var r = Random(); ``` - The following code produces this diagnostic because the `show` combinator - already hides `Random` and `max`, so the `hide` combinator is redundant: + The following code produces this diagnostic because + the `show` combinator already hides `Random` and `max`, + so the `hide` combinator is redundant: ```dart import 'dart:math' [!hide Random, max show min!]; @@ -27756,7 +27757,8 @@ WarningCode: #### Common fixes - If you prefer to list the names that should be visible, then use a single `show` combinator: + If you prefer to list the names that should be visible, + then use a single `show` combinator: ```dart import 'dart:math' show min; @@ -27764,7 +27766,8 @@ WarningCode: var x = min(0, 1); ``` - If you prefer to list the names that should be hidden, then use a single `hide` combinator: + If you prefer to list the names that should be hidden, + then use a single `hide` combinator: ```dart import 'dart:math' hide Random, max, min; diff --git a/pkg/linter/lib/src/lint_codes.g.dart b/pkg/linter/lib/src/lint_codes.g.dart index 3ac09f36a8e..9a5799c98e6 100644 --- a/pkg/linter/lib/src/lint_codes.g.dart +++ b/pkg/linter/lib/src/lint_codes.g.dart @@ -159,6 +159,7 @@ class LinterLintCode extends LintCode { LintNames.avoid_dynamic_calls, "Method invocation or property access on a 'dynamic' target.", correctionMessage: "Try giving the target a type.", + hasPublishedDocs: true, ); static const LintCode avoid_empty_else = LinterLintCode( @@ -568,6 +569,7 @@ class LinterLintCode extends LintCode { "The public property isn't described by either 'debugFillProperties' or " "'debugDescribeChildren'.", correctionMessage: "Try describing the property.", + hasPublishedDocs: true, ); static const LintCode directives_ordering_alphabetical = LinterLintCode( @@ -872,6 +874,7 @@ class LinterLintCode extends LintCode { LintNames.missing_whitespace_between_adjacent_strings, "Missing whitespace between adjacent strings.", correctionMessage: "Try adding whitespace between the strings.", + hasPublishedDocs: true, ); static const LintCode no_adjacent_strings_in_list = LinterLintCode( @@ -1006,6 +1009,7 @@ class LinterLintCode extends LintCode { "Don't throw instances of classes that don't extend either 'Exception' or " "'Error'.", correctionMessage: "Try throwing a different class of object.", + hasPublishedDocs: true, ); static const LintCode overridden_fields = LinterLintCode( @@ -1051,12 +1055,14 @@ class LinterLintCode extends LintCode { LintNames.prefer_asserts_in_initializer_lists, "Assert should be in the initializer list.", correctionMessage: "Try moving the assert to the initializer list.", + hasPublishedDocs: true, ); static const LintCode prefer_asserts_with_message = LinterLintCode( LintNames.prefer_asserts_with_message, "Missing a message in an assert.", correctionMessage: "Try adding a message to the assert.", + hasPublishedDocs: true, ); static const LintCode prefer_collection_literals = LinterLintCode( @@ -1111,6 +1117,7 @@ class LinterLintCode extends LintCode { LintNames.prefer_constructors_over_static_methods, "Static method should be a constructor.", correctionMessage: "Try converting the method into a constructor.", + hasPublishedDocs: true, ); static const LintCode prefer_contains_always_false = LinterLintCode( @@ -1145,6 +1152,7 @@ class LinterLintCode extends LintCode { LintNames.prefer_expression_function_bodies, "Unnecessary use of a block function body.", correctionMessage: "Try using an expression function body.", + hasPublishedDocs: true, ); static const LintCode prefer_final_fields = LinterLintCode( @@ -1158,6 +1166,7 @@ class LinterLintCode extends LintCode { LintNames.prefer_final_in_for_each, "The pattern should be final.", correctionMessage: "Try making the pattern final.", + hasPublishedDocs: true, uniqueName: 'prefer_final_in_for_each_pattern', ); @@ -1172,12 +1181,14 @@ class LinterLintCode extends LintCode { LintNames.prefer_final_locals, "Local variables should be final.", correctionMessage: "Try making the variable final.", + hasPublishedDocs: true, ); static const LintCode prefer_final_parameters = LinterLintCode( LintNames.prefer_final_parameters, "The parameter '{0}' should be final.", correctionMessage: "Try making the parameter final.", + hasPublishedDocs: true, ); static const LintCode prefer_for_elements_to_map_fromIterable = @@ -1194,6 +1205,7 @@ class LinterLintCode extends LintCode { "Use 'forEach' rather than a 'for' loop to apply a function to every " "element.", correctionMessage: "Try using 'forEach' rather than a 'for' loop.", + hasPublishedDocs: true, ); static const LintCode @@ -1402,6 +1414,7 @@ class LinterLintCode extends LintCode { LintNames.public_member_api_docs, "Missing documentation for a public member.", correctionMessage: "Try adding documentation for the member.", + hasPublishedDocs: true, ); static const LintCode recursive_getters = LinterLintCode( @@ -1535,12 +1548,14 @@ class LinterLintCode extends LintCode { "Use a type annotation rather than 'assert' to enforce non-nullability.", correctionMessage: "Try adding a type annotation and removing the 'assert'.", + hasPublishedDocs: true, ); static const LintCode type_annotate_public_apis = LinterLintCode( LintNames.type_annotate_public_apis, "Missing type annotation on a public API.", correctionMessage: "Try adding a type annotation.", + hasPublishedDocs: true, ); static const LintCode type_init_formals = LinterLintCode( @@ -1716,12 +1731,14 @@ class LinterLintCode extends LintCode { "Unnecessary use of a null-aware operator to invoke an extension method on " "a nullable type.", correctionMessage: "Try removing the '?'.", + hasPublishedDocs: true, ); static const LintCode unnecessary_null_checks = LinterLintCode( LintNames.unnecessary_null_checks, "Unnecessary use of a null check ('!').", correctionMessage: "Try removing the null check.", + hasPublishedDocs: true, ); static const LintCode unnecessary_null_in_if_null_operators = LinterLintCode( diff --git a/pkg/linter/messages.yaml b/pkg/linter/messages.yaml index 6b3c3c5f51d..362e7b7cdfe 100644 --- a/pkg/linter/messages.yaml +++ b/pkg/linter/messages.yaml @@ -765,7 +765,7 @@ LintCode: experimental: "2.12" stable: "2.14" categories: [binarySize, errorProne] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -3870,7 +3870,7 @@ LintCode: state: stable: "2.3" categories: [errorProne, flutter] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -6199,7 +6199,7 @@ LintCode: state: stable: "2.8" categories: [errorProne] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -7365,7 +7365,7 @@ LintCode: state: stable: "2.0" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -7830,7 +7830,7 @@ LintCode: state: stable: "2.0" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -7884,7 +7884,7 @@ LintCode: state: stable: "2.3" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -8444,7 +8444,7 @@ LintCode: state: stable: "2.0" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -8661,7 +8661,7 @@ LintCode: state: stable: "2.0" categories: [brevity, style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -8840,7 +8840,7 @@ LintCode: state: stable: "2.1" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -8912,7 +8912,7 @@ LintCode: state: stable: "2.0" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -8980,7 +8980,7 @@ LintCode: state: stable: "2.14" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -9137,7 +9137,7 @@ LintCode: experimental: "2.0" stable: "2.2" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -10335,7 +10335,7 @@ LintCode: state: stable: "2.0" categories: [publicInterface, style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -11521,7 +11521,7 @@ LintCode: state: stable: "2.12" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -11591,7 +11591,7 @@ LintCode: state: stable: "2.0" categories: [effectiveDart, publicInterface] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -12867,7 +12867,7 @@ LintCode: state: stable: "2.18" categories: [style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description @@ -12926,7 +12926,7 @@ LintCode: state: experimental: "2.12" categories: [brevity, style] - hasPublishedDocs: false + hasPublishedDocs: true documentation: |- #### Description diff --git a/pkg/linter/tool/machine/rules.json b/pkg/linter/tool/machine/rules.json index b3497d95dcb..9a3becc64eb 100644 --- a/pkg/linter/tool/machine/rules.json +++ b/pkg/linter/tool/machine/rules.json @@ -953,7 +953,7 @@ }, { "name": "discarded_futures", - "description": "Don't invoke asynchronous functions in non-`async` blocks.", + "description": "There should be no `Future`-returning calls in synchronous functions unless they are assigned or returned.", "categories": [ "errorProne" ],