Skip to content

Commit e032779

Browse files
parloughCommit Queue
authored and
Commit Queue
committed
[linter] Deprecate package_api_docs lint
The lint hasn't been functional for a long time. Rather than try to fix it and start introducing a lot of warnings on packages that include it, let's deprecate it and prepare for removal. Keeping it around in its current state results in the analyzer not meeting the expectations of developers that include the rule, potentially even causing misconceptions that an element isn't public when it is. A replacement, with a new name, can be introduced in the future if there is the desire and time to implement it. Bug: https://github.com/dart-lang/linter/issues/5107 Change-Id: Ied113e4c98be2253cb938277cfd6ea1c96bcac4a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389585 Reviewed-by: Phil Quitslund <[email protected]> Auto-Submit: Parker Lougheed <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]>
1 parent 1e624b8 commit e032779

File tree

9 files changed

+17
-152
lines changed

9 files changed

+17
-152
lines changed

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,8 +2207,6 @@ LintCode.only_throw_errors:
22072207
status: noFix
22082208
LintCode.overridden_fields:
22092209
status: noFix
2210-
LintCode.package_api_docs:
2211-
status: noFix
22122210
LintCode.package_names:
22132211
status: noFix
22142212
notes: |-

pkg/linter/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# 3.6.0-wip
1+
# 3.7.0-wip
2+
3+
- deprecated lint: `package_api_docs`
4+
5+
# 3.6.0
26

37
- new lint: `use_truncating_division`
48
- new _(experimental)_ lint: `omit_obvious_local_variable_types`

pkg/linter/analyzer_use_new_elements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ lib/src/rules/null_closures.dart
9999
lib/src/rules/omit_obvious_local_variable_types.dart
100100
lib/src/rules/one_member_abstracts.dart
101101
lib/src/rules/only_throw_errors.dart
102-
lib/src/rules/package_api_docs.dart
103102
lib/src/rules/package_prefixed_library_names.dart
104103
lib/src/rules/prefer_adjacent_string_concatenation.dart
105104
lib/src/rules/prefer_asserts_with_message.dart
@@ -324,7 +323,6 @@ test/rules/omit_obvious_local_variable_types_test.dart
324323
test/rules/one_member_abstracts_test.dart
325324
test/rules/only_throw_errors_test.dart
326325
test/rules/overridden_fields_test.dart
327-
test/rules/package_api_docs_test.dart
328326
test/rules/package_names_test.dart
329327
test/rules/package_prefixed_library_names_test.dart
330328
test/rules/parameter_assignments_test.dart

pkg/linter/example/all.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ linter:
114114
- one_member_abstracts
115115
- only_throw_errors
116116
- overridden_fields
117-
- package_api_docs
118117
- package_names
119118
- package_prefixed_library_names
120119
- parameter_assignments

pkg/linter/lib/src/rules/package_api_docs.dart

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analyzer/dart/ast/ast.dart';
6-
import 'package:analyzer/dart/ast/visitor.dart';
5+
import 'package:pub_semver/pub_semver.dart';
76

87
import '../analyzer.dart';
98

@@ -14,76 +13,9 @@ class PackageApiDocs extends LintRule {
1413
: super(
1514
name: LintNames.package_api_docs,
1615
description: _desc,
16+
state: State.deprecated(since: Version(3, 7, 0)),
1717
);
1818

1919
@override
20-
LintCode get lintCode => LinterLintCode.package_api_docs;
21-
22-
@override
23-
void registerNodeProcessors(
24-
NodeLintRegistry registry, LinterContext context) {
25-
var visitor = _Visitor(this);
26-
registry.addConstructorDeclaration(this, visitor);
27-
registry.addFieldDeclaration(this, visitor);
28-
registry.addMethodDeclaration(this, visitor);
29-
registry.addClassDeclaration(this, visitor);
30-
registry.addEnumDeclaration(this, visitor);
31-
registry.addFunctionDeclaration(this, visitor);
32-
registry.addTopLevelVariableDeclaration(this, visitor);
33-
registry.addClassTypeAlias(this, visitor);
34-
registry.addFunctionTypeAlias(this, visitor);
35-
}
36-
}
37-
38-
class _Visitor extends GeneralizingAstVisitor<void> {
39-
final PackageApiDocs rule;
40-
41-
_Visitor(this.rule);
42-
43-
// ignore: prefer_expression_function_bodies
44-
void check(Declaration node) {
45-
// See: https://github.com/dart-lang/linter/issues/3395
46-
// (`DartProject` removal).
47-
return;
48-
49-
// // If no project info is set, bail early.
50-
// // https://github.com/dart-lang/linter/issues/154
51-
// var currentProject = rule.project;
52-
// if (currentProject == null) {
53-
// return;
54-
// }
55-
//
56-
// var declaredElement = node.declaredElement;
57-
// if (declaredElement != null && currentProject.isApi(declaredElement)) {
58-
// if (node.documentationComment == null) {
59-
// rule.reportLint(getNodeToAnnotate(node));
60-
// }
61-
// }
62-
}
63-
64-
/// classMember ::=
65-
/// [ConstructorDeclaration]
66-
/// | [FieldDeclaration]
67-
/// | [MethodDeclaration]
68-
@override
69-
void visitClassMember(ClassMember node) {
70-
check(node);
71-
}
72-
73-
/// compilationUnitMember ::=
74-
/// [ClassDeclaration]
75-
/// | [EnumDeclaration]
76-
/// | [FunctionDeclaration]
77-
/// | [TopLevelVariableDeclaration]
78-
/// | [ClassTypeAlias]
79-
/// | [FunctionTypeAlias]
80-
@override
81-
void visitCompilationUnitMember(CompilationUnitMember node) {
82-
check(node);
83-
}
84-
85-
@override
86-
void visitNode(AstNode node) {
87-
// Don't visit children
88-
}
20+
LintCode get lintCode => LinterLintCode.removed_lint;
8921
}

pkg/linter/messages.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7140,6 +7140,10 @@ LintCode:
71407140
categories: [effectiveDart, publicInterface]
71417141
hasPublishedDocs: false
71427142
deprecatedDetails: |-
7143+
**NOTE:** This lint is deprecated because it is has not
7144+
been fully functional since at least Dart 2.0.
7145+
Remove all inclusions of this lint from your analysis options.
7146+
71437147
**DO** provide doc comments for all public APIs.
71447148
71457149
As described in the [pub package layout doc](https://dart.dev/tools/pub/package-layout#implementation-files),

pkg/linter/test/rules/all.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ import 'omit_obvious_local_variable_types_test.dart'
165165
import 'one_member_abstracts_test.dart' as one_member_abstracts;
166166
import 'only_throw_errors_test.dart' as only_throw_errors;
167167
import 'overridden_fields_test.dart' as overridden_fields;
168-
import 'package_api_docs_test.dart' as package_api_docs;
169168
import 'package_names_test.dart' as package_names;
170169
import 'package_prefixed_library_names_test.dart'
171170
as package_prefixed_library_names;
@@ -434,7 +433,6 @@ void main() {
434433
one_member_abstracts.main();
435434
only_throw_errors.main();
436435
overridden_fields.main();
437-
package_api_docs.main();
438436
package_names.main();
439437
package_prefixed_library_names.main();
440438
parameter_assignments.main();

pkg/linter/test/rules/package_api_docs_test.dart

Lines changed: 0 additions & 68 deletions
This file was deleted.

pkg/linter/tool/machine/rules.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,11 @@
373373
"categories": [
374374
"style"
375375
],
376-
"state": "stable",
376+
"state": "removed",
377377
"incompatible": [],
378378
"sets": [],
379-
"fixStatus": "hasFix",
380-
"details": "**DON'T** check for `null` in custom `==` operators.\n\nAs `null` is a special value, no instance of any class (other than `Null`) can\nbe equivalent to it. Thus, it is redundant to check whether the other instance\nis `null`.\n\n**BAD:**\n```dart\nclass Person {\n final String? name;\n\n @override\n operator ==(Object? other) =>\n other != null && other is Person && name == other.name;\n}\n```\n\n**GOOD:**\n```dart\nclass Person {\n final String? name;\n\n @override\n operator ==(Object? other) => other is Person && name == other.name;\n}\n```",
379+
"fixStatus": "noFix",
380+
"details": "**DON'T** check for `null` in custom `==` operators.\n\nAs `null` is a special value, no instance of any class (other than `Null`) can\nbe equivalent to it. Thus, it is redundant to check whether the other instance\nis `null`.\n\n**BAD:**\n```dart\nclass Person {\n final String? name;\n\n @override\n operator ==(Object? other) =>\n other != null && other is Person && name == other.name;\n}\n```\n\n**GOOD:**\n```dart\nclass Person {\n final String? name;\n\n @override\n operator ==(Object? other) => other is Person && name == other.name;\n}\n```\n\nThis rule has been removed.",
381381
"sinceDartSdk": "2.0"
382382
},
383383
{
@@ -1613,11 +1613,11 @@
16131613
"effectiveDart",
16141614
"publicInterface"
16151615
],
1616-
"state": "stable",
1616+
"state": "deprecated",
16171617
"incompatible": [],
16181618
"sets": [],
16191619
"fixStatus": "noFix",
1620-
"details": "**DO** provide doc comments for all public APIs.\n\nAs described in the [pub package layout doc](https://dart.dev/tools/pub/package-layout#implementation-files),\npublic APIs consist in everything in your package's `lib` folder, minus\nimplementation files in `lib/src`, adding elements explicitly exported with an\n`export` directive.\n\nFor example, given `lib/foo.dart`:\n```dart\nexport 'src/bar.dart' show Bar;\nexport 'src/baz.dart';\n\nclass Foo { }\n\nclass _Foo { }\n```\nits API includes:\n\n* `Foo` (but not `_Foo`)\n* `Bar` (exported) and\n* all *public* elements in `src/baz.dart`\n\nAll public API members should be documented with `///` doc-style comments.\n\n**BAD:**\n```dart\nclass Bar {\n void bar();\n}\n```\n\n**GOOD:**\n```dart\n/// A Foo.\nabstract class Foo {\n /// Start foo-ing.\n void start() => _start();\n\n _start();\n}\n```\n\nAdvice for writing good doc comments can be found in the\n[Doc Writing Guidelines](https://dart.dev/effective-dart/documentation).",
1620+
"details": "**NOTE:** This lint is deprecated because it is has not\nbeen fully functional since at least Dart 2.0.\nRemove all inclusions of this lint from your analysis options.\n\n**DO** provide doc comments for all public APIs.\n\nAs described in the [pub package layout doc](https://dart.dev/tools/pub/package-layout#implementation-files),\npublic APIs consist in everything in your package's `lib` folder, minus\nimplementation files in `lib/src`, adding elements explicitly exported with an\n`export` directive.\n\nFor example, given `lib/foo.dart`:\n```dart\nexport 'src/bar.dart' show Bar;\nexport 'src/baz.dart';\n\nclass Foo { }\n\nclass _Foo { }\n```\nits API includes:\n\n* `Foo` (but not `_Foo`)\n* `Bar` (exported) and\n* all *public* elements in `src/baz.dart`\n\nAll public API members should be documented with `///` doc-style comments.\n\n**BAD:**\n```dart\nclass Bar {\n void bar();\n}\n```\n\n**GOOD:**\n```dart\n/// A Foo.\nabstract class Foo {\n /// Start foo-ing.\n void start() => _start();\n\n _start();\n}\n```\n\nAdvice for writing good doc comments can be found in the\n[Doc Writing Guidelines](https://dart.dev/effective-dart/documentation).",
16211621
"sinceDartSdk": "2.0"
16221622
},
16231623
{

0 commit comments

Comments
 (0)