Skip to content

Commit b888da7

Browse files
mkustermannCommit Queue
authored and
Commit Queue
committed
Revert "analyzer: separate unused_element_parameter from unused_element"
This reverts commit c1976b0. Reason for revert: It seems this change caused failures on Flutter HHH bot. Example log can be found at [0]: ``` | lib/src/super_reader/super_reader.dart:615:14: Error: Final field 'showDebugLeaderBounds' is not initialized. | Try to initialize the field in the declaration or in every constructor. | final bool showDebugLeaderBounds; | ^^^^^^^^^^^^^^^^^^^^^ ``` Looking at the sources it seems that may be related to the `// ignore: unused_element` analyzer directive: ``` 602 /// A [SuperReaderDocumentLayerBuilder] that builds a [SelectionLeadersDocumentLayer], which positions 603 /// leader widgets at the base and extent of the user's selection, so that other widgets 604 /// can position themselves relative to the user's selection. 605 class _SelectionLeadersDocumentLayerBuilder implements SuperReaderDocumentLayerBuilder { 606 const _SelectionLeadersDocumentLayerBuilder({ 607 required this.links, 608 // ignore: unused_element 609 this.showDebugLeaderBounds = false, 610 }); 611 612 /// Collections of [LayerLink]s, which are given to leader widgets that are 613 /// positioned at the selection bounds, and around the full selection. 614 final SelectionLayerLinks links; 615 616 /// Whether to paint colorful bounds around the leader widgets, for debugging purposes. 617 final bool showDebugLeaderBounds; ``` So tentatively reverting this CL. [0] https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8739650477551803313/+/u/Run_customer_testing_tests/stdout Original change's description: > analyzer: separate unused_element_parameter from unused_element > > Fixes #49025 > > 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. > > Tested: Presubmit CI > Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try > Change-Id: I4844a6a0e0a67cd5e37ed8735b1526e174deb950 > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378500 > Reviewed-by: Brian Wilkerson <[email protected]> > Reviewed-by: Phil Quitslund <[email protected]> > Commit-Queue: Samuel Rawlins <[email protected]> > Reviewed-by: Ryan Macnak <[email protected]> Change-Id: Ibbba75fe56601c7c4b5535c9142cf94c2dd80b91 Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380460 Commit-Queue: Martin Kustermann <[email protected]> Bot-Commit: Rubber Stamper <[email protected]> Reviewed-by: Slava Egorov <[email protected]>
1 parent 3d083d2 commit b888da7

File tree

5 files changed

+19
-40
lines changed

5 files changed

+19
-40
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_parameter, recursive_constant_constructor
351+
// ignore: unused_element, recursive_constant_constructor
352352
const _E({_E e = const _E()});
353353
}
354354
''');

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7585,9 +7585,11 @@ class WarningCode extends AnalyzerErrorCode {
75857585
/// Parameters:
75867586
/// 0: the name of the parameter that is declared but not used
75877587
static const WarningCode UNUSED_ELEMENT_PARAMETER = WarningCode(
7588-
'UNUSED_ELEMENT_PARAMETER',
7588+
'UNUSED_ELEMENT',
75897589
"A value for optional parameter '{0}' isn't ever given.",
75907590
correctionMessage: "Try removing the unused parameter.",
7591+
hasPublishedDocs: true,
7592+
uniqueName: 'UNUSED_ELEMENT_PARAMETER',
75917593
);
75927594

75937595
/// Parameters:

pkg/analyzer/messages.yaml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27308,6 +27308,8 @@ WarningCode:
2730827308
kinds of declarations are analyzed:
2730927309
- Private top-level declarations and all of their members
2731027310
- Private members of public declarations
27311+
- Optional parameters of private functions for which a value is never
27312+
passed
2731127313

2731227314
Not all references to an element will mark it as "used":
2731327315
- Assigning a value to a top-level variable (with a standard `=`
@@ -27327,26 +27329,6 @@ WarningCode:
2732727329
class [!_C!] {}
2732827330
```
2732927331

27330-
#### Common fixes
27331-
27332-
If the declaration isn't needed, then remove it.
27333-
27334-
If the declaration is intended to be used, then add the code to use it.
27335-
UNUSED_ELEMENT_PARAMETER:
27336-
problemMessage: "A value for optional parameter '{0}' isn't ever given."
27337-
correctionMessage: Try removing the unused parameter.
27338-
hasPublishedDocs: false
27339-
comment: |-
27340-
Parameters:
27341-
0: the name of the parameter that is declared but not used
27342-
documentation: |-
27343-
#### Description
27344-
27345-
The analyzer produces this diagnostic when a value is never passed for an
27346-
optional parameter declared within a private declaration.
27347-
27348-
#### Example
27349-
2735027332
Assuming that no code in the library passes a value for `y` in any
2735127333
invocation of `_m`, the following code produces this diagnostic:
2735227334

@@ -27371,6 +27353,14 @@ WarningCode:
2737127353
```
2737227354

2737327355
If the declaration is intended to be used, then add the code to use it.
27356+
UNUSED_ELEMENT_PARAMETER:
27357+
sharedName: UNUSED_ELEMENT
27358+
problemMessage: "A value for optional parameter '{0}' isn't ever given."
27359+
correctionMessage: Try removing the unused parameter.
27360+
hasPublishedDocs: true
27361+
comment: |-
27362+
Parameters:
27363+
0: the name of the parameter that is declared but not used
2737427364
UNUSED_FIELD:
2737527365
problemMessage: "The value of the field '{0}' isn't used."
2737627366
correctionMessage: Try removing the field, or using it.

pkg/analyzer/tool/diagnostics/diagnostics.md

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

2318423184
### unused_element
2318523185

23186+
_A value for optional parameter '{0}' isn't ever given._
23187+
2318623188
_The declaration '{0}' isn't referenced._
2318723189

2318823190
#### Description
@@ -23192,6 +23194,8 @@ referenced in the library that contains the declaration. The following
2319223194
kinds of declarations are analyzed:
2319323195
- Private top-level declarations and all of their members
2319423196
- Private members of public declarations
23197+
- Optional parameters of private functions for which a value is never
23198+
passed
2319523199

2319623200
Not all references to an element will mark it as "used":
2319723201
- Assigning a value to a top-level variable (with a standard `=`
@@ -23211,23 +23215,6 @@ produces this diagnostic:
2321123215
class [!_C!] {}
2321223216
```
2321323217

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

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_parameter
2945+
// ignore: unused_element
29462946
static bool _isScrolledToBottom(DivElement? container, [int threshold = 2]) {
29472947
if (container == null) {
29482948
return false;

0 commit comments

Comments
 (0)