Skip to content

Commit

Permalink
more linting (dart-lang#1825)
Browse files Browse the repository at this point in the history
* + lints

* type fix
  • Loading branch information
pq authored Nov 7, 2019
1 parent 0825bcf commit 2c284c2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
7 changes: 5 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ linter:
- prefer_expression_function_bodies
- prefer_final_fields
# - prefer_final_locals
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
# - prefer_function_declarations_over_variables
# - prefer_generic_function_type_aliases # under review (see #1068)
- prefer_generic_function_type_aliases
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
- prefer_interpolation_to_compose_strings
Expand All @@ -97,7 +99,8 @@ linter:
- prefer_single_quotes
- prefer_spread_collections
# - prefer_typing_uninitialized_variables # under review (see #1068)
# - prefer_void_to_null # under review (see #1068)
- prefer_void_to_null
- provide_deprecation_message
# - public_member_api_docs
# - sort_constructors_first
# - sort_unnamed_constructors_first
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ AstNode _getNodeToAnnotate(Declaration node) {

/// An [Element] processor function type.
/// If `true` is returned, children of [element] will be visited.
typedef bool ElementProcessor(Element element);
typedef ElementProcessor = bool Function(Element element);

class HasConstErrorListener extends AnalysisErrorListener {
static const List<CompileTimeErrorCode> errorCodes = [
Expand Down
2 changes: 1 addition & 1 deletion lib/src/util/dart_type_utilities.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_system.dart';
import 'package:analyzer/src/dart/element/member.dart'; // ignore: implementation_imports

typedef bool AstNodePredicate(AstNode node);
typedef AstNodePredicate = bool Function(AstNode node);

class DartTypeUtilities {
static bool extendsClass(DartType type, String className, String library) =>
Expand Down
8 changes: 4 additions & 4 deletions lib/src/util/leak_detector_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ bool _isSimpleIdentifierElementEqualToVariable(
(n.staticElement as PropertyAccessorElement).variable ==
variable.name.staticElement));

typedef bool DartTypePredicate(DartType type);
typedef DartTypePredicate = bool Function(DartType type);

typedef bool _Predicate(AstNode node);
typedef _Predicate = bool Function(AstNode node);

typedef _Predicate _PredicateBuilder(VariableDeclaration v);
typedef _PredicateBuilder = _Predicate Function(VariableDeclaration v);

typedef void _VisitVariableDeclaration(VariableDeclaration node);
typedef _VisitVariableDeclaration = void Function(VariableDeclaration node);

abstract class LeakDetectorProcessors extends SimpleAstVisitor<void> {
static final _variablePredicateBuilders = <_PredicateBuilder>[_hasReturn];
Expand Down
2 changes: 1 addition & 1 deletion lib/src/util/tested_expressions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool _sameOperands(String eLeftOperand, String bcLeftOperand,
return sameOperandsSameOrder || sameOperandsInverted;
}

typedef void _RecurseCallback(Expression expression);
typedef _RecurseCallback = void Function(Expression expression);

class ContradictoryComparisons {
final Expression first;
Expand Down
2 changes: 1 addition & 1 deletion test/engine_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void defineLinterEngineTests() {
});
}

typedef NodeVisitor(node);
typedef NodeVisitor = void Function(Object node);

class MockLinter extends LintRule {
final NodeVisitor nodeVisitor;
Expand Down
2 changes: 1 addition & 1 deletion tool/rule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,4 @@ String _generateTest(String libName, String className) => '''
''';

typedef String _Generator(String libName, String className);
typedef _Generator = String Function(String libName, String className);

0 comments on commit 2c284c2

Please sign in to comment.