From 4cacd2156c856e28051b45242ab676e805497fea Mon Sep 17 00:00:00 2001 From: Igor Borges Date: Tue, 24 Dec 2019 21:39:07 -0300 Subject: [PATCH] Fix some linter tips, ignore tests --- analysis_options.yaml | 1 + lib/client.dart | 2 +- lib/generator.dart | 11 +++++------ lib/generator/data.dart | 4 ++-- lib/generator/helpers.dart | 8 ++++---- lib/generator/print_helpers.dart | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index a41910a9..f2b5d84e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -7,6 +7,7 @@ analyzer: implicit-casts: false exclude: - example/**/*.dart + - test/**/*.dart linter: rules: - public_member_api_docs diff --git a/lib/client.dart b/lib/client.dart index 248aba69..68a7fdda 100644 --- a/lib/client.dart +++ b/lib/client.dart @@ -49,7 +49,7 @@ class ArtemisClient { variables: query.getVariablesMap(), ); - final Response response = await _link.request(request).first; + final response = await _link.request(request).first; return GraphQLResponse( data: response.data == null ? null : query.parse(response.data), diff --git a/lib/generator.dart b/lib/generator.dart index f1ad683f..75e8d4fe 100644 --- a/lib/generator.dart +++ b/lib/generator.dart @@ -33,8 +33,7 @@ You may want to do either: }); final basename = p.basenameWithoutExtension(path); - final List customImports = - _extractCustomImports(schema.types, options); + final customImports = _extractCustomImports(schema.types, options); return LibraryDefinition( basename, queries: queriesDefinitions, @@ -69,18 +68,18 @@ QueryDefinition generateQuery( final queryName = operation.name?.value ?? basename; final className = ReCase(queryName).pascalCase; - GraphQLType parentType = gql.getTypeByName(schema, schema.queryType.name); + var parentType = gql.getTypeByName(schema, schema.queryType.name); if (operation.type == OperationType.mutation) { parentType = gql.getTypeByName(schema, schema.mutationType.name); } final prefix = schemaMap.addQueryPrefix ? className : ''; - final List inputs = []; - final List inputsClasses = []; + final inputs = []; + final inputsClasses = []; if (operation.variableDefinitions != null) { operation.variableDefinitions.forEach((v) { - NamedTypeNode unwrappedType = _unwrapType(v.type); + final unwrappedType = _unwrapType(v.type); final type = gql.getTypeByName(schema, unwrappedType.name.value); diff --git a/lib/generator/data.dart b/lib/generator/data.dart index 0f060185..cfb79f23 100644 --- a/lib/generator/data.dart +++ b/lib/generator/data.dart @@ -5,10 +5,10 @@ import 'package:recase/recase.dart'; import '../schema/graphql.dart'; /// Callback fired when the generator processes a [LibraryDefinition]. -typedef void OnBuildQuery(LibraryDefinition definition); +typedef OnBuildQuery = void Function(LibraryDefinition definition); /// Callback fired when a new class is found during schema parsing. -typedef void OnNewClassFoundCallback( +typedef OnNewClassFoundCallback = void Function( SelectionSetNode selectionSet, String className, GraphQLType parentType, diff --git a/lib/generator/helpers.dart b/lib/generator/helpers.dart index e4642c00..c421bd27 100644 --- a/lib/generator/helpers.dart +++ b/lib/generator/helpers.dart @@ -1,11 +1,11 @@ -typedef U _IterableFunction(T i); -typedef T _MergeableFunction(T oldT, T newT); +typedef _IterableFunction = U Function(T i); +typedef _MergeableFunction = T Function(T oldT, T newT); /// Remove duplicated values from an iterable given a predicate without /// modifying the original iterable. Iterable removeDuplicatedBy( Iterable list, _IterableFunction fn) { - final values = Map(); + final values = {}; return list.where((i) { final value = fn(i); return values.update(value, (_) => false, ifAbsent: () => true); @@ -16,7 +16,7 @@ Iterable removeDuplicatedBy( /// the original iterable. Iterable mergeDuplicatesBy(Iterable list, _IterableFunction fn, _MergeableFunction mergeFn) { - final values = Map(); + final values = {}; list.forEach((i) { final value = fn(i); values.update(value, (oldI) => mergeFn(oldI, i), ifAbsent: () => i); diff --git a/lib/generator/print_helpers.dart b/lib/generator/print_helpers.dart index 62e01465..04385b96 100644 --- a/lib/generator/print_helpers.dart +++ b/lib/generator/print_helpers.dart @@ -201,7 +201,7 @@ Spec generateArgumentClassSpec(QueryDefinition definition) { /// Generates a [Spec] of a query/mutation class. Spec generateQueryClassSpec(QueryDefinition definition) { - final String typeDeclaration = definition.inputs.isEmpty + final typeDeclaration = definition.inputs.isEmpty ? '${definition.className}, JsonSerializable' : '${definition.className}, ${definition.className}Arguments';