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