Commit 35803c22 authored by Alexandre Ardhuin's avatar Alexandre Ardhuin Committed by GitHub

comprehensive list of lints (#9330)

* comprehensive list of lints
* add comments to commented out lint
* fix unnecessary_this lints
* exclude prefer_final_fields
parent 96d8a2a3
...@@ -54,9 +54,11 @@ linter: ...@@ -54,9 +54,11 @@ linter:
- empty_statements - empty_statements
- hash_and_equals - hash_and_equals
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790 # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
# - iterable_contains_unrelated_type - iterable_contains_unrelated_type
- list_remove_unrelated_type - list_remove_unrelated_type
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791 # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
- no_adjacent_strings_in_list
- no_duplicate_case_values
- test_types_in_equals - test_types_in_equals
- throw_in_finally - throw_in_finally
- unrelated_type_equality_checks - unrelated_type_equality_checks
...@@ -67,10 +69,12 @@ linter: ...@@ -67,10 +69,12 @@ linter:
- always_specify_types - always_specify_types
- annotate_overrides - annotate_overrides
- avoid_as - avoid_as
# - avoid_function_literals_in_foreach_calls # not yet tested
- avoid_init_to_null - avoid_init_to_null
- avoid_return_types_on_setters - avoid_return_types_on_setters
- await_only_futures - await_only_futures
- camel_case_types - camel_case_types
# - cascade_invocations # not yet tested
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
- directives_ordering - directives_ordering
- empty_catches - empty_catches
...@@ -78,24 +82,28 @@ linter: ...@@ -78,24 +82,28 @@ linter:
- implementation_imports - implementation_imports
- library_names - library_names
- library_prefixes - library_prefixes
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names - non_constant_identifier_names
# - omit_local_variable_types # opposite of always_specify_types
# - one_member_abstracts # too many false positives # - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
# - overridden_fields # - overridden_fields # not yet tested
- package_api_docs - package_api_docs
- package_prefixed_library_names - package_prefixed_library_names
# - parameter_assignments # we do this commonly # - parameter_assignments # we do this commonly
# - prefer_final_fields # https://github.com/dart-lang/sdk/issues/29197 # - prefer_adjacent_string_concatenation # not yet tested
- prefer_collection_literals - prefer_collection_literals
- prefer_const_constructors - prefer_const_constructors
- prefer_contains - prefer_contains
# - prefer_expression_function_bodies # not yet tested
# - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
- prefer_final_locals - prefer_final_locals
# - prefer_function_declarations_over_variables # not yet tested
- prefer_initializing_formals - prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
- prefer_is_empty - prefer_is_empty
- prefer_is_not_empty - prefer_is_not_empty
# - public_member_api_docs # this is the only difference from .analysis_options_repo # - public_member_api_docs # this is the only difference from .analysis_options_repo
# - recursive_getters # https://github.com/dart-lang/linter/issues/452
- slash_for_doc_comments - slash_for_doc_comments
- sort_constructors_first - sort_constructors_first
- sort_unnamed_constructors_first - sort_unnamed_constructors_first
...@@ -103,10 +111,12 @@ linter: ...@@ -103,10 +111,12 @@ linter:
# - type_annotate_public_apis # subset of always_specify_types # - type_annotate_public_apis # subset of always_specify_types
- type_init_formals - type_init_formals
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
- unnecessary_brace_in_string_interp - unnecessary_brace_in_string_interps
- unnecessary_getters_setters - unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
- unnecessary_null_aware_assignments - unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators - unnecessary_null_in_if_null_operators
- unnecessary_this
# === pub rules === # === pub rules ===
- package_names - package_names
...@@ -52,9 +52,11 @@ linter: ...@@ -52,9 +52,11 @@ linter:
- empty_statements - empty_statements
- hash_and_equals - hash_and_equals
# - invariant_booleans # https://github.com/flutter/flutter/issues/5790 # - invariant_booleans # https://github.com/flutter/flutter/issues/5790
# - iterable_contains_unrelated_type - iterable_contains_unrelated_type
- list_remove_unrelated_type - list_remove_unrelated_type
# - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791 # - literal_only_boolean_expressions # https://github.com/flutter/flutter/issues/5791
- no_adjacent_strings_in_list
- no_duplicate_case_values
- test_types_in_equals - test_types_in_equals
- throw_in_finally - throw_in_finally
- unrelated_type_equality_checks - unrelated_type_equality_checks
...@@ -65,10 +67,12 @@ linter: ...@@ -65,10 +67,12 @@ linter:
- always_specify_types - always_specify_types
- annotate_overrides - annotate_overrides
- avoid_as - avoid_as
# - avoid_function_literals_in_foreach_calls # not yet tested
- avoid_init_to_null - avoid_init_to_null
- avoid_return_types_on_setters - avoid_return_types_on_setters
- await_only_futures - await_only_futures
- camel_case_types - camel_case_types
# - cascade_invocations # not yet tested
# - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204
- directives_ordering - directives_ordering
- empty_catches - empty_catches
...@@ -76,24 +80,28 @@ linter: ...@@ -76,24 +80,28 @@ linter:
- implementation_imports - implementation_imports
- library_names - library_names
- library_prefixes - library_prefixes
- no_adjacent_strings_in_list
- no_duplicate_case_values
- non_constant_identifier_names - non_constant_identifier_names
# - omit_local_variable_types # opposite of always_specify_types
# - one_member_abstracts # too many false positives # - one_member_abstracts # too many false positives
# - only_throw_errors # https://github.com/flutter/flutter/issues/5792 # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
# - overridden_fields # - overridden_fields # not yet tested
- package_api_docs - package_api_docs
- package_prefixed_library_names - package_prefixed_library_names
# - parameter_assignments # we do this commonly # - parameter_assignments # we do this commonly
# - prefer_final_fields # https://github.com/dart-lang/sdk/issues/29197 # - prefer_adjacent_string_concatenation # not yet tested
- prefer_collection_literal - prefer_collection_literals
- prefer_const_constructors - prefer_const_constructors
- prefer_contains - prefer_contains
# - prefer_expression_function_bodies # not yet tested
# - prefer_final_fields # https://github.com/dart-lang/linter/issues/506
- prefer_final_locals - prefer_final_locals
# - prefer_function_declarations_over_variables # not yet tested
- prefer_initializing_formals - prefer_initializing_formals
# - prefer_interpolation_to_compose_strings # not yet tested
- prefer_is_empty - prefer_is_empty
- prefer_is_not_empty - prefer_is_not_empty
- public_member_api_docs # this is the only difference from .analysis_options # - public_member_api_docs # this is the only difference from .analysis_options_repo
# - recursive_getters # https://github.com/dart-lang/linter/issues/452
- slash_for_doc_comments - slash_for_doc_comments
- sort_constructors_first - sort_constructors_first
- sort_unnamed_constructors_first - sort_unnamed_constructors_first
...@@ -103,8 +111,10 @@ linter: ...@@ -103,8 +111,10 @@ linter:
# - unawaited_futures # https://github.com/flutter/flutter/issues/5793 # - unawaited_futures # https://github.com/flutter/flutter/issues/5793
- unnecessary_brace_in_string_interps - unnecessary_brace_in_string_interps
- unnecessary_getters_setters - unnecessary_getters_setters
# - unnecessary_lambdas # https://github.com/dart-lang/linter/issues/498
- unnecessary_null_aware_assignments - unnecessary_null_aware_assignments
- unnecessary_null_in_if_null_operators - unnecessary_null_in_if_null_operators
- unnecessary_this
# === pub rules === # === pub rules ===
- package_names - package_names
...@@ -40,13 +40,13 @@ abstract class AnalyzerTask { ...@@ -40,13 +40,13 @@ abstract class AnalyzerTask {
class AnalyzerCliTask extends AnalyzerTask { class AnalyzerCliTask extends AnalyzerTask {
AnalyzerCliTask(String sdk, String commit, DateTime timestamp) { AnalyzerCliTask(String sdk, String commit, DateTime timestamp) {
this.benchmark = new FlutterAnalyzeBenchmark(sdk, commit, timestamp); benchmark = new FlutterAnalyzeBenchmark(sdk, commit, timestamp);
} }
} }
class AnalyzerServerTask extends AnalyzerTask { class AnalyzerServerTask extends AnalyzerTask {
AnalyzerServerTask(String sdk, String commit, DateTime timestamp) { AnalyzerServerTask(String sdk, String commit, DateTime timestamp) {
this.benchmark = new FlutterAnalyzeAppBenchmark(sdk, commit, timestamp); benchmark = new FlutterAnalyzeAppBenchmark(sdk, commit, timestamp);
} }
} }
......
...@@ -282,12 +282,12 @@ class RenderSectorRing extends RenderSectorWithChildren { ...@@ -282,12 +282,12 @@ class RenderSectorRing extends RenderSectorWithChildren {
@override @override
void performLayout() { void performLayout() {
assert(this.parentData is SectorParentData); assert(parentData is SectorParentData);
deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius); deltaRadius = constraints.constrainDeltaRadius(desiredDeltaRadius);
assert(deltaRadius < double.INFINITY); assert(deltaRadius < double.INFINITY);
final double innerDeltaRadius = deltaRadius - padding * 2.0; final double innerDeltaRadius = deltaRadius - padding * 2.0;
final double childRadius = this.parentData.radius + padding; final double childRadius = parentData.radius + padding;
final double paddingTheta = math.atan(padding / (this.parentData.radius + deltaRadius)); final double paddingTheta = math.atan(padding / (parentData.radius + deltaRadius));
double innerTheta = paddingTheta; // increments with each child double innerTheta = paddingTheta; // increments with each child
double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta); double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta);
RenderSector child = firstChild; RenderSector child = firstChild;
...@@ -367,11 +367,11 @@ class RenderSectorSlice extends RenderSectorWithChildren { ...@@ -367,11 +367,11 @@ class RenderSectorSlice extends RenderSectorWithChildren {
@override @override
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
assert(this.parentData is SectorParentData); assert(parentData is SectorParentData);
final double paddingTheta = math.atan(padding / this.parentData.radius); final double paddingTheta = math.atan(padding / parentData.radius);
final double outerDeltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta); final double outerDeltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
final double innerDeltaTheta = outerDeltaTheta - paddingTheta * 2.0; final double innerDeltaTheta = outerDeltaTheta - paddingTheta * 2.0;
double childRadius = this.parentData.radius + padding; double childRadius = parentData.radius + padding;
double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0);
RenderSector child = firstChild; RenderSector child = firstChild;
while (child != null) { while (child != null) {
...@@ -388,19 +388,19 @@ class RenderSectorSlice extends RenderSectorWithChildren { ...@@ -388,19 +388,19 @@ class RenderSectorSlice extends RenderSectorWithChildren {
remainingDeltaRadius -= padding; remainingDeltaRadius -= padding;
} }
return new SectorDimensions.withConstraints(constraints, return new SectorDimensions.withConstraints(constraints,
deltaRadius: childRadius - this.parentData.radius, deltaRadius: childRadius - parentData.radius,
deltaTheta: outerDeltaTheta); deltaTheta: outerDeltaTheta);
} }
@override @override
void performLayout() { void performLayout() {
assert(this.parentData is SectorParentData); assert(parentData is SectorParentData);
deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta); deltaTheta = constraints.constrainDeltaTheta(desiredDeltaTheta);
assert(deltaTheta <= kTwoPi); assert(deltaTheta <= kTwoPi);
final double paddingTheta = math.atan(padding / this.parentData.radius); final double paddingTheta = math.atan(padding / parentData.radius);
final double innerTheta = this.parentData.theta + paddingTheta; final double innerTheta = parentData.theta + paddingTheta;
final double innerDeltaTheta = deltaTheta - paddingTheta * 2.0; final double innerDeltaTheta = deltaTheta - paddingTheta * 2.0;
double childRadius = this.parentData.radius + padding; double childRadius = parentData.radius + padding;
double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0);
RenderSector child = firstChild; RenderSector child = firstChild;
while (child != null) { while (child != null) {
...@@ -418,7 +418,7 @@ class RenderSectorSlice extends RenderSectorWithChildren { ...@@ -418,7 +418,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
childRadius += padding; childRadius += padding;
remainingDeltaRadius -= padding; remainingDeltaRadius -= padding;
} }
deltaRadius = childRadius - this.parentData.radius; deltaRadius = childRadius - parentData.radius;
} }
// offset must point to the center of our circle // offset must point to the center of our circle
......
...@@ -600,8 +600,8 @@ abstract class CompoundAnimation<T> extends Animation<T> ...@@ -600,8 +600,8 @@ abstract class CompoundAnimation<T> extends Animation<T>
T _lastValue; T _lastValue;
void _maybeNotifyListeners() { void _maybeNotifyListeners() {
if (this.value != _lastValue) { if (value != _lastValue) {
_lastValue = this.value; _lastValue = value;
notifyListeners(); notifyListeners();
} }
} }
......
...@@ -1769,7 +1769,7 @@ abstract class RenderBox extends RenderObject { ...@@ -1769,7 +1769,7 @@ abstract class RenderBox extends RenderObject {
throw new FlutterError( throw new FlutterError(
'$runtimeType does not implement applyPaintTransform.\n' '$runtimeType does not implement applyPaintTransform.\n'
'The following $runtimeType object:\n' 'The following $runtimeType object:\n'
' ${this.toStringShallow()}\n' ' ${toStringShallow()}\n'
'...did not use a BoxParentData class for the parentData field of the following child:\n' '...did not use a BoxParentData class for the parentData field of the following child:\n'
' ${child.toStringShallow()}\n' ' ${child.toStringShallow()}\n'
'The $runtimeType class inherits from RenderBox. ' 'The $runtimeType class inherits from RenderBox. '
......
...@@ -1781,7 +1781,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1781,7 +1781,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
final RenderObject parent = this.parent; final RenderObject parent = this.parent;
relayoutBoundary = parent._relayoutBoundary; relayoutBoundary = parent._relayoutBoundary;
} }
assert(parent == this.parent);
assert(() { assert(() {
_debugCanParentUseSize = parentUsesSize; _debugCanParentUseSize = parentUsesSize;
return true; return true;
...@@ -1842,7 +1841,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget { ...@@ -1842,7 +1841,6 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
}); });
_needsLayout = false; _needsLayout = false;
markNeedsPaint(); markNeedsPaint();
assert(parent == this.parent);
} }
/// If a subclass has a "size" (the state controlled by `parentUsesSize`, /// If a subclass has a "size" (the state controlled by `parentUsesSize`,
......
...@@ -313,7 +313,7 @@ class LabeledGlobalKey<T extends State<StatefulWidget>> extends GlobalKey<T> { ...@@ -313,7 +313,7 @@ class LabeledGlobalKey<T extends State<StatefulWidget>> extends GlobalKey<T> {
@override @override
String toString() { String toString() {
final String tag = _debugLabel != null ? ' $_debugLabel' : '#$hashCode'; final String tag = _debugLabel != null ? ' $_debugLabel' : '#$hashCode';
if (this.runtimeType == LabeledGlobalKey) if (runtimeType == LabeledGlobalKey)
return '[GlobalKey$tag]'; return '[GlobalKey$tag]';
return '[$runtimeType$tag]'; return '[$runtimeType$tag]';
} }
......
...@@ -19,7 +19,7 @@ class TestTransition extends AnimatedWidget { ...@@ -19,7 +19,7 @@ class TestTransition extends AnimatedWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Animation<double> animation = this.listenable; final Animation<double> animation = listenable;
if (animation.value >= 0.5) if (animation.value >= 0.5)
return childSecondHalf; return childSecondHalf;
return childFirstHalf; return childFirstHalf;
......
...@@ -22,7 +22,7 @@ abstract class CommandWithTarget extends Command { ...@@ -22,7 +22,7 @@ abstract class CommandWithTarget extends Command {
/// Constructs this command given a [finder]. /// Constructs this command given a [finder].
CommandWithTarget(this.finder, {Duration timeout}) : super(timeout: timeout) { CommandWithTarget(this.finder, {Duration timeout}) : super(timeout: timeout) {
if (finder == null) if (finder == null)
throw new DriverError('${this.runtimeType} target cannot be null'); throw new DriverError('$runtimeType target cannot be null');
} }
/// Deserializes the command from JSON generated by [serialize]. /// Deserializes the command from JSON generated by [serialize].
......
...@@ -316,7 +316,7 @@ void main() { ...@@ -316,7 +316,7 @@ void main() {
class MockDevice extends Mock implements Device { class MockDevice extends Mock implements Device {
MockDevice() { MockDevice() {
when(this.isSupported()).thenReturn(true); when(isSupported()).thenReturn(true);
} }
} }
......
...@@ -165,7 +165,7 @@ class MockDoctor extends Doctor { ...@@ -165,7 +165,7 @@ class MockDoctor extends Doctor {
class MockSimControl extends Mock implements SimControl { class MockSimControl extends Mock implements SimControl {
MockSimControl() { MockSimControl() {
when(this.getConnectedDevices()).thenReturn(<SimDevice>[]); when(getConnectedDevices()).thenReturn(<SimDevice>[]);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment