Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Linting #128

Open
wants to merge 32 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
e7d4e42
migrate ios_app_group to the maintained app_group_directory
Leptopoda Oct 7, 2022
aa02417
mirate snackbar to ScaffoldMessenger
Leptopoda Oct 7, 2022
61c5175
upgrade workmanager for flutter 3
Leptopoda Oct 7, 2022
56d1d8b
null safety migration
Leptopoda Oct 16, 2022
6f55f46
add linting
Leptopoda Oct 14, 2022
f99fddb
fix require_trailing_commas
Leptopoda Oct 14, 2022
5cd37b0
fix avoid_redundant_argument_values
Leptopoda Oct 14, 2022
0b9168b
fix prefer_final lints
Leptopoda Oct 14, 2022
e6497cd
fix prefer_const_constructors
Leptopoda Oct 14, 2022
730a17f
unnecessary_await_in_return
Leptopoda Oct 14, 2022
395fc59
fix curly_braces_in_flow_control_structures
Leptopoda Oct 14, 2022
3b647ba
fix various lints (using dart fix)
Leptopoda Oct 14, 2022
f86e2e7
Sort pub dependencies
Leptopoda Oct 14, 2022
a79bec9
disable lints that require deeper code changes
Leptopoda Oct 14, 2022
a069ba2
manually fix some lints
Leptopoda Oct 13, 2022
eec0f48
fix use_named_constants
Leptopoda Oct 12, 2022
3a472ee
fix avoid_classes_with_only_static_members
Leptopoda Oct 12, 2022
e5729bc
prefer_null_aware_method_calls
Leptopoda Oct 12, 2022
f126dfb
fix errors
Leptopoda Oct 14, 2022
60a2d86
fix join_return_with_assignment
Leptopoda Oct 13, 2022
8ebc4f6
fix type_annotate_public_apis
Leptopoda Oct 13, 2022
155d1d6
fix avoid_setters_without_getters
Leptopoda Oct 13, 2022
519f0e9
fix use_setters_to_change_properties
Leptopoda Oct 14, 2022
9e5429a
removed unused variable
Leptopoda Oct 14, 2022
26d9160
fix use_string_buffers
Leptopoda Oct 14, 2022
8f4ee26
fix leading_newlines_in_multiline_strings
Leptopoda Oct 14, 2022
6cbc255
fix use_decorated_box
Leptopoda Oct 14, 2022
421f678
fix no_leading_underscores_for_local_identifiers
Leptopoda Oct 14, 2022
eb7fd66
fix prefer_constructors_over_static_methods
Leptopoda Oct 14, 2022
b684002
fix error catching stuff
Leptopoda Oct 14, 2022
bfe0250
format code
Leptopoda Oct 16, 2022
1c6bf85
fix depend_on_referenced_packages
Leptopoda Oct 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file configures the analyzer to use the lint rule set from `package:lint`

# For apps, use the default set
include: package:lint/analysis_options.yaml

# You might want to exclude auto-generated files from dart analysis
analyzer:
exclude:
#- '**.freezed.dart'

# You can customize the lint rules set to your own liking. A list of all rules
# can be found at https://dart-lang.github.io/linter/lints/options/options.html
linter:
rules:
constant_identifier_names: false
avoid_print: false
avoid_positional_boolean_parameters: false
use_build_context_synchronously: false
parameter_assignments: false
avoid_setters_without_getters: false
15 changes: 8 additions & 7 deletions lib/common/appstart/app_initializer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import 'package:dhbwstudentapp/common/appstart/localization_initialize.dart';
import 'package:dhbwstudentapp/common/appstart/notification_schedule_changed_initialize.dart';
import 'package:dhbwstudentapp/common/appstart/notifications_initialize.dart';
import 'package:dhbwstudentapp/common/appstart/service_injector.dart';
import 'package:dhbwstudentapp/common/data/preferences/preferences_provider.dart';
import 'package:dhbwstudentapp/common/iap/in_app_purchase_manager.dart';
import 'package:dhbwstudentapp/native/widget/widget_update_callback.dart';
import 'package:dhbwstudentapp/schedule/background/calendar_synchronizer.dart';
import 'package:dhbwstudentapp/schedule/business/schedule_provider.dart';
import 'package:dhbwstudentapp/schedule/business/schedule_source_provider.dart';
import 'package:kiwi/kiwi.dart';
import 'package:dhbwstudentapp/schedule/business/schedule_provider.dart';
import 'package:dhbwstudentapp/common/data/preferences/preferences_provider.dart';
import 'package:timezone/data/latest.dart' as tz;

bool isInitialized = false;
Expand Down Expand Up @@ -57,15 +57,16 @@ Future<void> initializeApp(bool isBackground) async {
NotificationScheduleChangedInitialize().setupNotification();

if (isBackground) {
var setup = KiwiContainer().resolve<ScheduleSourceProvider>();
final setup = KiwiContainer().resolve<ScheduleSourceProvider>();
setup.setupScheduleSource();
}

// Callback-Function for synchronizing the device calendar with the schedule, when schedule is updated
CalendarSynchronizer calendarSynchronizer = new CalendarSynchronizer(
KiwiContainer().resolve<ScheduleProvider>(),
KiwiContainer().resolve<ScheduleSourceProvider>(),
KiwiContainer().resolve<PreferencesProvider>());
final CalendarSynchronizer calendarSynchronizer = CalendarSynchronizer(
KiwiContainer().resolve<ScheduleProvider>(),
KiwiContainer().resolve<ScheduleSourceProvider>(),
KiwiContainer().resolve<PreferencesProvider>(),
);

calendarSynchronizer.registerSynchronizationCallback();
calendarSynchronizer.scheduleSyncInAFewSeconds();
Expand Down
4 changes: 2 additions & 2 deletions lib/common/appstart/background_initialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BackgroundInitialize {

KiwiContainer().registerInstance<WorkSchedulerService>(scheduler);

var tasks = [
final tasks = [
BackgroundScheduleUpdate(
KiwiContainer().resolve(),
KiwiContainer().resolve(),
Expand All @@ -37,7 +37,7 @@ class BackgroundInitialize {
),
];

for (var task in tasks) {
for (final task in tasks) {
scheduler.registerTask(task);

KiwiContainer().registerInstance(
Expand Down
14 changes: 8 additions & 6 deletions lib/common/appstart/localization_initialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'package:kiwi/kiwi.dart';
/// correct language
///
class LocalizationInitialize {
PreferencesProvider _preferencesProvider;
String _languageCode;
PreferencesProvider? _preferencesProvider;
String? _languageCode;

///
/// Initialize the localization using the provided language code
Expand All @@ -23,10 +23,12 @@ class LocalizationInitialize {
LocalizationInitialize.fromPreferences(this._preferencesProvider);

Future<void> setupLocalizations() async {
var localization = L(Locale(
_languageCode ??
(await _preferencesProvider?.getLastUsedLanguageCode() ?? "en"),
));
final localization = L(
Locale(
_languageCode ??
(await _preferencesProvider?.getLastUsedLanguageCode() ?? "en"),
),
);
KiwiContainer().registerInstance(localization);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import 'package:kiwi/kiwi.dart';
///
class NotificationScheduleChangedInitialize {
void setupNotification() {
var provider = KiwiContainer().resolve<ScheduleProvider>();
final provider = KiwiContainer().resolve<ScheduleProvider>();

provider.addScheduleEntryChangedCallback(_scheduleChangedCallback);
}

Future<void> _scheduleChangedCallback(ScheduleDiff scheduleDiff) async {
PreferencesProvider preferences = KiwiContainer().resolve();
var doNotify = await preferences.getNotifyAboutScheduleChanges();
final PreferencesProvider preferences = KiwiContainer().resolve();
final doNotify = await preferences.getNotifyAboutScheduleChanges();

if (!doNotify) return;

var notification = ScheduleChangedNotification(
final notification = ScheduleChangedNotification(
KiwiContainer().resolve(),
KiwiContainer().resolve(),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/common/appstart/notifications_initialize.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:kiwi/kiwi.dart';
class NotificationsInitialize {
Future<void> setupNotifications() async {
if (Platform.isAndroid) {
var notificationApi = NotificationApi();
final notificationApi = NotificationApi();

KiwiContainer().registerInstance(notificationApi);

Expand Down
86 changes: 51 additions & 35 deletions lib/common/appstart/service_injector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,46 +28,62 @@ bool _isInjected = false;
void injectServices(bool isBackground) {
if (_isInjected) return;

KiwiContainer c = KiwiContainer();
c.registerInstance(PreferencesProvider(
PreferencesAccess(),
SecureStorageAccess(),
));
final KiwiContainer c = KiwiContainer();
c.registerInstance(
PreferencesProvider(
PreferencesAccess(),
SecureStorageAccess(),
),
);
c.registerInstance(DatabaseAccess());
c.registerInstance(ScheduleEntryRepository(
c.resolve(),
));
c.registerInstance(ScheduleFilterRepository(
c.resolve(),
));
c.registerInstance(ScheduleQueryInformationRepository(
c.resolve(),
));
c.registerInstance(ScheduleSourceProvider(
c.resolve(),
isBackground,
c.resolve(),
c.resolve(),
));
c.registerInstance(ScheduleProvider(
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
));
c.registerInstance(
ScheduleEntryRepository(
c.resolve(),
),
);
c.registerInstance(
ScheduleFilterRepository(
c.resolve(),
),
);
c.registerInstance(
ScheduleQueryInformationRepository(
c.resolve(),
),
);
c.registerInstance(
ScheduleSourceProvider(
c.resolve(),
isBackground,
c.resolve(),
c.resolve(),
),
);
c.registerInstance(
ScheduleProvider(
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
c.resolve(),
),
);
c.registerInstance<DualisScraper>(
FakeAccountDualisScraperDecorator(DualisScraper()),
);
c.registerInstance<DualisService>(CacheDualisServiceDecorator(
DualisServiceImpl(
c.resolve(),
c.registerInstance<DualisService>(
CacheDualisServiceDecorator(
DualisServiceImpl(
c.resolve(),
),
),
));
c.registerInstance(DateEntryProvider(
DateManagementService(),
DateEntryRepository(c.resolve()),
));
);
c.registerInstance(
DateEntryProvider(
DateManagementService(),
DateEntryRepository(c.resolve()),
),
);
c.registerInstance(WidgetHelper());
c.registerInstance(ListDateEntries30d(List<DateEntry>.empty(growable: true)));

Expand Down
13 changes: 9 additions & 4 deletions lib/common/background/background_work_scheduler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ class BackgroundWorkScheduler extends WorkSchedulerService {
///
@override
Future<void> scheduleOneShotTaskIn(
Duration delay, String id, String name) async {
Duration delay,
String id,
String name,
) async {
print(
"Scheduling one shot task: $id. With a delay of ${delay.inMinutes} minutes.",
);
Expand Down Expand Up @@ -103,13 +106,16 @@ class BackgroundWorkScheduler extends WorkSchedulerService {
///
/// Entry point for when a background task is executed
///
static Future<bool> backgroundTaskMain(taskId, inputData) async {
static Future<bool> backgroundTaskMain(
String taskId,
Map<String, dynamic>? inputData,
) async {
try {
print("Background task started: $taskId with data: $inputData");

await initializeApp(true);

WorkSchedulerService scheduler = KiwiContainer().resolve();
final WorkSchedulerService scheduler = KiwiContainer().resolve();

await scheduler.executeTask(taskId);
} catch (e, trace) {
Expand All @@ -129,7 +135,6 @@ class BackgroundWorkScheduler extends WorkSchedulerService {

await workmanager.initialize(
callbackDispatcher,
isInDebugMode: false,
);
}

Expand Down
Loading