From a589d87fad8182a0002fde014c69969ab54a3fb0 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Wed, 18 Sep 2024 15:47:58 +0300 Subject: [PATCH] dcm fix --only-rules=avoid-redundant-async --- lib/screens/measurement_categories_screen.dart | 2 +- lib/screens/measurement_entries_screen.dart | 2 +- lib/widgets/dashboard/widgets.dart | 4 ++-- test/exercises/exercise_provider_load_test.dart | 2 +- test/exercises/exercise_provider_test.dart | 2 +- test/exercises/model_exercise_test.dart | 2 +- test/measurements/measurement_provider_test.dart | 16 +++++++--------- test/other/base_provider_test.dart | 4 ++-- test/weight/weight_model_test.dart | 4 ++-- test/workout/plate_calculator_test.dart | 6 +++--- test/workout/set_model_test.dart | 2 +- test/workout/setting_model_test.dart | 10 +++++----- test/workout/workout_log_model_test.dart | 12 ++++++------ 13 files changed, 33 insertions(+), 35 deletions(-) diff --git a/lib/screens/measurement_categories_screen.dart b/lib/screens/measurement_categories_screen.dart index 6bc5e1b1..29b33d0f 100644 --- a/lib/screens/measurement_categories_screen.dart +++ b/lib/screens/measurement_categories_screen.dart @@ -34,7 +34,7 @@ class MeasurementCategoriesScreen extends StatelessWidget { appBar: AppBar(title: Text(AppLocalizations.of(context).measurements)), floatingActionButton: FloatingActionButton( child: const Icon(Icons.add, color: Colors.white), - onPressed: () async { + onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, diff --git a/lib/screens/measurement_entries_screen.dart b/lib/screens/measurement_entries_screen.dart index dcbcae1a..3c8e4188 100644 --- a/lib/screens/measurement_entries_screen.dart +++ b/lib/screens/measurement_entries_screen.dart @@ -122,7 +122,7 @@ class MeasurementEntriesScreen extends StatelessWidget { ), floatingActionButton: FloatingActionButton( child: const Icon(Icons.add, color: Colors.white), - onPressed: () async { + onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, diff --git a/lib/widgets/dashboard/widgets.dart b/lib/widgets/dashboard/widgets.dart index 9fc26761..d1060ec5 100644 --- a/lib/widgets/dashboard/widgets.dart +++ b/lib/widgets/dashboard/widgets.dart @@ -209,7 +209,7 @@ class _DashboardWeightWidgetState extends State { ), IconButton( icon: const Icon(Icons.add), - onPressed: () async { + onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, @@ -526,7 +526,7 @@ class NothingFound extends StatelessWidget { IconButton( iconSize: 30, icon: const Icon(Icons.add_box, color: wgerPrimaryButtonColor), - onPressed: () async { + onPressed: () { Navigator.pushNamed( context, FormScreen.routeName, diff --git a/test/exercises/exercise_provider_load_test.dart b/test/exercises/exercise_provider_load_test.dart index baaef088..b12f1a59 100644 --- a/test/exercises/exercise_provider_load_test.dart +++ b/test/exercises/exercise_provider_load_test.dart @@ -41,7 +41,7 @@ void main() { await ServiceLocator().configure(); }); - setUp(() async { + setUp(() { WidgetsFlutterBinding.ensureInitialized(); driftRuntimeOptions.dontWarnAboutMultipleDatabases = true; diff --git a/test/exercises/exercise_provider_test.dart b/test/exercises/exercise_provider_test.dart index dc2aa192..0170a3fe 100644 --- a/test/exercises/exercise_provider_test.dart +++ b/test/exercises/exercise_provider_test.dart @@ -84,7 +84,7 @@ void main() { fixture('exercises/exercisebaseinfo_response.json'), ); - setUpAll(() async { + setUpAll(() { // Needs to be configured here, setUp runs on every test, setUpAll only once //await ServiceLocator().configure(); }); diff --git a/test/exercises/model_exercise_test.dart b/test/exercises/model_exercise_test.dart index 96886cb0..72e7f899 100644 --- a/test/exercises/model_exercise_test.dart +++ b/test/exercises/model_exercise_test.dart @@ -12,7 +12,7 @@ void main() { ); group('Model tests', () { - test('test getExercise', () async { + test('test getExercise', () { // arrange and act final base = getTestExercises()[1]; diff --git a/test/measurements/measurement_provider_test.dart b/test/measurements/measurement_provider_test.dart index 68157513..ea176ac8 100644 --- a/test/measurements/measurement_provider_test.dart +++ b/test/measurements/measurement_provider_test.dart @@ -240,13 +240,13 @@ void main() { test( 'should re-add the "removed" MeasurementCategory and relay the exception on WgerHttpException', - () async { + () { // arrange when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}')); // act & assert - expect(() async => measurementProvider.deleteCategory(tCategoryId), - throwsA(isA())); + expect( + () => measurementProvider.deleteCategory(tCategoryId), throwsA(isA())); expect(measurementProvider.categories, tMeasurementCategories); }); }); @@ -279,9 +279,7 @@ void main() { test("should throw a NoSuchEntryException if category doesn't exist", () { // act & assert - expect( - () async => - measurementProvider.editCategory(83, tCategoryEditedName, tCategoryEditedUnit), + expect(() => measurementProvider.editCategory(83, tCategoryEditedName, tCategoryEditedUnit), throwsA(isA())); }); @@ -439,7 +437,7 @@ void main() { test("should throw a NoSuchEntryException if the category isn't found", () { // act & assert - expect(() async => measurementProvider.deleteEntry(tEntryId, 83), + expect(() => measurementProvider.deleteEntry(tEntryId, 83), throwsA(isA())); }); @@ -461,7 +459,7 @@ void main() { test( 'should re-add the "removed" MeasurementEntry and throw a WgerHttpException if the api call fails', - () async { + () { // arrange final List tMeasurementCategories = [ MeasurementCategory(id: 1, name: 'Strength', unit: 'kN', entries: [ @@ -485,7 +483,7 @@ void main() { when(mockWgerBaseProvider.deleteRequest(any, any)).thenThrow(WgerHttpException('{}')); // act & assert - expect(() async => measurementProvider.deleteEntry(tEntryId, tCategoryId), + expect(() => measurementProvider.deleteEntry(tEntryId, tCategoryId), throwsA(isA())); expect(measurementProvider.categories, tMeasurementCategories); }); diff --git a/test/other/base_provider_test.dart b/test/other/base_provider_test.dart index e416e1b8..3f3376d2 100644 --- a/test/other/base_provider_test.dart +++ b/test/other/base_provider_test.dart @@ -30,7 +30,7 @@ import 'base_provider_test.mocks.dart'; @GenerateMocks([http.Client]) void main() { group('test base provider', () { - test('Test the makeUrl helper', () async { + test('Test the makeUrl helper', () { final WgerBaseProvider provider = WgerBaseProvider(testAuthProvider); expect( @@ -63,7 +63,7 @@ void main() { ); }); - test('Test the makeUrl helper with sub url', () async { + test('Test the makeUrl helper with sub url', () { // Trailing slash is removed when saving the server URL testAuthProvider.serverUrl = 'https://example.com/wger-url'; final WgerBaseProvider provider = WgerBaseProvider(testAuthProvider); diff --git a/test/weight/weight_model_test.dart b/test/weight/weight_model_test.dart index f903f370..0866d83e 100644 --- a/test/weight/weight_model_test.dart +++ b/test/weight/weight_model_test.dart @@ -21,7 +21,7 @@ import 'package:wger/models/body_weight/weight_entry.dart'; void main() { group('fetchPost', () { - test('Test that the weight entries are correctly converted to json', () async { + test('Test that the weight entries are correctly converted to json', () { WeightEntry weightEntry = WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31)); expect(weightEntry.toJson(), {'id': 1, 'weight': '80', 'date': '2020-12-31'}); @@ -29,7 +29,7 @@ void main() { expect(weightEntry.toJson(), {'id': 2, 'weight': '70.2', 'date': '2020-12-01'}); }); - test('Test that the weight entries are correctly converted from json', () async { + test('Test that the weight entries are correctly converted from json', () { final WeightEntry weightEntryObj = WeightEntry(id: 1, weight: 80, date: DateTime(2020, 12, 31)); final WeightEntry weightEntry = WeightEntry.fromJson({ diff --git a/test/workout/plate_calculator_test.dart b/test/workout/plate_calculator_test.dart index e1150406..60a1b017 100644 --- a/test/workout/plate_calculator_test.dart +++ b/test/workout/plate_calculator_test.dart @@ -22,7 +22,7 @@ import 'package:wger/helpers/gym_mode.dart'; void main() { group('Test the plate calculator', () { - test('Regular weights', () async { + test('Regular weights', () { expect(plateCalculator(40, BAR_WEIGHT, AVAILABLE_PLATES), [10]); expect(plateCalculator(100, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 10]); expect(plateCalculator(102.5, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 10, 1.25]); @@ -31,7 +31,7 @@ void main() { expect(plateCalculator(85, BAR_WEIGHT, AVAILABLE_PLATES), [15, 15, 2.5]); }); - test('Exceptions', () async { + test('Exceptions', () { expect( plateCalculator(10, BAR_WEIGHT, AVAILABLE_PLATES), [], @@ -47,7 +47,7 @@ void main() { }); group('Test the plate calculator group', () { - test('Test groups', () async { + test('Test groups', () { expect(groupPlates([15, 15, 15, 10, 10, 5]), {15: 3, 10: 2, 5: 1}); expect(groupPlates([15, 10, 5, 1.25]), {15: 1, 10: 1, 5: 1, 1.25: 1}); expect(groupPlates([10, 10, 10, 10, 10, 10, 10]), {10: 7}); diff --git a/test/workout/set_model_test.dart b/test/workout/set_model_test.dart index dfd4b0e8..b055d149 100644 --- a/test/workout/set_model_test.dart +++ b/test/workout/set_model_test.dart @@ -22,7 +22,7 @@ import '../../test_data/workouts.dart'; void main() { group('Test the getSmartTextRepr method for a set', () { - test('Repetitions and weigh units', () async { + test('Repetitions and weigh units', () { final workout = getWorkout(); final set = workout.days.first.sets.first; final exercise1 = set.exerciseBasesObj[0]; diff --git a/test/workout/setting_model_test.dart b/test/workout/setting_model_test.dart index 53d2381c..bec0a052 100644 --- a/test/workout/setting_model_test.dart +++ b/test/workout/setting_model_test.dart @@ -23,7 +23,7 @@ import 'package:wger/models/workouts/weight_unit.dart'; void main() { group('Test the singleSettingRepText method', () { - test('Default rep and weight units, no RiR', () async { + test('Default rep and weight units, no RiR', () { const repUnit = RepetitionUnit(id: 1, name: 'mol'); const weightUnit = WeightUnit(id: 1, name: 'mg'); @@ -36,7 +36,7 @@ void main() { expect(setting.singleSettingRepText, '2 × 30 mg'); }); - test('Default rep and weight units', () async { + test('Default rep and weight units', () { const repUnit = RepetitionUnit(id: 1, name: 'mol'); const weightUnit = WeightUnit(id: 1, name: 'mg'); @@ -49,7 +49,7 @@ void main() { expect(setting.singleSettingRepText, '2 × 30 mg \n (1.5 RiR)'); }); - test('No weight, default rep and weight units', () async { + test('No weight, default rep and weight units', () { const repUnit = RepetitionUnit(id: 1, name: 'mol'); const weightUnit = WeightUnit(id: 1, name: 'mg'); @@ -62,7 +62,7 @@ void main() { expect(setting.singleSettingRepText, '2 mol \n (1.5 RiR)'); }); - test('Custom rep and weight units, no RiR', () async { + test('Custom rep and weight units, no RiR', () { const repUnit = RepetitionUnit(id: 2, name: 'mol'); const weightUnit = WeightUnit(id: 2, name: 'mg'); @@ -75,7 +75,7 @@ void main() { expect(setting.singleSettingRepText, '2 mol × 30 mg'); }); - test('Custom rep and weight units, RiR', () async { + test('Custom rep and weight units, RiR', () { const repUnit = RepetitionUnit(id: 2, name: 'mol'); const weightUnit = WeightUnit(id: 2, name: 'mg'); diff --git a/test/workout/workout_log_model_test.dart b/test/workout/workout_log_model_test.dart index f7f381d9..a53e7ae3 100644 --- a/test/workout/workout_log_model_test.dart +++ b/test/workout/workout_log_model_test.dart @@ -49,31 +49,31 @@ void main() { ); }); - test('Test equal values (besides Id, workoutPlan and date)', () async { + test('Test equal values (besides Id, workoutPlan and date)', () { expect(log1, log2); }); - test('Test different rir values', () async { + test('Test different rir values', () { log1.rir = null; expect(log1, isNot(log2)); }); - test('Test different weight values', () async { + test('Test different weight values', () { log1.weight = 100; expect(log1, isNot(log2)); }); - test('Test different weight units', () async { + test('Test different weight units', () { log1.weightUnitId = 2; expect(log1, isNot(log2)); }); - test('Test different reps', () async { + test('Test different reps', () { log1.reps = 99; expect(log1, isNot(log2)); }); - test('Test different rep units', () async { + test('Test different rep units', () { log1.repetitionUnitId = 44; expect(log1, isNot(log2)); });