From 32f0b58be685064e909704c8022d46792dab5ffd Mon Sep 17 00:00:00 2001 From: imaNNeoFighT Date: Fri, 27 Dec 2024 14:07:58 +0100 Subject: [PATCH] Update the analysis_options to include the tests/ directory and fixed the analysis issues --- analysis_options.yaml | 1 - test/chart/bar_chart/bar_chart_test.dart | 6 ++ .../axis_chart_scaffold_widget_test.dart | 75 ++++++++++--------- .../axis_chart/axis_chart_widgets_test.dart | 21 +++--- .../side_titles/side_titles_flex_test.dart | 2 + test/chart/line_chart/line_chart_test.dart | 4 + .../scatter_chart/scatter_chart_test.dart | 4 + 7 files changed, 67 insertions(+), 46 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 1c2e0777e..1b1ad3e30 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -2,7 +2,6 @@ include: package:very_good_analysis/analysis_options.yaml analyzer: exclude: - "**.mocks.dart" - - "test/**" linter: rules: always_put_required_named_parameters_first: false diff --git a/test/chart/bar_chart/bar_chart_test.dart b/test/chart/bar_chart/bar_chart_test.dart index 13aca5c42..7087721a4 100644 --- a/test/chart/bar_chart/bar_chart_test.dart +++ b/test/chart/bar_chart/bar_chart_test.dart @@ -75,8 +75,10 @@ void main() { createTestWidget( chart: BarChart( BarChartData(alignment: alignment), + // This is for test // ignore: avoid_redundant_argument_values transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, ), @@ -228,8 +230,10 @@ void main() { createTestWidget( chart: BarChart( BarChartData(), + // This is for test // ignore: avoid_redundant_argument_values transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, ), @@ -756,6 +760,7 @@ void main() { chart: BarChart( BarChartData(), transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, trackpadScrollCausesScale: true, @@ -791,6 +796,7 @@ void main() { BarChartData(), transformationConfig: FlTransformationConfig( scaleAxis: scaleAxis, + // This is for test // ignore: avoid_redundant_argument_values trackpadScrollCausesScale: false, ), diff --git a/test/chart/base/axis_chart/axis_chart_scaffold_widget_test.dart b/test/chart/base/axis_chart/axis_chart_scaffold_widget_test.dart index cf1bf6126..67aae5634 100644 --- a/test/chart/base/axis_chart/axis_chart_scaffold_widget_test.dart +++ b/test/chart/base/axis_chart/axis_chart_scaffold_widget_test.dart @@ -412,8 +412,10 @@ void main() { height: viewSize.height, child: AxisChartScaffoldWidget( data: lineChartDataWithAllTitles, + // This is for test // ignore: avoid_redundant_argument_values transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, ), @@ -1245,8 +1247,10 @@ void main() { height: 300, child: LineChart( lineChartDataWithNoTitles, + // This is for test // ignore: avoid_redundant_argument_values transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, ), @@ -1309,26 +1313,26 @@ void main() { 'oldWidget.controller is null and widget.controller is null: ' 'keeps old controller', (WidgetTester tester) async { - final actualchartVirtualRects = [isNotScaled, isNotScaled]; + final actualChartVirtualRects = [isNotScaled, isNotScaled]; await tester.pumpWidget(createTestWidget()); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects); + expect(chartVirtualRects, actualChartVirtualRects); final transformationController = getTransformationController(tester); transformationController!.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pumpWidget(createTestWidget()); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); final transformationController2 = getTransformationController(tester); expect(transformationController2, transformationController); transformationController2!.value = Matrix4.identity()..scale(3.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); }, ); @@ -1336,24 +1340,24 @@ void main() { 'oldWidget.controller is null and widget.controller is not null: ' 'disposes old controller and sets up widget.controller with listeners', (WidgetTester tester) async { - final actualchartVirtualRects = [isNotScaled, isNotScaled]; + final actualChartVirtualRects = [isNotScaled, isNotScaled]; await tester.pumpWidget(createTestWidget()); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects); + expect(chartVirtualRects, actualChartVirtualRects); final transformationController = getTransformationController(tester); transformationController!.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); final transformationController2 = TransformationController(); await tester.pumpWidget( createTestWidget(controller: transformationController2), ); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled)); expect(transformationController2, isNot(transformationController)); expect( @@ -1362,7 +1366,7 @@ void main() { ); transformationController2.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); }, ); @@ -1371,31 +1375,32 @@ void main() { 'removes listeners from old controller and sets up new controller ' 'with listeners', (WidgetTester tester) async { - final actualchartVirtualRects = [isNotScaled, isNotScaled]; + final actualChartVirtualRects = [isNotScaled, isNotScaled]; final transformationController = TransformationController(); await tester.pumpWidget( createTestWidget(controller: transformationController), ); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects); + expect(chartVirtualRects, actualChartVirtualRects); transformationController.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pumpWidget(createTestWidget()); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled)); final transformationController2 = getTransformationController(tester); expect(transformationController2, isNot(transformationController)); + // This is for test // ignore: invalid_use_of_protected_member expect(transformationController.hasListeners, false); transformationController.addListener(() {}); // throws if disposed transformationController2!.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); }, ); @@ -1405,34 +1410,35 @@ void main() { 'removes listeners from old controller and sets up ' 'widget.controller with listeners', (WidgetTester tester) async { - final actualchartVirtualRects = [isNotScaled, isNotScaled]; + final actualChartVirtualRects = [isNotScaled, isNotScaled]; final transformationController = TransformationController(); await tester.pumpWidget( createTestWidget(controller: transformationController), ); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects); + expect(chartVirtualRects, actualChartVirtualRects); transformationController.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); final transformationController2 = TransformationController(); await tester.pumpWidget( createTestWidget(controller: transformationController2), ); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled)); expect(transformationController2, isNot(transformationController)); + // This is for test // ignore: invalid_use_of_protected_member expect(transformationController.hasListeners, false); transformationController.addListener(() {}); // throws if disposed transformationController2.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); }, ); @@ -1440,7 +1446,7 @@ void main() { 'oldWidget.controller is not null and widget.controller is not null, ' 'controllers are the same: keeps old controller', (WidgetTester tester) async { - final actualchartVirtualRects = [isNotScaled, isNotScaled]; + final actualChartVirtualRects = [isNotScaled, isNotScaled]; final transformationController = TransformationController(); await tester.pumpWidget( createTestWidget( @@ -1448,26 +1454,26 @@ void main() { ), ); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects); + expect(chartVirtualRects, actualChartVirtualRects); transformationController.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pumpWidget( createTestWidget( controller: transformationController, ), ); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); final transformationController2 = getTransformationController(tester); expect(transformationController2, transformationController); transformationController.value = Matrix4.identity()..scale(3.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); }, ); }); @@ -1477,7 +1483,7 @@ void main() { (WidgetTester tester) async { final transformationController = TransformationController(); final chartVirtualRects = []; - final actualchartVirtualRects = [isNotScaled, isNotScaled]; + final actualChartVirtualRects = [isNotScaled, isNotScaled]; await tester.pumpWidget( MaterialApp( home: AxisChartScaffoldWidget( @@ -1493,15 +1499,15 @@ void main() { ), ); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects); + expect(chartVirtualRects, actualChartVirtualRects); transformationController.value = Matrix4.identity()..scale(2.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isScaled)); transformationController.value = Matrix4.identity()..scale(1.0); await tester.pump(); - expect(chartVirtualRects, actualchartVirtualRects..add(isNotScaled)); + expect(chartVirtualRects, actualChartVirtualRects..add(isNotScaled)); }, ); @@ -1522,6 +1528,7 @@ void main() { ), ); await tester.pumpWidget(Container()); + // This is for test // ignore: invalid_use_of_protected_member expect(controller.hasListeners, false); controller.addListener(() {}); // throws if disposed diff --git a/test/chart/base/axis_chart/axis_chart_widgets_test.dart b/test/chart/base/axis_chart/axis_chart_widgets_test.dart index ce78f71c8..1a9084582 100644 --- a/test/chart/base/axis_chart/axis_chart_widgets_test.dart +++ b/test/chart/base/axis_chart/axis_chart_widgets_test.dart @@ -4,17 +4,16 @@ import 'package:flutter_test/flutter_test.dart'; void main() { TitleMeta getTitleMeta(AxisSide axisSide) => TitleMeta( - min: 0, - max: 10, - parentAxisSize: 100, - axisPosition: 10, - appliedInterval: 10, - sideTitles: const SideTitles(), - formattedValue: '12', - axisSide: axisSide, - rotationQuarterTurns: 0, - ); - + min: 0, + max: 10, + parentAxisSize: 100, + axisPosition: 10, + appliedInterval: 10, + sideTitles: const SideTitles(), + formattedValue: '12', + axisSide: axisSide, + rotationQuarterTurns: 0, + ); group( 'SideTitle without FitInside enabled', diff --git a/test/chart/base/axis_chart/side_titles/side_titles_flex_test.dart b/test/chart/base/axis_chart/side_titles/side_titles_flex_test.dart index 89ac64d64..3587daec4 100644 --- a/test/chart/base/axis_chart/side_titles/side_titles_flex_test.dart +++ b/test/chart/base/axis_chart/side_titles/side_titles_flex_test.dart @@ -188,6 +188,7 @@ void main() { const Size(viewSize, 40), ); expect( + // This is for test // ignore: invalid_use_of_protected_member renderFlex.computeDistanceToActualBaseline(TextBaseline.alphabetic), null, @@ -213,6 +214,7 @@ void main() { const Size(viewSize, 40), ); expect( + // This is for test // ignore: invalid_use_of_protected_member renderFlex.computeDistanceToActualBaseline(TextBaseline.alphabetic), null, diff --git a/test/chart/line_chart/line_chart_test.dart b/test/chart/line_chart/line_chart_test.dart index 47f31a705..48a34d3c8 100644 --- a/test/chart/line_chart/line_chart_test.dart +++ b/test/chart/line_chart/line_chart_test.dart @@ -105,8 +105,10 @@ void main() { createTestWidget( chart: LineChart( LineChartData(), + // This is for test // ignore: avoid_redundant_argument_values transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, ), @@ -647,6 +649,7 @@ void main() { chart: LineChart( LineChartData(), transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, trackpadScrollCausesScale: true, @@ -684,6 +687,7 @@ void main() { LineChartData(), transformationConfig: FlTransformationConfig( scaleAxis: scaleAxis, + // This is for test // ignore: avoid_redundant_argument_values trackpadScrollCausesScale: false, ), diff --git a/test/chart/scatter_chart/scatter_chart_test.dart b/test/chart/scatter_chart/scatter_chart_test.dart index 872572a43..184d252fd 100644 --- a/test/chart/scatter_chart/scatter_chart_test.dart +++ b/test/chart/scatter_chart/scatter_chart_test.dart @@ -110,8 +110,10 @@ void main() { createTestWidget( chart: ScatterChart( ScatterChartData(), + // This is for test // ignore: avoid_redundant_argument_values transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, ), @@ -646,6 +648,7 @@ void main() { chart: ScatterChart( ScatterChartData(), transformationConfig: const FlTransformationConfig( + // This is for test // ignore: avoid_redundant_argument_values scaleAxis: FlScaleAxis.none, trackpadScrollCausesScale: true, @@ -682,6 +685,7 @@ void main() { ScatterChartData(), transformationConfig: FlTransformationConfig( scaleAxis: scaleAxis, + // This is for test // ignore: avoid_redundant_argument_values trackpadScrollCausesScale: false, ),