Skip to content
This repository was archived by the owner on Sep 14, 2024. It is now read-only.

Commit 97b44d8

Browse files
committed
tighten our static analysis
1 parent f5d8504 commit 97b44d8

File tree

67 files changed

+444
-452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+444
-452
lines changed

analysis_options.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,24 @@ include: package:lint/strict.yaml
55
linter:
66
rules:
77
sort_pub_dependencies: false
8+
prefer_final_parameters: false
9+
discarded_futures: false
10+
prefer_asserts_with_message: false
11+
unawaited_futures: false
12+
prefer_mixin: false
13+
prefer_expression_function_bodies: false
14+
only_throw_errors: false
15+
16+
always_put_control_body_on_new_line: true
17+
use_key_in_widget_constructors: true
18+
always_put_required_named_parameters_first: true
19+
prefer_single_quotes: true
20+
sort_constructors_first: true
21+
omit_local_variable_types: true
22+
prefer_int_literals: true
23+
cascade_invocations: true
24+
avoid_equals_and_hash_code_on_mutable_classes: true
25+
avoid_types_on_closure_parameters: true
26+
use_decorated_box: true
27+
unnecessary_lambdas: true
28+
prefer_foreach: true

lib/main.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class _AppState extends State<App> {
9494
Widget build(BuildContext context) {
9595
return ThemeModeHandler(
9696
manager: ThemeModeManager(),
97-
builder: (ThemeMode themeMode) => MaterialApp(
97+
builder: (themeMode) => MaterialApp(
9898
navigatorKey: IntentRepository().getNavigationKey(),
9999
themeMode: themeMode,
100100
theme: AppTheme.lightThemeData,
@@ -121,8 +121,8 @@ class _AppState extends State<App> {
121121
SnackBar(
122122
content: Text(
123123
translate(
124-
"categories.errors.api_version_check_failed",
125-
args: {"error_msg": snapshot.error},
124+
'categories.errors.api_version_check_failed',
125+
args: {'error_msg': snapshot.error},
126126
),
127127
style: TextStyle(
128128
color: Theme.of(context).colorScheme.onError,
@@ -138,10 +138,10 @@ class _AppState extends State<App> {
138138
SnackBar(
139139
content: Text(
140140
translate(
141-
"categories.errors.api_version_above_confirmed",
141+
'categories.errors.api_version_above_confirmed',
142142
args: {
143-
"version":
144-
"${snapshot.data!.major}.${snapshot.data!.minor}"
143+
'version':
144+
'${snapshot.data!.major}.${snapshot.data!.minor}'
145145
},
146146
),
147147
),

lib/src/blocs/authentication/authentication_bloc.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@ part 'authentication_state.dart';
88

99
class AuthenticationBloc
1010
extends Bloc<AuthenticationEvent, AuthenticationState> {
11-
final UserRepository userRepository = UserRepository();
12-
1311
AuthenticationBloc() : super(AuthenticationState()) {
1412
on<AppStarted>(_mapAppStartedEventToState);
1513
on<LoggedIn>(_mapLoggedInEventToState);
1614
on<LoggedOut>(_mapLoggedOutEventToState);
1715
}
16+
final UserRepository userRepository = UserRepository();
1817

1918
Future<void> _mapAppStartedEventToState(
2019
AppStarted event,
2120
Emitter<AuthenticationState> emit,
2221
) async {
23-
final bool hasToken = await userRepository.hasAppAuthentication();
22+
final hasToken = await userRepository.hasAppAuthentication();
2423

2524
if (hasToken) {
2625
await userRepository.loadAppAuthentication();

lib/src/blocs/authentication/authentication_event.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ class AppStarted extends AuthenticationEvent {
1212
}
1313

1414
class LoggedIn extends AuthenticationEvent {
15-
final AppAuthentication appAuthentication;
16-
1715
const LoggedIn({required this.appAuthentication});
16+
final AppAuthentication appAuthentication;
1817

1918
@override
2019
List<Object> get props => [appAuthentication];

lib/src/blocs/authentication/authentication_state.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ enum AuthenticationStatus {
2222
}
2323

2424
class AuthenticationState extends Equatable {
25-
final AuthenticationStatus status;
26-
final String? error;
27-
2825
const AuthenticationState({
2926
this.status = AuthenticationStatus.loading,
3027
this.error,
3128
}) : assert(
3229
(status != AuthenticationStatus.error && error == null) ||
3330
(status == AuthenticationStatus.error && error != null),
3431
);
32+
final AuthenticationStatus status;
33+
final String? error;
3534

3635
@override
3736
List<Object?> get props => [status, error];

lib/src/blocs/categories/categories_bloc.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ part 'categories_event.dart';
77
part 'categories_state.dart';
88

99
class CategoriesBloc extends Bloc<CategoriesEvent, CategoriesState> {
10-
final DataRepository dataRepository = DataRepository();
11-
1210
CategoriesBloc() : super(CategoriesState()) {
1311
on<CategoriesLoaded>(_mapCategoriesLoadedEventToState);
1412
}
13+
final DataRepository dataRepository = DataRepository();
1514

1615
Future<void> _mapCategoriesLoadedEventToState(
1716
CategoriesLoaded event,

lib/src/blocs/categories/categories_state.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ enum CategoriesStatus {
88
}
99

1010
class CategoriesState extends Equatable {
11-
final CategoriesStatus status;
12-
final String? error;
13-
final Iterable<Category>? categories;
14-
final Iterable<RecipeStub?>? recipes;
15-
1611
CategoriesState({
1712
this.status = CategoriesStatus.loadInProgress,
1813
this.error,
@@ -33,6 +28,10 @@ class CategoriesState extends Equatable {
3328
assert(error != null && categories == null && recipes == null);
3429
}
3530
}
31+
final CategoriesStatus status;
32+
final String? error;
33+
final Iterable<Category>? categories;
34+
final Iterable<RecipeStub?>? recipes;
3635

3736
@override
3837
List<Object?> get props => [status, error, categories];

lib/src/blocs/login/login_bloc.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@ part 'login_event.dart';
99
part 'login_state.dart';
1010

1111
class LoginBloc extends Bloc<LoginEvent, LoginState> {
12-
final UserRepository userRepository = UserRepository();
13-
final AuthenticationBloc authenticationBloc;
14-
1512
LoginBloc({
1613
required this.authenticationBloc,
1714
}) : super(LoginState()) {
1815
on<LoginButtonPressed>(_mapLoginButtonPressedEventToState);
1916
}
17+
final UserRepository userRepository = UserRepository();
18+
final AuthenticationBloc authenticationBloc;
2019

2120
Future<void> _mapLoginButtonPressedEventToState(
2221
LoginButtonPressed event,

lib/src/blocs/login/login_event.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,18 @@ abstract class LoginEvent extends Equatable {
88
}
99

1010
class LoginButtonPressed extends LoginEvent {
11-
final String serverURL;
12-
final String username;
13-
final String originalBasicAuth;
14-
final bool isAppPassword;
15-
final bool isSelfSignedCertificate;
16-
1711
const LoginButtonPressed({
1812
required this.serverURL,
1913
required this.username,
2014
required this.originalBasicAuth,
2115
required this.isAppPassword,
2216
required this.isSelfSignedCertificate,
2317
});
18+
final String serverURL;
19+
final String username;
20+
final String originalBasicAuth;
21+
final bool isAppPassword;
22+
final bool isSelfSignedCertificate;
2423

2524
@override
2625
List<Object> get props =>

lib/src/blocs/login/login_state.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,15 @@ enum LoginStatus {
77
}
88

99
class LoginState extends Equatable {
10-
final LoginStatus status;
11-
final String? error;
12-
1310
const LoginState({
1411
this.status = LoginStatus.initial,
1512
this.error,
1613
}) : assert(
1714
(status != LoginStatus.failure && error == null) ||
1815
(status == LoginStatus.failure && error != null),
1916
);
17+
final LoginStatus status;
18+
final String? error;
2019

2120
@override
2221
List<Object?> get props => [status, error];

0 commit comments

Comments
 (0)