mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Enable new linter rules in analyzer packages
Change-Id: Id0182648a347a05cbf6e1483a0afe94219268853 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271000 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
parent
419c5fdb91
commit
5f8ef7be53
|
@ -16,13 +16,21 @@ linter:
|
|||
avoid_types_as_parameter_names: true
|
||||
avoid_unused_constructor_parameters: true
|
||||
camel_case_extensions: true
|
||||
collection_methods_unrelated_type: true
|
||||
curly_braces_in_flow_control_structures: true
|
||||
|
||||
# Enable when we require Dart 2.19.0.
|
||||
#- dangling_library_doc_comments
|
||||
depend_on_referenced_packages: true
|
||||
directives_ordering: true
|
||||
empty_catches: true
|
||||
enable_null_safety: true
|
||||
|
||||
# We import heavily from package:analyzer/src.
|
||||
implementation_imports: false
|
||||
implicit_call_tearoffs: true
|
||||
library_annotations: true
|
||||
|
||||
# This rule does not work well with package:test_reflective_loader.
|
||||
no_duplicate_case_values: true
|
||||
non_constant_identifier_names: false
|
||||
|
@ -32,4 +40,7 @@ linter:
|
|||
prefer_iterable_whereType: true
|
||||
prefer_single_quotes: true
|
||||
unawaited_futures: true
|
||||
unnecessary_library_directive: true
|
||||
unnecessary_parenthesis: true
|
||||
unreachable_from_main: true
|
||||
unrelated_type_equality_checks: true
|
||||
|
|
|
@ -270,7 +270,7 @@ class CommandLineOptions {
|
|||
|
||||
// Check that SDK is existing directory.
|
||||
if (sdkPath != null) {
|
||||
if (!(io.Directory(sdkPath)).existsSync()) {
|
||||
if (!io.Directory(sdkPath).existsSync()) {
|
||||
printAndFail('Invalid Dart SDK path: $sdkPath');
|
||||
return null; // Only reachable in testing.
|
||||
}
|
||||
|
|
|
@ -118,47 +118,47 @@ void main() {
|
|||
};
|
||||
|
||||
test('no values', () {
|
||||
var options = overrideKnownFeatures(
|
||||
knownFeatures, (() => parse(['foo.dart'])!));
|
||||
var options =
|
||||
overrideKnownFeatures(knownFeatures, () => parse(['foo.dart'])!);
|
||||
expect(options.enabledExperiments, isEmpty);
|
||||
});
|
||||
|
||||
test('single value', () {
|
||||
var options = overrideKnownFeatures(knownFeatures,
|
||||
(() => parse(['--enable-experiment', 'a', 'foo.dart'])!));
|
||||
() => parse(['--enable-experiment', 'a', 'foo.dart'])!);
|
||||
expect(options.enabledExperiments, ['a']);
|
||||
});
|
||||
|
||||
group('multiple values', () {
|
||||
test('single flag', () {
|
||||
var options = overrideKnownFeatures(knownFeatures,
|
||||
(() => parse(['--enable-experiment', 'a,b', 'foo.dart'])!));
|
||||
() => parse(['--enable-experiment', 'a,b', 'foo.dart'])!);
|
||||
expect(options.enabledExperiments, ['a', 'b']);
|
||||
});
|
||||
|
||||
test('mixed single and multiple flags', () {
|
||||
var options = overrideKnownFeatures(
|
||||
knownFeatures,
|
||||
(() => parse([
|
||||
() => parse([
|
||||
'--enable-experiment',
|
||||
'a,b',
|
||||
'--enable-experiment',
|
||||
'c',
|
||||
'foo.dart'
|
||||
])!));
|
||||
])!);
|
||||
expect(options.enabledExperiments, ['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
test('multiple flags', () {
|
||||
var options = overrideKnownFeatures(
|
||||
knownFeatures,
|
||||
(() => parse([
|
||||
() => parse([
|
||||
'--enable-experiment',
|
||||
'a',
|
||||
'--enable-experiment',
|
||||
'b',
|
||||
'foo.dart'
|
||||
])!));
|
||||
])!);
|
||||
expect(options.enabledExperiments, ['a', 'b']);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ String get packageRoot {
|
|||
/// to the specified destination path.
|
||||
Future<void> recursiveCopy(FileSystemEntity src, String dstPath) async {
|
||||
if (src is Directory) {
|
||||
await (Directory(dstPath)).create(recursive: true);
|
||||
await Directory(dstPath).create(recursive: true);
|
||||
for (var entity in src.listSync()) {
|
||||
await recursiveCopy(
|
||||
entity, pathos.join(dstPath, pathos.basename(entity.path)));
|
||||
|
|
|
@ -8,9 +8,19 @@ linter:
|
|||
rules:
|
||||
# In addition to lints/recommended:
|
||||
always_declare_return_types: true
|
||||
collection_methods_unrelated_type: true
|
||||
# Enable when we require Dart 2.19.0.
|
||||
#dangling_library_doc_comments: true
|
||||
depend_on_referenced_packages: true
|
||||
enable_null_safety: true
|
||||
implicit_call_tearoffs: true
|
||||
library_annotations: true
|
||||
omit_local_variable_types: true
|
||||
prefer_single_quotes: true
|
||||
unawaited_futures: true
|
||||
unnecessary_library_directive: true
|
||||
unnecessary_parenthesis: true
|
||||
unreachable_from_main: true
|
||||
|
||||
# Remove from lints/recommended:
|
||||
constant_identifier_names: false
|
||||
|
@ -18,6 +28,4 @@ linter:
|
|||
non_constant_identifier_names: false
|
||||
|
||||
# Existing violations (3)
|
||||
library_private_types_in_public_api: false
|
||||
# Existing violations (3)
|
||||
prefer_initializing_formals: false
|
||||
library_private_types_in_public_api: false
|
|
@ -261,11 +261,9 @@ class CompletionTarget {
|
|||
|
||||
/// Create a [CompletionTarget] holding the given [containingNode] and
|
||||
/// [entity].
|
||||
CompletionTarget._(this.offset, AstNode containingNode,
|
||||
SyntacticEntity? entity, this.isCommentText)
|
||||
: containingNode = containingNode,
|
||||
entity = entity,
|
||||
argIndex = _computeArgIndex(containingNode, entity),
|
||||
CompletionTarget._(
|
||||
this.offset, this.containingNode, this.entity, this.isCommentText)
|
||||
: argIndex = _computeArgIndex(containingNode, entity),
|
||||
droppedToken = _computeDroppedToken(containingNode, entity, offset);
|
||||
|
||||
/// Return the expression to the left of the "dot" or "dot dot",
|
||||
|
|
|
@ -438,7 +438,7 @@ class Server {
|
|||
/// [notificationProcessor].
|
||||
void listenToOutput(NotificationProcessor notificationProcessor) {
|
||||
_process!.stdout
|
||||
.transform((Utf8Codec()).decoder)
|
||||
.transform(Utf8Codec().decoder)
|
||||
.transform(LineSplitter())
|
||||
.listen((String line) {
|
||||
lastCommunicationTime = currentElapseTime;
|
||||
|
@ -489,7 +489,7 @@ class Server {
|
|||
}
|
||||
});
|
||||
_process!.stderr
|
||||
.transform((Utf8Codec()).decoder)
|
||||
.transform(Utf8Codec().decoder)
|
||||
.transform(LineSplitter())
|
||||
.listen((String line) {
|
||||
var trimmedLine = line.trim();
|
||||
|
@ -641,9 +641,7 @@ class _ListOf extends Matcher {
|
|||
/// Iterable matcher which we use to test the contents of the list.
|
||||
final Matcher iterableMatcher;
|
||||
|
||||
_ListOf(Matcher elementMatcher)
|
||||
: elementMatcher = elementMatcher,
|
||||
iterableMatcher = everyElement(elementMatcher);
|
||||
_ListOf(this.elementMatcher) : iterableMatcher = everyElement(elementMatcher);
|
||||
|
||||
@override
|
||||
Description describe(Description description) =>
|
||||
|
|
|
@ -346,8 +346,8 @@ class ServerPluginTest extends AbstractPluginTest {
|
|||
}
|
||||
|
||||
Future<void> test_onRequest_pluginVersionCheck() async {
|
||||
var response = (await channel.sendRequest(
|
||||
PluginVersionCheckParams('byteStorePath', 'sdkPath', '0.1.0')));
|
||||
var response = await channel.sendRequest(
|
||||
PluginVersionCheckParams('byteStorePath', 'sdkPath', '0.1.0'));
|
||||
var result = PluginVersionCheckResult.fromResponse(response);
|
||||
expect(result, isNotNull);
|
||||
expect(result.interestingFiles, ['*.dart']);
|
||||
|
|
|
@ -6,7 +6,18 @@ analyzer:
|
|||
|
||||
linter:
|
||||
rules:
|
||||
- collection_methods_unrelated_type
|
||||
# Enable when we require Dart 2.19.0.
|
||||
#- dangling_library_doc_comments
|
||||
- depend_on_referenced_packages
|
||||
- empty_constructor_bodies
|
||||
- empty_statements
|
||||
- enable_null_safety
|
||||
- implicit_call_tearoffs
|
||||
- library_annotations
|
||||
- unawaited_futures
|
||||
- unnecessary_brace_in_string_interps
|
||||
- unnecessary_library_directive
|
||||
- unnecessary_parenthesis
|
||||
- unreachable_from_main
|
||||
- valid_regexps
|
||||
|
|
Loading…
Reference in a new issue