Skip to content

Commit ed25f7a

Browse files
authored
Share analysis config between packages (#2447)
* Share analysis config between packages * Update missing SDK constraint
1 parent e9b0868 commit ed25f7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+341
-386
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
# for details. All rights reserved. Use of this source code is governed by a
3+
# BSD-style license that can be found in the LICENSE file.
4+
5+
include: package:lints/recommended.yaml
6+
7+
analyzer:
8+
# language:
9+
# strict-casts: true
10+
errors:
11+
dead_code: error
12+
unused_element: error
13+
unused_import: error
14+
unused_local_variable: error
15+
16+
linter:
17+
rules:
18+
- always_declare_return_types
19+
- avoid_classes_with_only_static_members
20+
- avoid_returning_this
21+
- avoid_unused_constructor_parameters
22+
- avoid_void_async
23+
- cancel_subscriptions
24+
- directives_ordering
25+
- join_return_with_assignment
26+
- library_names
27+
- literal_only_boolean_expressions
28+
- package_api_docs
29+
- package_prefixed_library_names
30+
# - prefer_final_locals
31+
# - prefer_relative_imports
32+
- prefer_single_quotes
33+
- prefer_void_to_null
34+
- test_types_in_equals
35+
- throw_in_finally
36+
- omit_local_variable_types
37+
- only_throw_errors
38+
- unawaited_futures
39+
- unnecessary_lambdas
40+
- unnecessary_parenthesis
41+
- unnecessary_statements
42+
43+
# TODO(https://github.com/dart-lang/webdev/issues/2053): Enable commented-out rules with fixes.
44+
dart_code_metrics:
45+
metrics:
46+
# cyclomatic-complexity: 20 # Enable.
47+
# number-of-parameters: 5 # Enable.
48+
# maximum-nesting-level: 5 # Enable.
49+
metrics-exclude:
50+
- test/**
51+
rules:
52+
# - arguments-ordering
53+
# - avoid-banned-imports
54+
- avoid-cascade-after-if-null
55+
- avoid-collection-methods-with-unrelated-types
56+
# - avoid-double-slash-imports
57+
- avoid-duplicate-exports
58+
# - avoid-dynamic
59+
# - avoid-global-state # Enable.
60+
# - avoid-ignoring-return-values
61+
# - avoid-late-keyword
62+
- avoid-missing-enum-constant-in-map
63+
- avoid-nested-conditional-expressions
64+
- avoid-non-ascii-symbols
65+
# - avoid-non-null-assertion # Enable.
66+
# - avoid-passing-async-when-sync-expected # Enable.
67+
- avoid-redundant-async
68+
# - avoid-throw-in-catch-block # Enable.
69+
# - avoid-top-level-members-in-tests
70+
# - avoid-unnecessary-conditionals
71+
- avoid-unnecessary-type-assertions
72+
- avoid-unnecessary-type-casts
73+
- avoid-unrelated-type-assertions
74+
- avoid-unused-parameters
75+
# - ban-name
76+
- binary-expression-operand-order
77+
- double-literal-format
78+
# - format-comment # Enable.
79+
# - list-all-equatable-fields
80+
# - member-ordering # Enable.
81+
# - missing-test-assertion
82+
# - new-line-before-return
83+
- no-boolean-literal-compare
84+
# - no-empty-block # Enable.
85+
# - no-equal-arguments
86+
- no-equal-then-else
87+
# - no-magic-number
88+
# - no-object-declaration
89+
# - prefer-async-await # Enable.
90+
# - prefer-commenting-analyzer-ignores # Enable.
91+
# - prefer-conditional-expressions
92+
# - prefer-correct-identifier-length
93+
# - prefer-correct-test-file-name # Enable.
94+
- prefer-correct-type-name
95+
- prefer-enums-by-name
96+
# - prefer-first
97+
# - prefer-immediate-return # Enable.
98+
- prefer-iterable-of
99+
- prefer-last
100+
# - prefer-match-file-name
101+
# - prefer-moving-to-variable: # Enable.
102+
# allow-duplicated-chains: 2
103+
# - prefer-static-class
104+
# - prefer-trailing-comma
105+
# - tag-name

_analysis_config/pubspec.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: analysis_config
2+
description: The shared analysis configuration for the webdev packages.
3+
4+
publish_to: none
5+
6+
environment:
7+
sdk: ^3.1.0
8+
9+
dependencies:
10+
lints: ^4.0.0

analysis_options.yaml

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

dwds/analysis_options.yaml

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# This file contains the analysis options used for code in the webdev
2-
# repository.
3-
4-
include: package:lints/recommended.yaml
1+
include: package:analysis_config/analysis_options.yaml
52

63
analyzer:
74
exclude:
@@ -13,73 +10,5 @@ analyzer:
1310
linter:
1411
rules:
1512
- always_use_package_imports
16-
- avoid_void_async
17-
- directives_ordering
1813
- prefer_final_locals
1914
- require_trailing_commas
20-
- unawaited_futures
21-
- unnecessary_lambdas
22-
23-
# TODO(https://github.com/dart-lang/webdev/issues/2053): Enable commented-out rules with fixes.
24-
dart_code_metrics:
25-
metrics:
26-
# cyclomatic-complexity: 20 # Enable.
27-
# number-of-parameters: 5 # Enable.
28-
# maximum-nesting-level: 5 # Enable.
29-
metrics-exclude:
30-
- test/**
31-
rules:
32-
# - arguments-ordering
33-
# - avoid-banned-imports
34-
- avoid-cascade-after-if-null
35-
- avoid-collection-methods-with-unrelated-types
36-
# - avoid-double-slash-imports
37-
- avoid-duplicate-exports
38-
# - avoid-dynamic
39-
# - avoid-global-state # Enable.
40-
# - avoid-ignoring-return-values
41-
# - avoid-late-keyword
42-
- avoid-missing-enum-constant-in-map
43-
- avoid-nested-conditional-expressions
44-
- avoid-non-ascii-symbols
45-
# - avoid-non-null-assertion # Enable.
46-
# - avoid-passing-async-when-sync-expected # Enable.
47-
- avoid-redundant-async
48-
# - avoid-throw-in-catch-block # Enable.
49-
# - avoid-top-level-members-in-tests
50-
# - avoid-unnecessary-conditionals
51-
- avoid-unnecessary-type-assertions
52-
- avoid-unnecessary-type-casts
53-
- avoid-unrelated-type-assertions
54-
- avoid-unused-parameters
55-
# - ban-name
56-
- binary-expression-operand-order
57-
- double-literal-format
58-
# - format-comment # Enable.
59-
# - list-all-equatable-fields
60-
# - member-ordering # Enable.
61-
# - missing-test-assertion
62-
# - new-line-before-return
63-
- no-boolean-literal-compare
64-
# - no-empty-block # Enable.
65-
# - no-equal-arguments
66-
- no-equal-then-else
67-
# - no-magic-number
68-
# - no-object-declaration
69-
# - prefer-async-await # Enable.
70-
# - prefer-commenting-analyzer-ignores # Enable.
71-
# - prefer-conditional-expressions
72-
# - prefer-correct-identifier-length
73-
# - prefer-correct-test-file-name # Enable.
74-
- prefer-correct-type-name
75-
- prefer-enums-by-name
76-
# - prefer-first
77-
# - prefer-immediate-return # Enable.
78-
- prefer-iterable-of
79-
- prefer-last
80-
# - prefer-match-file-name
81-
# - prefer-moving-to-variable: # Enable.
82-
# allow-duplicated-chains: 2
83-
# - prefer-static-class
84-
# - prefer-trailing-comma
85-
# - tag-name

dwds/debug_extension/tool/copy_builder.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Builder copyBuilder(_) => _CopyBuilder();
1010
class _CopyBuilder extends Builder {
1111
@override
1212
Map<String, List<String>> get buildExtensions => {
13-
"web/{{}}.dart.js": ["compiled/{{}}.dart.js"],
14-
"web/static_assets/{{}}.png": ["compiled/static_assets/{{}}.png"],
15-
"web/static_assets/{{}}.html": ["compiled/static_assets/{{}}.html"],
16-
"web/static_assets/{{}}.css": ["compiled/static_assets/{{}}.css"],
17-
"web/manifest.json": ["compiled/manifest.json"],
13+
'web/{{}}.dart.js': ['compiled/{{}}.dart.js'],
14+
'web/static_assets/{{}}.png': ['compiled/static_assets/{{}}.png'],
15+
'web/static_assets/{{}}.html': ['compiled/static_assets/{{}}.html'],
16+
'web/static_assets/{{}}.css': ['compiled/static_assets/{{}}.css'],
17+
'web/manifest.json': ['compiled/manifest.json'],
1818
};
1919

2020
@override

dwds/debug_extension/tool/update_dev_files.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ String _newKeyValue({
7575

7676
extension LeftPaddingExtension on String {
7777
String leftPadding() {
78-
String padding = '';
79-
int idx = 0;
78+
var padding = '';
79+
var idx = 0;
8080
while (idx < length && this[idx] == ' ') {
8181
padding += ' ';
8282
idx++;

dwds/debug_extension/web/debug_session.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void _registerDebugEventListeners() {
246246
);
247247
}
248248

249-
_enableExecutionContextReporting(int tabId) {
249+
void _enableExecutionContextReporting(int tabId) {
250250
// Runtime.enable enables reporting of execution contexts creation by means of
251251
// executionContextCreated event. When the reporting gets enabled the event
252252
// will be sent immediately for each existing execution context:
@@ -299,7 +299,7 @@ Future<void> _maybeConnectToDwds(int tabId, Object? params) async {
299299
final context = json.decode(JSON.stringify(params))['context'];
300300
final contextOrigin = context['origin'] as String?;
301301
if (contextOrigin == null) return;
302-
if (contextOrigin.contains(('chrome-extension:'))) return;
302+
if (contextOrigin.contains('chrome-extension:')) return;
303303
final debugInfo = await fetchStorageObject<DebugInfo>(
304304
type: StorageObject.debugInfo,
305305
tabId: tabId,

dwds/debug_extension/web/logger.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ enum _LogLevel {
1515
error,
1616
}
1717

18-
debugLog(
18+
void debugLog(
1919
String msg, {
2020
String? prefix,
2121
bool verbose = false,
2222
}) {
2323
_log(msg, prefix: prefix, verbose: verbose);
2424
}
2525

26-
debugWarn(
26+
void debugWarn(
2727
String msg, {
2828
String? prefix,
2929
bool verbose = false,
3030
}) {
3131
_log(msg, prefix: prefix, level: _LogLevel.warn, verbose: verbose);
3232
}
3333

34-
debugError(
34+
void debugError(
3535
String msg, {
3636
String? prefix,
3737
bool verbose = false,

dwds/lib/src/debugging/debugger.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class Debugger extends Domain {
443443
// TODO(#700): Understand when this can happen and have a better fix.
444444
if (script == null) return null;
445445

446-
final functionName = _prettifyMember((frame.functionName).split('.').last);
446+
final functionName = _prettifyMember(frame.functionName.split('.').last);
447447
final codeRefName = functionName.isEmpty ? '<closure>' : functionName;
448448

449449
final dartFrame = Frame(

dwds/lib/src/debugging/inspector.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ class AppInspector implements AppInspectorInterface {
573573
int? count,
574574
int? length,
575575
}) async {
576-
String rangeId = objectId;
576+
var rangeId = objectId;
577577
// Ignore offset/count if there is no length:
578578
if (length != null) {
579579
if (_isEmptyRange(offset: offset, count: count, length: length)) {

0 commit comments

Comments
 (0)