Skip to content

Commit 5b4744b

Browse files
committed
build: add linting rules and fix issues
1 parent 6b47d50 commit 5b4744b

36 files changed

+127
-132
lines changed

mobile/analysis_options.yaml

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,24 @@
1-
# This file configures the analyzer, which statically analyzes Dart code to
2-
# check for errors, warnings, and lints.
3-
#
4-
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5-
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6-
# invoked from the command line by running `flutter analyze`.
7-
8-
# The following line activates a set of recommended lints for Flutter apps,
9-
# packages, and plugins designed to encourage good coding practices.
101
include: package:flutter_lints/flutter.yaml
112

123
linter:
13-
# The lint rules applied to this project can be customized in the
14-
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15-
# included above or to enable additional rules. A list of all available lints
16-
# and their documentation is published at https://dart.dev/lints.
17-
#
18-
# Instead of disabling a lint rule for the entire project in the
19-
# section below, it can also be suppressed for a single line of code
20-
# or a specific dart file by using the `// ignore: name_of_lint` and
21-
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22-
# producing the lint.
234
rules:
24-
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25-
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26-
27-
# Additional information about this file can be found at
28-
# https://dart.dev/guides/language/analysis-options
5+
always_declare_return_types: true
6+
prefer_single_quotes: false
7+
always_use_package_imports: true
8+
avoid_bool_literals_in_conditional_expressions: true
9+
avoid_empty_else: true
10+
avoid_relative_lib_imports: true
11+
unnecessary_async: true
12+
unnecessary_const: true
13+
unnecessary_final: true
14+
unnecessary_ignore: true
15+
unnecessary_late: true
16+
unnecessary_new: true
17+
unnecessary_null_checks: true
18+
unnecessary_null_in_if_null_operators: true
19+
unnecessary_parenthesis: true
20+
unnecessary_string_interpolations: true
21+
use_enums: true
22+
use_rethrow_when_possible: true
23+
annotate_overrides: true
24+
constant_identifier_names: false

mobile/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import 'package:financial_planner_mobile/util/theme.dart';
1818
import 'package:flutter/foundation.dart';
1919
import 'package:flutter/material.dart';
2020
import 'package:flutter_bloc/flutter_bloc.dart';
21-
import 'firebase_options.dart';
21+
import 'package:financial_planner_mobile/firebase_options.dart';
2222

2323
void main() async {
2424
WidgetsFlutterBinding.ensureInitialized();

mobile/lib/ui/app/account/account_currency.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'package:firebase_auth/firebase_auth.dart';
33
import 'package:flutter/material.dart';
44
import 'package:flutter_bloc/flutter_bloc.dart';
55

6-
import '../../../cubit/currency_cubit.dart';
7-
import '../../../util/theme.dart';
6+
import 'package:financial_planner_mobile/cubit/currency_cubit.dart';
7+
import 'package:financial_planner_mobile/util/theme.dart';
88

99
class AccountCurrency extends StatelessWidget {
1010
const AccountCurrency({super.key});
@@ -72,10 +72,10 @@ class AccountCurrency extends StatelessWidget {
7272
separatorBuilder: (_, __) => Divider(
7373
color: darkTheme.surfaceContainer, height: 1),
7474
itemBuilder: (context, index) {
75-
final code = currencies.keys.elementAt(index);
76-
final name = currencies[code]!;
75+
var code = currencies.keys.elementAt(index);
76+
var name = currencies[code]!;
7777

78-
final isSelected = code == selectedCurrency;
78+
var isSelected = code == selectedCurrency;
7979

8080
return ListTile(
8181
title: Text('$code - $name'),

mobile/lib/ui/app/account/account_settings.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import 'package:firebase_auth/firebase_auth.dart';
66
import 'package:flutter/material.dart';
77
import 'package:flutter_bloc/flutter_bloc.dart';
88

9-
import '../../../cubit/name_cubit.dart';
10-
import '../../../util/theme.dart';
9+
import 'package:financial_planner_mobile/cubit/name_cubit.dart';
10+
import 'package:financial_planner_mobile/util/theme.dart';
1111

1212
class AccountSettings extends StatefulWidget {
1313
const AccountSettings({super.key});

mobile/lib/ui/app/analytics/analytics.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,31 @@ import 'package:fl_chart/fl_chart.dart';
33
import 'package:flutter/material.dart';
44
import 'package:flutter_bloc/flutter_bloc.dart';
55

6-
import '../../../cubit/assets_cubit.dart';
7-
import '../../../cubit/balances_cubit.dart';
8-
import '../../../cubit/receivables_cubit.dart';
9-
import '../../../cubit/transactions_cubit.dart';
10-
import '../../../util/money_format.dart';
11-
import '../../../util/theme.dart';
6+
import 'package:financial_planner_mobile/cubit/assets_cubit.dart';
7+
import 'package:financial_planner_mobile/cubit/balances_cubit.dart';
8+
import 'package:financial_planner_mobile/cubit/receivables_cubit.dart';
9+
import 'package:financial_planner_mobile/cubit/transactions_cubit.dart';
10+
import 'package:financial_planner_mobile/util/money_format.dart';
11+
import 'package:financial_planner_mobile/util/theme.dart';
1212

1313
class AnalyticsPage extends StatelessWidget {
1414
const AnalyticsPage({super.key});
1515

1616
List<FlSpot> generateExpenseSpots(List<dynamic> transactions) {
17-
final now = DateTime.now();
18-
final lastWeek = List.generate(7, (i) => DateTime(now.year, now.month, now.day).subtract(Duration(days: 6 - i)));
17+
var now = DateTime.now();
18+
var lastWeek = List.generate(7, (i) => DateTime(now.year, now.month, now.day).subtract(Duration(days: 6 - i)));
1919

2020
// Initialize a map with zeroes for each day
21-
final Map<String, double> dailyTotals = {
21+
Map<String, double> dailyTotals = {
2222
for (var day in lastWeek)
2323
"${day.year}-${day.month}-${day.day}": 0.0,
2424
};
2525

2626
for (var tx in transactions) {
2727
if (tx["type"] != "expense") continue;
2828

29-
final date = tx["date"].toDate();
30-
final dateKey = "${date.year}-${date.month}-${date.day}";
29+
var date = tx["date"].toDate();
30+
var dateKey = "${date.year}-${date.month}-${date.day}";
3131

3232
if (dailyTotals.containsKey(dateKey)) {
3333
dailyTotals[dateKey] = dailyTotals[dateKey]! + tx["value"];
@@ -37,7 +37,7 @@ class AnalyticsPage extends StatelessWidget {
3737
// Convert to FlSpot
3838
List<FlSpot> spots = [];
3939
for (int i = 0; i < lastWeek.length; i++) {
40-
final key = "${lastWeek[i].year}-${lastWeek[i].month}-${lastWeek[i].day}";
40+
var key = "${lastWeek[i].year}-${lastWeek[i].month}-${lastWeek[i].day}";
4141
spots.add(FlSpot(i.toDouble(), dailyTotals[key]!));
4242
}
4343

@@ -174,7 +174,7 @@ class AnalyticsPage extends StatelessWidget {
174174
SizedBox(height: 30),
175175
BlocBuilder<TransactionsCubit, List<dynamic>>(
176176
builder: (context, transactions) {
177-
final spots = generateExpenseSpots(transactions);
177+
var spots = generateExpenseSpots(transactions);
178178

179179
return SizedBox(
180180
height: 200,
@@ -194,7 +194,7 @@ class AnalyticsPage extends StatelessWidget {
194194
int index = value.toInt();
195195
if (index < 0 || index >= 7) return SizedBox.shrink();
196196

197-
final date = DateTime.now().subtract(Duration(days: 6 - index));
197+
var date = DateTime.now().subtract(Duration(days: 6 - index));
198198
return Text("${date.day.toString().padLeft(2, '0')}/${date.month}", style: TextStyle(color: Colors.white, fontSize: 10));
199199
},
200200
),
@@ -205,7 +205,7 @@ class AnalyticsPage extends StatelessWidget {
205205
reservedSize: 40,
206206
getTitlesWidget: (value, meta) {
207207
// Only show actual used Y values
208-
final usedY = spots.map((e) => e.y).toSet();
208+
var usedY = spots.map((e) => e.y).toSet();
209209
if (usedY.contains(value)) {
210210
return Text(value.toInt().toString(), style: TextStyle(color: Colors.white, fontSize: 12));
211211
}

mobile/lib/ui/app/assets/assets.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:cloud_firestore/cloud_firestore.dart';
66
import 'package:flutter/material.dart';
77
import 'package:flutter_bloc/flutter_bloc.dart';
88

9-
import '../../../util/money_format.dart';
9+
import 'package:financial_planner_mobile/util/money_format.dart';
1010

1111
class AssetsPage extends StatefulWidget {
1212
const AssetsPage({super.key});

mobile/lib/ui/app/assets/assets_add.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'package:financial_planner_mobile/values/spaces.dart';
33
import 'package:firebase_auth/firebase_auth.dart';
44
import 'package:flutter/material.dart';
55

6-
import '../../common/primary_button.dart';
7-
import '../../common/themed_input_field.dart';
6+
import 'package:financial_planner_mobile/ui/common/primary_button.dart';
7+
import 'package:financial_planner_mobile/ui/common/themed_input_field.dart';
88

99
class AssetsAdd extends StatefulWidget {
1010
const AssetsAdd({super.key});

mobile/lib/ui/app/balances/balances.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:cloud_firestore/cloud_firestore.dart';
66
import 'package:flutter/material.dart';
77
import 'package:flutter_bloc/flutter_bloc.dart';
88

9-
import '../../../util/money_format.dart';
9+
import 'package:financial_planner_mobile/util/money_format.dart';
1010

1111
class BalancesPage extends StatefulWidget {
1212
const BalancesPage({super.key});

mobile/lib/ui/app/balances/balances_add.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:financial_planner_mobile/values/spaces.dart';
44
import 'package:firebase_auth/firebase_auth.dart';
55
import 'package:flutter/material.dart';
66

7-
import '../../common/themed_input_field.dart';
7+
import 'package:financial_planner_mobile/ui/common/themed_input_field.dart';
88

99
class BalancesAdd extends StatefulWidget {
1010
const BalancesAdd({super.key});

mobile/lib/ui/app/bills/bill_details.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import 'package:financial_planner_mobile/values/spaces.dart';
55
import 'package:firebase_auth/firebase_auth.dart';
66
import 'package:flutter/material.dart';
77

8-
import '../../../util/money_format.dart';
9-
import '../../../util/theme.dart';
8+
import 'package:financial_planner_mobile/util/money_format.dart';
9+
import 'package:financial_planner_mobile/util/theme.dart';
1010

1111
class BillDetails extends StatefulWidget {
1212
const BillDetails({super.key, required this.index, required this.bill});

0 commit comments

Comments
 (0)