Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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
23 changes: 14 additions & 9 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Specify analysis options.
#
# This file is a copy of analysis_options.yaml from flutter repo
# as of 2023-03-22, but with some modifications marked with
# as of 2023-12-18, but with some modifications marked with
# "DIFFERENT FROM FLUTTER/FLUTTER" below.

analyzer:
Expand All @@ -20,7 +20,7 @@ analyzer:
linter:
rules:
# This list is derived from the list of all available lints located at
# https://github.com/dart-lang/linter/blob/master/example/all.yaml
# https://github.com/dart-lang/linter/blob/main/example/all.yaml
- always_declare_return_types
- always_put_control_body_on_new_line
# - always_put_required_named_parameters_first # we prefer having parameters in the same order as fields https://github.com/flutter/flutter/issues/10219
Expand All @@ -31,7 +31,7 @@ linter:
- avoid_bool_literals_in_conditional_expressions
# - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
# - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
# - avoid_classes_with_only_static_members # we do this commonly
# - avoid_classes_with_only_static_members # we do this commonly for `abstract final class`es
- avoid_double_and_int_checks
- avoid_dynamic_calls
- avoid_empty_else
Expand All @@ -40,7 +40,7 @@ linter:
- avoid_field_initializers_in_const_classes
# - avoid_final_parameters # incompatible with prefer_final_parameters
- avoid_function_literals_in_foreach_calls
- avoid_implementing_value_types
# - avoid_implementing_value_types # see https://github.com/dart-lang/linter/issues/4558
- avoid_init_to_null
- avoid_js_rounded_ints
# - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
Expand Down Expand Up @@ -82,6 +82,7 @@ linter:
- dangling_library_doc_comments
- depend_on_referenced_packages
- deprecated_consistency
# - deprecated_member_use_from_same_package # we allow self-references to deprecated members
# - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
- directives_ordering
# - discarded_futures # too many false positives, similar to unawaited_futures
Expand All @@ -96,25 +97,28 @@ linter:
- hash_and_equals
- implementation_imports
- implicit_call_tearoffs
- implicit_reopen
- invalid_case_patterns
- iterable_contains_unrelated_type
# - join_return_with_assignment # not required by flutter style
- leading_newlines_in_multiline_strings
- library_annotations
- library_names
- library_prefixes
- library_private_types_in_public_api
# - lines_longer_than_80_chars # not required by flutter style
- list_remove_unrelated_type
# - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
- literal_only_boolean_expressions
# - matching_super_parameters # blocked on https://github.com/dart-lang/language/issues/2509
# - missing_whitespace_between_adjacent_strings # DIFFERENT FROM FLUTTER/FLUTTER (too many false positives)
- no_adjacent_strings_in_list
- no_default_cases
- no_duplicate_case_values
- no_leading_underscores_for_library_prefixes
- no_leading_underscores_for_local_identifiers
- no_literal_bool_comparisons
- no_logic_in_create_state
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
- no_self_assignments
- no_wildcard_variable_uses
- non_constant_identifier_names
- noop_primitive_operations
- null_check_on_nullable_type_parameter
Expand Down Expand Up @@ -143,7 +147,7 @@ linter:
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
# - prefer_final_parameters # we should enable this one day when it can be auto-fixed (https://github.com/dart-lang/linter/issues/3104), see also parameter_assignments
# - prefer_final_parameters # adds too much verbosity
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
- prefer_function_declarations_over_variables
Expand Down Expand Up @@ -183,6 +187,7 @@ linter:
- tighten_type_of_initializing_formals
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
- type_literal_in_constant_pattern
# - unawaited_futures # too many false positives, especially with the way AnimationController works
- unnecessary_await_in_return
- unnecessary_brace_in_string_interps
Expand All @@ -208,7 +213,7 @@ linter:
- unnecessary_string_interpolations
- unnecessary_this
- unnecessary_to_list_in_spreads
# - unreachable_from_main # Do not enable this rule until it is un-marked as "experimental" and carefully re-evaluated.
- unreachable_from_main
- unrelated_type_equality_checks
- unsafe_html
- use_build_context_synchronously
Expand Down
18 changes: 2 additions & 16 deletions ci/bin/format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class FormattingException implements Exception {
final String message;
final ProcessResult? result;

int get exitCode => result?.exitCode ?? -1;

@override
String toString() {
final StringBuffer output = StringBuffer(runtimeType.toString());
Expand Down Expand Up @@ -109,7 +107,6 @@ abstract class FormatChecker {
ProcessManager processManager = const LocalProcessManager(),
required this.baseGitRef,
required this.repoDir,
required this.srcDir,
this.allFiles = false,
this.messageCallback,
}) : _processRunner = ProcessRunner(
Expand Down Expand Up @@ -142,7 +139,6 @@ abstract class FormatChecker {
processManager: processManager,
baseGitRef: baseGitRef,
repoDir: repoDir,
srcDir: srcDir,
allFiles: allFiles,
messageCallback: messageCallback,
);
Expand All @@ -160,7 +156,6 @@ abstract class FormatChecker {
processManager: processManager,
baseGitRef: baseGitRef,
repoDir: repoDir,
srcDir: srcDir,
allFiles: allFiles,
messageCallback: messageCallback,
);
Expand All @@ -169,15 +164,13 @@ abstract class FormatChecker {
processManager: processManager,
baseGitRef: baseGitRef,
repoDir: repoDir,
srcDir: srcDir,
allFiles: allFiles,
messageCallback: messageCallback,
);
}
}

final ProcessRunner _processRunner;
final Directory srcDir;
final Directory repoDir;
final bool allFiles;
MessageCallback? messageCallback;
Expand Down Expand Up @@ -302,9 +295,7 @@ class ClangFormatChecker extends FormatChecker {
required Directory srcDir,
super.allFiles,
super.messageCallback,
}) : super(
srcDir: srcDir,
) {
}) {
/*late*/ String clangOs;
if (Platform.isLinux) {
clangOs = 'linux-x64';
Expand Down Expand Up @@ -462,9 +453,7 @@ class JavaFormatChecker extends FormatChecker {
required Directory srcDir,
super.allFiles,
super.messageCallback,
}) : super(
srcDir: srcDir,
) {
}) {
googleJavaFormatJar = File(
path.absolute(
path.join(
Expand Down Expand Up @@ -619,7 +608,6 @@ class GnFormatChecker extends FormatChecker {
super.processManager,
required super.baseGitRef,
required Directory repoDir,
required super.srcDir,
super.allFiles,
super.messageCallback,
}) : super(
Expand Down Expand Up @@ -750,7 +738,6 @@ class PythonFormatChecker extends FormatChecker {
super.processManager,
required super.baseGitRef,
required Directory repoDir,
required super.srcDir,
super.allFiles,
super.messageCallback,
}) : super(
Expand Down Expand Up @@ -845,7 +832,6 @@ class WhitespaceFormatChecker extends FormatChecker {
super.processManager,
required super.baseGitRef,
required super.repoDir,
required super.srcDir,
super.allFiles,
super.messageCallback,
});
Expand Down
2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: 5e484e46971049766e74d801d325ad63
Signature: b0fbe71c20bdf5b2a1c163281b1f90de

28 changes: 7 additions & 21 deletions ci/test/format_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,34 @@ import 'dart:io' as io;

import 'package:litetest/litetest.dart';
import 'package:path/path.dart' as path;
import 'package:process_runner/process_runner.dart';

import '../bin/format.dart' as target;

final io.File script = io.File.fromUri(io.Platform.script).absolute;
final io.Directory repoDir = script.parent.parent.parent;
final ProcessPool pool = ProcessPool(
numWorkers: 1,
processRunner: ProcessRunner(defaultWorkingDirectory: repoDir),
);

class FileContentPair {
FileContentPair(this.original, this.formatted, this.fileExtension);
FileContentPair(this.original, this.formatted);

final String original;
final String formatted;
final String fileExtension;
}

final FileContentPair ccContentPair = FileContentPair(
'int main(){return 0;}\n', 'int main() {\n return 0;\n}\n', '.cc');
'int main(){return 0;}\n', 'int main() {\n return 0;\n}\n');
final FileContentPair hContentPair =
FileContentPair('int\nmain\n()\n;\n', 'int main();\n', '.h');
FileContentPair('int\nmain\n()\n;\n', 'int main();\n');
final FileContentPair gnContentPair = FileContentPair(
'test\n(){testvar=true}\n', 'test() {\n testvar = true\n}\n', '.gn');
'test\n(){testvar=true}\n', 'test() {\n testvar = true\n}\n');
final FileContentPair javaContentPair = FileContentPair(
'class Test{public static void main(String args[]){System.out.println("Test");}}\n',
'class Test {\n public static void main(String args[]) {\n System.out.println("Test");\n }\n}\n',
'.java');
'class Test {\n public static void main(String args[]) {\n System.out.println("Test");\n }\n}\n');
final FileContentPair pythonContentPair = FileContentPair(
"if __name__=='__main__':\n sys.exit(\nMain(sys.argv)\n)\n",
"if __name__ == '__main__':\n sys.exit(Main(sys.argv))\n",
'.py');
"if __name__ == '__main__':\n sys.exit(Main(sys.argv))\n");
final FileContentPair whitespaceContentPair = FileContentPair(
'int main() {\n return 0; \n}\n',
'int main() {\n return 0;\n}\n',
'.c');
'int main() {\n return 0;\n}\n');

class TestFileFixture {
TestFileFixture(this.type) {
Expand Down Expand Up @@ -106,31 +97,26 @@ class TestFileFixture {
path.extension(file.path) == '.cc'
? ccContentPair.formatted
: hContentPair.formatted,
path.extension(file.path),
);
case target.FormatCheck.gn:
return FileContentPair(
content,
gnContentPair.formatted,
path.extension(file.path),
);
case target.FormatCheck.java:
return FileContentPair(
content,
javaContentPair.formatted,
path.extension(file.path),
);
case target.FormatCheck.python:
return FileContentPair(
content,
pythonContentPair.formatted,
path.extension(file.path),
);
case target.FormatCheck.whitespace:
return FileContentPair(
content,
whitespaceContentPair.formatted,
path.extension(file.path),
);
}
});
Expand Down
4 changes: 4 additions & 0 deletions lib/ui/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ analyzer:
exclude:
# fixtures/ depends on dart:ui and raises false positives.
- fixtures/**

linter:
rules:
unreachable_from_main: false # lint not compatible with how dart:ui is structured
4 changes: 1 addition & 3 deletions lib/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,7 @@ class Paint {
}
semicolon = '; ';
}
if (isAntiAlias != true) {
if (!isAntiAlias) {
result.write('${semicolon}antialias off');
semicolon = '; ';
}
Expand Down Expand Up @@ -6864,9 +6864,7 @@ base class _NativeImageDescriptor extends NativeFieldWrapperClass1 implements Im
targetHeight = height;
} else if (targetWidth == null && targetHeight != null) {
targetWidth = (targetHeight * (width / height)).round();
targetHeight = targetHeight;
} else if (targetHeight == null && targetWidth != null) {
targetWidth = targetWidth;
targetHeight = targetWidth ~/ (width / height);
}
assert(targetWidth != null);
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/lib/src/engine/canvaskit/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ CkImage scaleImage(SkImage image, int? targetWidth, int? targetHeight) {
}
if (targetWidth == null && targetHeight != null) {
targetWidth = (targetHeight * (image.width() / image.height())).round();
targetHeight = targetHeight;
} else if (targetHeight == null && targetWidth != null) {
targetWidth = targetWidth;
targetHeight = targetWidth ~/ (image.width() / image.height());
}

Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/html/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class SurfacePaint implements ui.Paint {
}
semicolon = '; ';
}
if (isAntiAlias != true) {
if (!isAntiAlias) {
result.write('${semicolon}antialias off');
semicolon = '; ';
}
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/html/recording_canvas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class RecordingCanvas {
return;
}
final RecordingCanvas pictureRecording = enginePicture.recordingCanvas!;
if (pictureRecording._didDraw == true) {
if (pictureRecording._didDraw) {
_didDraw = true;
}
renderStrategy.merge(pictureRecording.renderStrategy);
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/lib/src/engine/semantics/text_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ class SemanticsTextEditingStrategy extends DefaultTextEditingStrategy {
{OnChangeCallback? onChange, OnActionCallback? onAction}) {
isEnabled = true;
inputConfiguration = inputConfig;
onChange = onChange;
onAction = onAction;
Comment on lines -155 to -156
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this just to mark these as "used" parameters?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering that as well...

applyConfiguration(inputConfig);
}

Expand Down
12 changes: 6 additions & 6 deletions lib/web_ui/lib/src/engine/text_editing/text_editing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1506,18 +1506,18 @@ abstract class DefaultTextEditingStrategy with CompositionAwareMixin implements
/// see: https://bugs.chromium.org/p/chromium/issues/detail?id=119216#c11.
void preventDefaultForMouseEvents() {
subscriptions.add(
DomSubscription(activeDomElement, 'mousedown', (_) {
_.preventDefault();
DomSubscription(activeDomElement, 'mousedown', (DomEvent event) {
event.preventDefault();
}));

subscriptions.add(
DomSubscription(activeDomElement, 'mouseup', (_) {
_.preventDefault();
DomSubscription(activeDomElement, 'mouseup', (DomEvent event) {
event.preventDefault();
}));

subscriptions.add(
DomSubscription(activeDomElement, 'mousemove', (_) {
_.preventDefault();
DomSubscription(activeDomElement, 'mousemove', (DomEvent event) {
event.preventDefault();
}));
}
}
Expand Down
2 changes: 0 additions & 2 deletions lib/web_ui/test/canvaskit/render_canvas_factory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import 'package:ui/src/engine.dart';

import 'common.dart';

const MethodCodec codec = StandardMethodCodec();

void main() {
internalBootstrapBrowserTest(() => testMain);
}
Expand Down
1 change: 0 additions & 1 deletion lib/web_ui/test/engine/history_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ Map<String, dynamic> _tagStateWithSerialCount(dynamic state, int serialCount) {
};
}

const Map<String, bool> originState = <String, bool>{'origin': true};
const Map<String, bool> flutterState = <String, bool>{'flutter': true};

const MethodCodec codec = JSONMethodCodec();
Expand Down
Loading