Skip to content

Commit c573859

Browse files
authored
Minor cleanup to lints and some top level files (#2872)
1 parent e00f32f commit c573859

19 files changed

+67
-73
lines changed

analysis_options.yaml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,14 @@ analyzer:
1919
- 'testing/test_package_export_error/**'
2020
linter:
2121
rules:
22-
always_declare_return_types: true
23-
avoid_dynamic_calls: true
24-
avoid_single_cascade_in_expression_statements: true
25-
avoid_unused_constructor_parameters: true
26-
avoid_init_to_null: true
27-
directives_ordering: true
28-
no_adjacent_strings_in_list: true
29-
package_api_docs: true
30-
prefer_final_fields: true
31-
prefer_initializing_formals: true
32-
prefer_void_to_null: true
33-
slash_for_doc_comments: true
34-
type_annotate_public_apis: true
35-
# Work in progress canonical score lints
36-
unawaited_futures: true
22+
- always_declare_return_types
23+
- always_put_required_named_parameters_first
24+
- avoid_bool_literals_in_conditional_expressions
25+
- avoid_unused_constructor_parameters
26+
- directives_ordering
27+
- no_adjacent_strings_in_list
28+
- package_api_docs
29+
- prefer_single_quotes
30+
- sort_child_properties_last
31+
- unawaited_futures
32+
- unnecessary_null_aware_assignments

analysis_options_presubmit.yaml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@ analyzer:
2424
- 'testing/test_package_export_error/**'
2525
linter:
2626
rules:
27-
always_declare_return_types: true
28-
avoid_dynamic_calls: true
29-
avoid_single_cascade_in_expression_statements: true
30-
avoid_unused_constructor_parameters: true
31-
avoid_init_to_null: true
32-
directives_ordering: true
33-
no_adjacent_strings_in_list: true
34-
package_api_docs: true
35-
prefer_final_fields: true
36-
prefer_initializing_formals: true
37-
prefer_void_to_null: true
38-
slash_for_doc_comments: true
39-
type_annotate_public_apis: true
40-
# Work in progress canonical score lints
41-
unawaited_futures: true
27+
- always_declare_return_types
28+
- always_put_required_named_parameters_first
29+
- avoid_bool_literals_in_conditional_expressions
30+
- avoid_unused_constructor_parameters
31+
- directives_ordering
32+
- no_adjacent_strings_in_list
33+
- package_api_docs
34+
- prefer_single_quotes
35+
- sort_child_properties_last
36+
- unawaited_futures
37+
- unnecessary_null_aware_assignments

lib/src/comment_references/parser.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ class StringTrie {
4848
return valid ? index : lastValid;
4949
}
5050
var matchChar = toMatch.codeUnitAt(index);
51-
if (children.containsKey(matchChar)) {
51+
var matchedChild = children[matchChar];
52+
if (matchedChild != null) {
5253
lastValid = valid ? index : lastValid;
53-
return children[matchChar]!.match(toMatch, index + 1, lastValid);
54+
return matchedChild.match(toMatch, index + 1, lastValid);
5455
}
5556
return valid ? index : lastValid;
5657
}
@@ -65,7 +66,7 @@ class StringTrie {
6566
}
6667
}
6768

68-
late final StringTrie operatorParseTrie = () {
69+
final StringTrie operatorParseTrie = () {
6970
var _operatorParseTrie = StringTrie();
7071
for (var name in operatorNames.keys) {
7172
_operatorParseTrie.addWord(name);

lib/src/dartdoc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class Dartdoc {
352352
var stringLinks = links
353353
.map((link) => link.attributes['href'])
354354
.whereType<String>()
355-
.where((href) => href != '')
355+
.where((href) => href.isNotEmpty)
356356
.toList();
357357

358358
return Tuple2(stringLinks, baseHref);

lib/src/dartdoc_options.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,13 +1467,15 @@ Future<List<DartdocOption>> createDartdocOptions(
14671467
// ignore: unnecessary_null_comparison
14681468
if (inSdk != null) {
14691469
Map<String, String> sdks = option.parent['sdks'].valueAt(dir);
1470-
if (sdks.containsKey(inSdk)) return sdks[inSdk]!;
1470+
var inSdkVal = sdks[inSdk];
1471+
if (inSdkVal != null) return inSdkVal;
14711472
}
14721473
var hostedAt = packageMeta.hostedAt;
14731474
// ignore: unnecessary_null_comparison
14741475
if (hostedAt != null) {
14751476
Map<String, String> hostMap = option.parent['hosted'].valueAt(dir);
1476-
if (hostMap.containsKey(hostedAt)) return hostMap[hostedAt]!;
1477+
var hostedAtVal = hostMap[hostedAt];
1478+
if (hostedAtVal != null) return hostedAtVal;
14771479
}
14781480
return '';
14791481
}, resourceProvider, help: 'Url to use for this particular package.'),

lib/src/element_type.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class ParameterizedElementType extends DefinedElementType with Rendered {
227227
.toList(growable: false);
228228
}
229229

230-
/// A [ElementType] whose underlying type was referrred to by a type alias.
230+
/// A [ElementType] whose underlying type was referred to by a type alias.
231231
mixin Aliased implements ElementType, ModelBuilderInterface {
232232
late final Element typeAliasElement = type.alias!.element;
233233

lib/src/model/comment_referable.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extension on Scope {
3939

4040
/// A set of utility methods for helping build
4141
/// [CommentReferable.referenceChildren] out of collections of other
42-
/// [CommmentReferable]s.
42+
/// [CommentReferable]s.
4343
extension CommentReferableEntryGenerators on Iterable<CommentReferable> {
4444
/// Creates ordinary references except if there is a conflict with
4545
/// [referable], it will generate a [MapEntry] using [referable]'s

lib/src/model/getter_setter_combo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ mixin GetterSetterCombo on ModelElement {
154154
buffer.write(getter!.oneLineDoc);
155155
}
156156
if (hasPublicSetter && setter!.oneLineDoc!.isNotEmpty) {
157-
buffer.write(getterSetterBothAvailable ? "" : setter!.oneLineDoc);
157+
buffer.write(getterSetterBothAvailable ? '' : setter!.oneLineDoc);
158158
}
159159
_oneLineDoc = buffer.toString();
160160
}

lib/src/model/model_element.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ abstract class ModelElement extends Canonicalization
157157
/// if and only if this is to be an inherited or extended object.
158158
factory ModelElement._fromPropertyInducingElement(
159159
PropertyInducingElement e, Library library, PackageGraph packageGraph,
160-
{Container? enclosingContainer,
161-
required Accessor? getter,
162-
required Accessor? setter}) {
160+
{required Accessor? getter,
161+
required Accessor? setter,
162+
Container? enclosingContainer}) {
163163
// TODO(jcollins-g): Refactor object model to instantiate 'ModelMembers'
164164
// for members?
165165
if (e is Member) {

lib/src/model/model_object_builder.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ abstract class ModelElementBuilder {
2020
ModelElement fromElement(Element e);
2121

2222
ModelElement fromPropertyInducingElement(Element e, Library l,
23-
{Container enclosingContainer,
24-
required Accessor? getter,
25-
required Accessor? setter});
23+
{required Accessor? getter,
24+
required Accessor? setter,
25+
Container enclosingContainer});
2626
}
2727

2828
abstract class ElementTypeBuilder {

0 commit comments

Comments
 (0)