Skip to content

Commit 81f4b71

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
Reland "Reapply "analyzer: separate unused_element_parameter from unused_element""
This reverts commit b3f31a0. Reason for revert: Customer tests are now disabled. Original change's description: > Revert "Reapply "analyzer: separate unused_element_parameter from unused_element"" > > This reverts commit b551690. > > Reason for revert: flutter customer tests failing: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8738601049545714785/+/u/run_test.dart_for_customer_testing_shard_and_subshard_None/stdout > > Original change's description: > > 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 <[email protected]> > > Commit-Queue: Samuel Rawlins <[email protected]> > > Reviewed-by: Brian Wilkerson <[email protected]> > > Change-Id: Ie0df2f4be45e5db2fa255dcf8c30ddf8408c155b > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382420 > Bot-Commit: Rubber Stamper <[email protected]> > Reviewed-by: Matan Lurey <[email protected]> > Commit-Queue: Samuel Rawlins <[email protected]> > Reviewed-by: Brian Wilkerson <[email protected]> > Reviewed-by: Ryan Macnak <[email protected]> Change-Id: Icbe69690e83daecc5a0649d2f632ffc33ba6394c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386722 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Matan Lurey <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Ben Konyi <[email protected]>
1 parent f359a43 commit 81f4b71

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
@@ -7632,11 +7632,9 @@ class WarningCode extends AnalyzerErrorCode {
76327632
/// Parameters:
76337633
/// 0: the name of the parameter that is declared but not used
76347634
static const WarningCode UNUSED_ELEMENT_PARAMETER = WarningCode(
7635-
'UNUSED_ELEMENT',
7635+
'UNUSED_ELEMENT_PARAMETER',
76367636
"A value for optional parameter '{0}' isn't ever given.",
76377637
correctionMessage: "Try removing the unused parameter.",
7638-
hasPublishedDocs: true,
7639-
uniqueName: 'UNUSED_ELEMENT_PARAMETER',
76407638
);
76417639

76427640
/// Parameters:

pkg/analyzer/messages.yaml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27382,8 +27382,6 @@ WarningCode:
2738227382
kinds of declarations are analyzed:
2738327383
- Private top-level declarations and all of their members
2738427384
- Private members of public declarations
27385-
- Optional parameters of private functions for which a value is never
27386-
passed
2738727385

2738827386
Not all references to an element will mark it as "used":
2738927387
- Assigning a value to a top-level variable (with a standard `=`
@@ -27403,6 +27401,26 @@ WarningCode:
2740327401
class [!_C!] {}
2740427402
```
2740527403

27404+
#### Common fixes
27405+
27406+
If the declaration isn't needed, then remove it.
27407+
27408+
If the declaration is intended to be used, then add the code to use it.
27409+
UNUSED_ELEMENT_PARAMETER:
27410+
problemMessage: "A value for optional parameter '{0}' isn't ever given."
27411+
correctionMessage: Try removing the unused parameter.
27412+
hasPublishedDocs: false
27413+
comment: |-
27414+
Parameters:
27415+
0: the name of the parameter that is declared but not used
27416+
documentation: |-
27417+
#### Description
27418+
27419+
The analyzer produces this diagnostic when a value is never passed for an
27420+
optional parameter declared within a private declaration.
27421+
27422+
#### Example
27423+
2740627424
Assuming that no code in the library passes a value for `y` in any
2740727425
invocation of `_m`, the following code produces this diagnostic:
2740827426

@@ -27427,14 +27445,6 @@ WarningCode:
2742727445
```
2742827446

2742927447
If the declaration is intended to be used, then add the code to use it.
27430-
UNUSED_ELEMENT_PARAMETER:
27431-
sharedName: UNUSED_ELEMENT
27432-
problemMessage: "A value for optional parameter '{0}' isn't ever given."
27433-
correctionMessage: Try removing the unused parameter.
27434-
hasPublishedDocs: true
27435-
comment: |-
27436-
Parameters:
27437-
0: the name of the parameter that is declared but not used
2743827448
UNUSED_FIELD:
2743927449
problemMessage: "The value of the field '{0}' isn't used."
2744027450
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
@@ -23249,8 +23249,6 @@ void f() {
2324923249

2325023250
### unused_element
2325123251

23252-
_A value for optional parameter '{0}' isn't ever given._
23253-
2325423252
_The declaration '{0}' isn't referenced._
2325523253

2325623254
#### Description
@@ -23260,8 +23258,6 @@ referenced in the library that contains the declaration. The following
2326023258
kinds of declarations are analyzed:
2326123259
- Private top-level declarations and all of their members
2326223260
- Private members of public declarations
23263-
- Optional parameters of private functions for which a value is never
23264-
passed
2326523261

2326623262
Not all references to an element will mark it as "used":
2326723263
- Assigning a value to a top-level variable (with a standard `=`
@@ -23281,6 +23277,23 @@ produces this diagnostic:
2328123277
class [!_C!] {}
2328223278
```
2328323279

23280+
#### Common fixes
23281+
23282+
If the declaration isn't needed, then remove it.
23283+
23284+
If the declaration is intended to be used, then add the code to use it.
23285+
23286+
### unused_element_parameter
23287+
23288+
_A value for optional parameter '{0}' isn't ever given._
23289+
23290+
#### Description
23291+
23292+
The analyzer produces this diagnostic when a value is never passed for an
23293+
optional parameter declared within a private declaration.
23294+
23295+
#### Example
23296+
2328423297
Assuming that no code in the library passes a value for `y` in any
2328523298
invocation of `_m`, the following code produces this diagnostic:
2328623299

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)