Skip to content

Commit b551690

Browse files
srawlinsCommit Queue
authored andcommitted
Reapply "analyzer: separate unused_element_parameter from unused_element"
Fixes #49025. Fixes #48401 This allows users to blanket ignore unused_element_parameter without ignoring unused_element. They are reported in distinct situations so it is valid to separate them. This reverts commit b888da7. Change-Id: I8ea52fcdcb491c140c1283602d6911c939e78d50 Tested: trybots Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381882 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
1 parent f6fd63d commit b551690

File tree

5 files changed

+40
-19
lines changed

5 files changed

+40
-19
lines changed

pkg/analysis_server/test/src/services/correction/assist/convert_class_to_enum_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ base class E {
348348
class _E {
349349
static const _E c = _E();
350350
351-
// ignore: unused_element, recursive_constant_constructor
351+
// ignore: unused_element_parameter, recursive_constant_constructor
352352
const _E({_E e = const _E()});
353353
}
354354
''');

pkg/analyzer/lib/src/error/codes.g.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7612,11 +7612,9 @@ class WarningCode extends AnalyzerErrorCode {
76127612
/// Parameters:
76137613
/// 0: the name of the parameter that is declared but not used
76147614
static const WarningCode UNUSED_ELEMENT_PARAMETER = WarningCode(
7615-
'UNUSED_ELEMENT',
7615+
'UNUSED_ELEMENT_PARAMETER',
76167616
"A value for optional parameter '{0}' isn't ever given.",
76177617
correctionMessage: "Try removing the unused parameter.",
7618-
hasPublishedDocs: true,
7619-
uniqueName: 'UNUSED_ELEMENT_PARAMETER',
76207618
);
76217619

76227620
/// Parameters:

pkg/analyzer/messages.yaml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27316,8 +27316,6 @@ WarningCode:
2731627316
kinds of declarations are analyzed:
2731727317
- Private top-level declarations and all of their members
2731827318
- Private members of public declarations
27319-
- Optional parameters of private functions for which a value is never
27320-
passed
2732127319

2732227320
Not all references to an element will mark it as "used":
2732327321
- Assigning a value to a top-level variable (with a standard `=`
@@ -27337,6 +27335,26 @@ WarningCode:
2733727335
class [!_C!] {}
2733827336
```
2733927337

27338+
#### Common fixes
27339+
27340+
If the declaration isn't needed, then remove it.
27341+
27342+
If the declaration is intended to be used, then add the code to use it.
27343+
UNUSED_ELEMENT_PARAMETER:
27344+
problemMessage: "A value for optional parameter '{0}' isn't ever given."
27345+
correctionMessage: Try removing the unused parameter.
27346+
hasPublishedDocs: false
27347+
comment: |-
27348+
Parameters:
27349+
0: the name of the parameter that is declared but not used
27350+
documentation: |-
27351+
#### Description
27352+
27353+
The analyzer produces this diagnostic when a value is never passed for an
27354+
optional parameter declared within a private declaration.
27355+
27356+
#### Example
27357+
2734027358
Assuming that no code in the library passes a value for `y` in any
2734127359
invocation of `_m`, the following code produces this diagnostic:
2734227360

@@ -27361,14 +27379,6 @@ WarningCode:
2736127379
```
2736227380

2736327381
If the declaration is intended to be used, then add the code to use it.
27364-
UNUSED_ELEMENT_PARAMETER:
27365-
sharedName: UNUSED_ELEMENT
27366-
problemMessage: "A value for optional parameter '{0}' isn't ever given."
27367-
correctionMessage: Try removing the unused parameter.
27368-
hasPublishedDocs: true
27369-
comment: |-
27370-
Parameters:
27371-
0: the name of the parameter that is declared but not used
2737227382
UNUSED_FIELD:
2737327383
problemMessage: "The value of the field '{0}' isn't used."
2737427384
correctionMessage: Try removing the field, or using it.

pkg/analyzer/tool/diagnostics/diagnostics.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23187,8 +23187,6 @@ void f() {
2318723187

2318823188
### unused_element
2318923189

23190-
_A value for optional parameter '{0}' isn't ever given._
23191-
2319223190
_The declaration '{0}' isn't referenced._
2319323191

2319423192
#### Description
@@ -23198,8 +23196,6 @@ referenced in the library that contains the declaration. The following
2319823196
kinds of declarations are analyzed:
2319923197
- Private top-level declarations and all of their members
2320023198
- Private members of public declarations
23201-
- Optional parameters of private functions for which a value is never
23202-
passed
2320323199

2320423200
Not all references to an element will mark it as "used":
2320523201
- Assigning a value to a top-level variable (with a standard `=`
@@ -23219,6 +23215,23 @@ produces this diagnostic:
2321923215
class [!_C!] {}
2322023216
```
2322123217

23218+
#### Common fixes
23219+
23220+
If the declaration isn't needed, then remove it.
23221+
23222+
If the declaration is intended to be used, then add the code to use it.
23223+
23224+
### unused_element_parameter
23225+
23226+
_A value for optional parameter '{0}' isn't ever given._
23227+
23228+
#### Description
23229+
23230+
The analyzer produces this diagnostic when a value is never passed for an
23231+
optional parameter declared within a private declaration.
23232+
23233+
#### Example
23234+
2322223235
Assuming that no code in the library passes a value for `y` in any
2322323236
invocation of `_m`, the following code produces this diagnostic:
2322423237

runtime/observatory/lib/src/elements/debugger.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2942,7 +2942,7 @@ class DebuggerConsoleElement extends CustomElement implements Renderable {
29422942
DebuggerConsoleElement.created() : super.created('debugger-console');
29432943

29442944
/// Is [container] scrolled to the within [threshold] pixels of the bottom?
2945-
// ignore: unused_element
2945+
// ignore: unused_element_parameter
29462946
static bool _isScrolledToBottom(DivElement? container, [int threshold = 2]) {
29472947
if (container == null) {
29482948
return false;

0 commit comments

Comments
 (0)