1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 22:09:06 +00:00

Account for linter changes in linter_tool (#1930)

This commit is contained in:
Parker Lougheed
2023-07-01 00:41:32 -05:00
committed by GitHub
parent 3df2a9767b
commit f9e1a99d1a
8 changed files with 242 additions and 87 deletions

View File

@@ -18,7 +18,7 @@ class Rule extends Equatable {
@HiveField(2)
final String group;
@HiveField(3)
final String maturity;
final String state;
@HiveField(4)
final List<String> incompatible;
@HiveField(5)
@@ -30,7 +30,7 @@ class Rule extends Equatable {
required this.name,
required this.description,
required this.group,
required this.maturity,
required this.state,
required this.incompatible,
required this.sets,
required this.details,

View File

@@ -20,7 +20,7 @@ class RuleAdapter extends TypeAdapter<Rule> {
name: fields[0] as String,
description: fields[1] as String,
group: fields[2] as String,
maturity: fields[3] as String,
state: fields[3] as String,
incompatible: (fields[4] as List).cast<String>(),
sets: (fields[5] as List).cast<String>(),
details: fields[6] as String,
@@ -38,7 +38,7 @@ class RuleAdapter extends TypeAdapter<Rule> {
..writeByte(2)
..write(obj.group)
..writeByte(3)
..write(obj.maturity)
..write(obj.state)
..writeByte(4)
..write(obj.incompatible)
..writeByte(5)
@@ -66,7 +66,7 @@ Rule _$RuleFromJson(Map<String, dynamic> json) => Rule(
name: json['name'] as String,
description: json['description'] as String,
group: json['group'] as String,
maturity: json['maturity'] as String,
state: json['state'] as String,
incompatible: (json['incompatible'] as List<dynamic>)
.map((e) => e as String)
.toList(),
@@ -78,7 +78,7 @@ Map<String, dynamic> _$RuleToJson(Rule instance) => <String, dynamic>{
'name': instance.name,
'description': instance.description,
'group': instance.group,
'maturity': instance.maturity,
'state': instance.state,
'incompatible': instance.incompatible,
'sets': instance.sets,
'details': instance.details,

View File

@@ -16,7 +16,7 @@ class APIProvider {
Future<List<Rule>> getRulesList() async {
final response =
await httpClient.get(Uri.parse('$_baseURL//lints/machine/rules.json'));
await httpClient.get(Uri.parse('$_baseURL/lints/machine/rules.json'));
if (response.statusCode == 200) {
final data = json.decode(response.body) as List;
@@ -31,7 +31,7 @@ class APIProvider {
Future<YamlMap> getTemplateFile() async {
final response = await httpClient.get(Uri.parse(
'https://raw.githubusercontent.com/flutter/flutter/master/packages/flutter_tools/templates/app_shared/analysis_options.yaml.tmpl'));
'https://raw.githubusercontent.com/flutter/flutter/main/packages/flutter_tools/templates/app_shared/analysis_options.yaml.tmpl'));
if (response.statusCode == 200) {
return loadYaml(response.body) as YamlMap;
} else {

View File

@@ -79,11 +79,11 @@ class _LintExpansionTileState extends State<LintExpansionTile> {
TextSpan(
children: [
TextSpan(
text: 'Maturity:',
text: 'State:',
style: textTheme.titleSmall,
),
TextSpan(
text: ' ${rule.maturity}',
text: ' ${rule.state}',
),
],
),

View File

@@ -101,11 +101,11 @@ class _SavedRuleTileState extends State<SavedRuleTile> {
TextSpan(
children: [
TextSpan(
text: 'Maturity:',
text: 'State:',
style: textTheme.titleSmall,
),
TextSpan(
text: ' ${rule.maturity}',
text: ' ${rule.state}',
),
],
),

View File

@@ -21,7 +21,7 @@ dependencies:
hive_flutter: ^1.1.0
http: ^1.0.0
json2yaml: ^3.0.0
json_annotation: ^4.5.0
json_annotation: ^4.8.1
mockito: ^5.0.13
provider: ^6.0.2
yaml: ^3.1.0
@@ -36,9 +36,9 @@ dev_dependencies:
path: ../../analysis_defaults
flutter_test:
sdk: flutter
build_runner: ^2.0.6
build_runner: ^2.4.6
hive_generator: ^2.0.0
json_serializable: ^6.2.0
json_serializable: ^6.7.1
flutter:
uses-material-design: true

View File

@@ -72,10 +72,10 @@ void main() {
testWidgets('NavigationRail smoke test', (tester) async {
var responseBody =
'''[{"name": "always_use_package_imports","description": "Avoid relative imports for files in `lib/`.","group": "errors","maturity": "stable","incompatible": [],"sets": [],"details": "*DO* avoid relative imports for files in `lib/`.\n\nWhen mixing relative and absolute imports it's possible to create confusion\nwhere the same member gets imported in two different ways. One way to avoid\nthat is to ensure you consistently use absolute imports for files withing the\n`lib/` directory.\n\nThis is the opposite of 'prefer_relative_imports'.\nMight be used with 'avoid_relative_lib_imports' to avoid relative imports of\nfiles within `lib/` directory outside of it. (for example `test/`)\n\n**GOOD:**\n\n```dart\nimport 'package:foo/bar.dart';\n\nimport 'package:foo/baz.dart';\n\nimport 'package:foo/src/baz.dart';\n...\n```\n\n**BAD:**\n\n```dart\nimport 'baz.dart';\n\nimport 'src/bag.dart'\n\nimport '../lib/baz.dart';\n\n...\n```\n\n"}]''';
'''[{"name": "always_use_package_imports","description": "Avoid relative imports for files in `lib/`.","group": "errors","state": "stable","incompatible": [],"sets": [],"details": "*DO* avoid relative imports for files in `lib/`.\n\nWhen mixing relative and absolute imports it's possible to create confusion\nwhere the same member gets imported in two different ways. One way to avoid\nthat is to ensure you consistently use absolute imports for files withing the\n`lib/` directory.\n\nThis is the opposite of 'prefer_relative_imports'.\nMight be used with 'avoid_relative_lib_imports' to avoid relative imports of\nfiles within `lib/` directory outside of it. (for example `test/`)\n\n**GOOD:**\n\n```dart\nimport 'package:foo/bar.dart';\n\nimport 'package:foo/baz.dart';\n\nimport 'package:foo/src/baz.dart';\n...\n```\n\n**BAD:**\n\n```dart\nimport 'baz.dart';\n\nimport 'src/bag.dart'\n\nimport '../lib/baz.dart';\n\n...\n```\n\n"}]''';
when(_mockClient.get(Uri.parse(
'https://dart-lang.github.io/linter//lints/machine/rules.json')))
'https://dart-lang.github.io/linter/lints/machine/rules.json')))
.thenAnswer(
(_) async => http.Response(responseBody, 400),
);

View File

@@ -1,15 +1,13 @@
// Mocks generated by Mockito 5.2.0 from annotations
// Mocks generated by Mockito 5.4.2 from annotations
// in linting_tool/test/widget_test.dart.
// Do not manually edit this file.
import 'dart:async' as _i5;
import 'dart:convert' as _i6;
import 'dart:typed_data' as _i7;
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'dart:async' as _i3;
import 'dart:convert' as _i4;
import 'dart:typed_data' as _i5;
import 'package:http/src/base_request.dart' as _i8;
import 'package:http/src/client.dart' as _i4;
import 'package:http/src/response.dart' as _i2;
import 'package:http/src/streamed_response.dart' as _i3;
import 'package:http/http.dart' as _i2;
import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: type=lint
@@ -21,88 +19,245 @@ import 'package:mockito/mockito.dart' as _i1;
// ignore_for_file: prefer_const_constructors
// ignore_for_file: unnecessary_parenthesis
// ignore_for_file: camel_case_types
// ignore_for_file: subtype_of_sealed_class
class _FakeResponse_0 extends _i1.Fake implements _i2.Response {}
class _FakeResponse_0 extends _i1.SmartFake implements _i2.Response {
_FakeResponse_0(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
class _FakeStreamedResponse_1 extends _i1.Fake
implements _i3.StreamedResponse {}
class _FakeStreamedResponse_1 extends _i1.SmartFake
implements _i2.StreamedResponse {
_FakeStreamedResponse_1(
Object parent,
Invocation parentInvocation,
) : super(
parent,
parentInvocation,
);
}
/// A class which mocks [Client].
///
/// See the documentation for Mockito's code generation for more information.
class MockClient extends _i1.Mock implements _i4.Client {
class MockClient extends _i1.Mock implements _i2.Client {
MockClient() {
_i1.throwOnMissingStub(this);
}
@override
_i5.Future<_i2.Response> head(Uri? url, {Map<String, String>? headers}) =>
(super.noSuchMethod(Invocation.method(#head, [url], {#headers: headers}),
returnValue: Future<_i2.Response>.value(_FakeResponse_0()))
as _i5.Future<_i2.Response>);
_i3.Future<_i2.Response> head(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(
#head,
[url],
{#headers: headers},
),
returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#head,
[url],
{#headers: headers},
),
)),
) as _i3.Future<_i2.Response>);
@override
_i5.Future<_i2.Response> get(Uri? url, {Map<String, String>? headers}) =>
(super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}),
returnValue: Future<_i2.Response>.value(_FakeResponse_0()))
as _i5.Future<_i2.Response>);
_i3.Future<_i2.Response> get(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(
#get,
[url],
{#headers: headers},
),
returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#get,
[url],
{#headers: headers},
),
)),
) as _i3.Future<_i2.Response>);
@override
_i5.Future<_i2.Response> post(Uri? url,
{Map<String, String>? headers,
_i3.Future<_i2.Response> post(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i6.Encoding? encoding}) =>
_i4.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(#post, [url],
{#headers: headers, #body: body, #encoding: encoding}),
returnValue: Future<_i2.Response>.value(_FakeResponse_0()))
as _i5.Future<_i2.Response>);
Invocation.method(
#post,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#post,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i3.Future<_i2.Response>);
@override
_i5.Future<_i2.Response> put(Uri? url,
{Map<String, String>? headers,
_i3.Future<_i2.Response> put(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i6.Encoding? encoding}) =>
_i4.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(#put, [url],
{#headers: headers, #body: body, #encoding: encoding}),
returnValue: Future<_i2.Response>.value(_FakeResponse_0()))
as _i5.Future<_i2.Response>);
Invocation.method(
#put,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#put,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i3.Future<_i2.Response>);
@override
_i5.Future<_i2.Response> patch(Uri? url,
{Map<String, String>? headers,
_i3.Future<_i2.Response> patch(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i6.Encoding? encoding}) =>
_i4.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(#patch, [url],
{#headers: headers, #body: body, #encoding: encoding}),
returnValue: Future<_i2.Response>.value(_FakeResponse_0()))
as _i5.Future<_i2.Response>);
Invocation.method(
#patch,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#patch,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i3.Future<_i2.Response>);
@override
_i5.Future<_i2.Response> delete(Uri? url,
{Map<String, String>? headers,
_i3.Future<_i2.Response> delete(
Uri? url, {
Map<String, String>? headers,
Object? body,
_i6.Encoding? encoding}) =>
_i4.Encoding? encoding,
}) =>
(super.noSuchMethod(
Invocation.method(#delete, [url],
{#headers: headers, #body: body, #encoding: encoding}),
returnValue: Future<_i2.Response>.value(_FakeResponse_0()))
as _i5.Future<_i2.Response>);
Invocation.method(
#delete,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
returnValue: _i3.Future<_i2.Response>.value(_FakeResponse_0(
this,
Invocation.method(
#delete,
[url],
{
#headers: headers,
#body: body,
#encoding: encoding,
},
),
)),
) as _i3.Future<_i2.Response>);
@override
_i5.Future<String> read(Uri? url, {Map<String, String>? headers}) =>
(super.noSuchMethod(Invocation.method(#read, [url], {#headers: headers}),
returnValue: Future<String>.value('')) as _i5.Future<String>);
@override
_i5.Future<_i7.Uint8List> readBytes(Uri? url,
{Map<String, String>? headers}) =>
_i3.Future<String> read(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(#readBytes, [url], {#headers: headers}),
returnValue: Future<_i7.Uint8List>.value(_i7.Uint8List(0)))
as _i5.Future<_i7.Uint8List>);
Invocation.method(
#read,
[url],
{#headers: headers},
),
returnValue: _i3.Future<String>.value(''),
) as _i3.Future<String>);
@override
_i5.Future<_i3.StreamedResponse> send(_i8.BaseRequest? request) =>
(super.noSuchMethod(Invocation.method(#send, [request]),
_i3.Future<_i5.Uint8List> readBytes(
Uri? url, {
Map<String, String>? headers,
}) =>
(super.noSuchMethod(
Invocation.method(
#readBytes,
[url],
{#headers: headers},
),
returnValue: _i3.Future<_i5.Uint8List>.value(_i5.Uint8List(0)),
) as _i3.Future<_i5.Uint8List>);
@override
_i3.Future<_i2.StreamedResponse> send(_i2.BaseRequest? request) =>
(super.noSuchMethod(
Invocation.method(
#send,
[request],
),
returnValue:
Future<_i3.StreamedResponse>.value(_FakeStreamedResponse_1()))
as _i5.Future<_i3.StreamedResponse>);
_i3.Future<_i2.StreamedResponse>.value(_FakeStreamedResponse_1(
this,
Invocation.method(
#send,
[request],
),
)),
) as _i3.Future<_i2.StreamedResponse>);
@override
void close() => super.noSuchMethod(Invocation.method(#close, []),
returnValueForMissingStub: null);
void close() => super.noSuchMethod(
Invocation.method(
#close,
[],
),
returnValueForMissingStub: null,
);
}