Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Share analysis config between packages #2447

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions _analysis_config/lib/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

include: package:lints/recommended.yaml

analyzer:
# language:
# strict-casts: true
errors:
dead_code: error
unused_element: error
unused_import: error
unused_local_variable: error

linter:
rules:
- always_declare_return_types
- avoid_classes_with_only_static_members
- avoid_returning_this
- avoid_unused_constructor_parameters
- avoid_void_async
- cancel_subscriptions
- directives_ordering
- join_return_with_assignment
- library_names
- literal_only_boolean_expressions
- package_api_docs
- package_prefixed_library_names
# - prefer_final_locals
# - prefer_relative_imports
- prefer_single_quotes
- prefer_void_to_null
- test_types_in_equals
- throw_in_finally
- omit_local_variable_types
- only_throw_errors
- unawaited_futures
- unnecessary_lambdas
- unnecessary_parenthesis
- unnecessary_statements

# TODO(https://github.com/dart-lang/webdev/issues/2053): Enable commented-out rules with fixes.
dart_code_metrics:
metrics:
# cyclomatic-complexity: 20 # Enable.
# number-of-parameters: 5 # Enable.
# maximum-nesting-level: 5 # Enable.
metrics-exclude:
- test/**
rules:
# - arguments-ordering
# - avoid-banned-imports
- avoid-cascade-after-if-null
- avoid-collection-methods-with-unrelated-types
# - avoid-double-slash-imports
- avoid-duplicate-exports
# - avoid-dynamic
# - avoid-global-state # Enable.
# - avoid-ignoring-return-values
# - avoid-late-keyword
- avoid-missing-enum-constant-in-map
- avoid-nested-conditional-expressions
- avoid-non-ascii-symbols
# - avoid-non-null-assertion # Enable.
# - avoid-passing-async-when-sync-expected # Enable.
- avoid-redundant-async
# - avoid-throw-in-catch-block # Enable.
# - avoid-top-level-members-in-tests
# - avoid-unnecessary-conditionals
- avoid-unnecessary-type-assertions
- avoid-unnecessary-type-casts
- avoid-unrelated-type-assertions
- avoid-unused-parameters
# - ban-name
- binary-expression-operand-order
- double-literal-format
# - format-comment # Enable.
# - list-all-equatable-fields
# - member-ordering # Enable.
# - missing-test-assertion
# - new-line-before-return
- no-boolean-literal-compare
# - no-empty-block # Enable.
# - no-equal-arguments
- no-equal-then-else
# - no-magic-number
# - no-object-declaration
# - prefer-async-await # Enable.
# - prefer-commenting-analyzer-ignores # Enable.
# - prefer-conditional-expressions
# - prefer-correct-identifier-length
# - prefer-correct-test-file-name # Enable.
- prefer-correct-type-name
- prefer-enums-by-name
# - prefer-first
# - prefer-immediate-return # Enable.
- prefer-iterable-of
- prefer-last
# - prefer-match-file-name
# - prefer-moving-to-variable: # Enable.
# allow-duplicated-chains: 2
# - prefer-static-class
# - prefer-trailing-comma
# - tag-name
10 changes: 10 additions & 0 deletions _analysis_config/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: analysis_config
description: The shared analysis configuration for the webdev packages.

publish_to: none

environment:
sdk: ^3.1.0

dependencies:
lints: ^4.0.0
106 changes: 0 additions & 106 deletions analysis_options.yaml

This file was deleted.

73 changes: 1 addition & 72 deletions dwds/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# This file contains the analysis options used for code in the webdev
# repository.

include: package:lints/recommended.yaml
include: package:analysis_config/analysis_options.yaml

analyzer:
exclude:
Expand All @@ -13,73 +10,5 @@ analyzer:
linter:
rules:
- always_use_package_imports
- avoid_void_async
- directives_ordering
- prefer_final_locals
- require_trailing_commas
- unawaited_futures
- unnecessary_lambdas

# TODO(https://github.com/dart-lang/webdev/issues/2053): Enable commented-out rules with fixes.
dart_code_metrics:
metrics:
# cyclomatic-complexity: 20 # Enable.
# number-of-parameters: 5 # Enable.
# maximum-nesting-level: 5 # Enable.
metrics-exclude:
- test/**
rules:
# - arguments-ordering
# - avoid-banned-imports
- avoid-cascade-after-if-null
- avoid-collection-methods-with-unrelated-types
# - avoid-double-slash-imports
- avoid-duplicate-exports
# - avoid-dynamic
# - avoid-global-state # Enable.
# - avoid-ignoring-return-values
# - avoid-late-keyword
- avoid-missing-enum-constant-in-map
- avoid-nested-conditional-expressions
- avoid-non-ascii-symbols
# - avoid-non-null-assertion # Enable.
# - avoid-passing-async-when-sync-expected # Enable.
- avoid-redundant-async
# - avoid-throw-in-catch-block # Enable.
# - avoid-top-level-members-in-tests
# - avoid-unnecessary-conditionals
- avoid-unnecessary-type-assertions
- avoid-unnecessary-type-casts
- avoid-unrelated-type-assertions
- avoid-unused-parameters
# - ban-name
- binary-expression-operand-order
- double-literal-format
# - format-comment # Enable.
# - list-all-equatable-fields
# - member-ordering # Enable.
# - missing-test-assertion
# - new-line-before-return
- no-boolean-literal-compare
# - no-empty-block # Enable.
# - no-equal-arguments
- no-equal-then-else
# - no-magic-number
# - no-object-declaration
# - prefer-async-await # Enable.
# - prefer-commenting-analyzer-ignores # Enable.
# - prefer-conditional-expressions
# - prefer-correct-identifier-length
# - prefer-correct-test-file-name # Enable.
- prefer-correct-type-name
- prefer-enums-by-name
# - prefer-first
# - prefer-immediate-return # Enable.
- prefer-iterable-of
- prefer-last
# - prefer-match-file-name
# - prefer-moving-to-variable: # Enable.
# allow-duplicated-chains: 2
# - prefer-static-class
# - prefer-trailing-comma
# - tag-name
10 changes: 5 additions & 5 deletions dwds/debug_extension/tool/copy_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Builder copyBuilder(_) => _CopyBuilder();
class _CopyBuilder extends Builder {
@override
Map<String, List<String>> get buildExtensions => {
"web/{{}}.dart.js": ["compiled/{{}}.dart.js"],
"web/static_assets/{{}}.png": ["compiled/static_assets/{{}}.png"],
"web/static_assets/{{}}.html": ["compiled/static_assets/{{}}.html"],
"web/static_assets/{{}}.css": ["compiled/static_assets/{{}}.css"],
"web/manifest.json": ["compiled/manifest.json"],
'web/{{}}.dart.js': ['compiled/{{}}.dart.js'],
'web/static_assets/{{}}.png': ['compiled/static_assets/{{}}.png'],
'web/static_assets/{{}}.html': ['compiled/static_assets/{{}}.html'],
'web/static_assets/{{}}.css': ['compiled/static_assets/{{}}.css'],
'web/manifest.json': ['compiled/manifest.json'],
};

@override
Expand Down
4 changes: 2 additions & 2 deletions dwds/debug_extension/tool/update_dev_files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ String _newKeyValue({

extension LeftPaddingExtension on String {
String leftPadding() {
String padding = '';
int idx = 0;
var padding = '';
var idx = 0;
while (idx < length && this[idx] == ' ') {
padding += ' ';
idx++;
Expand Down
4 changes: 2 additions & 2 deletions dwds/debug_extension/web/debug_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void _registerDebugEventListeners() {
);
}

_enableExecutionContextReporting(int tabId) {
void _enableExecutionContextReporting(int tabId) {
// Runtime.enable enables reporting of execution contexts creation by means of
// executionContextCreated event. When the reporting gets enabled the event
// will be sent immediately for each existing execution context:
Expand Down Expand Up @@ -299,7 +299,7 @@ Future<void> _maybeConnectToDwds(int tabId, Object? params) async {
final context = json.decode(JSON.stringify(params))['context'];
final contextOrigin = context['origin'] as String?;
if (contextOrigin == null) return;
if (contextOrigin.contains(('chrome-extension:'))) return;
if (contextOrigin.contains('chrome-extension:')) return;
final debugInfo = await fetchStorageObject<DebugInfo>(
type: StorageObject.debugInfo,
tabId: tabId,
Expand Down
6 changes: 3 additions & 3 deletions dwds/debug_extension/web/logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ enum _LogLevel {
error,
}

debugLog(
void debugLog(
String msg, {
String? prefix,
bool verbose = false,
}) {
_log(msg, prefix: prefix, verbose: verbose);
}

debugWarn(
void debugWarn(
String msg, {
String? prefix,
bool verbose = false,
}) {
_log(msg, prefix: prefix, level: _LogLevel.warn, verbose: verbose);
}

debugError(
void debugError(
String msg, {
String? prefix,
bool verbose = false,
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/debugging/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class Debugger extends Domain {
// TODO(#700): Understand when this can happen and have a better fix.
if (script == null) return null;

final functionName = _prettifyMember((frame.functionName).split('.').last);
final functionName = _prettifyMember(frame.functionName.split('.').last);
final codeRefName = functionName.isEmpty ? '<closure>' : functionName;

final dartFrame = Frame(
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/debugging/inspector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ class AppInspector implements AppInspectorInterface {
int? count,
int? length,
}) async {
String rangeId = objectId;
var rangeId = objectId;
// Ignore offset/count if there is no length:
if (length != null) {
if (_isEmptyRange(offset: offset, count: count, length: length)) {
Expand Down
Loading
Loading