Skip to content

Commit 774c0ee

Browse files
committed
Chore: Update to RydMike lints 2.3.0 and fix lints
1 parent d395b43 commit 774c0ee

19 files changed

+219
-65
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All changes to the **FlexColorScheme** (FCS) package are documented here.
44

55
## 8.1.0
66

7-
**Dec 28, 2024**
7+
**Dec 29, 2024**
88

99
### Package
1010

analysis_options.yaml

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
# RydMike LINTER Preferences v2.3.0
2-
# TODO(rydmike): Review and publish this v2.3.0 updated version.
32
#
43
# Get this file here: https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
54
#
65
# We include and activate all lint rules, later below we disable the not used or desired ones.
76
# You can find a list of all lint rules to put in your all_lint_rules.yaml file here:
87
# https://dart.dev/tools/linter-rules/all
98
#
9+
# This version is updated for Flutter 3.27 and Dart 3.6.
10+
#
1011
# For a comparison of all lint rules settings in rule styles listed below, please see this Google
1112
# sheet: https://docs.google.com/spreadsheets/d/1Nc1gFjmCOMubWZD7f2E4fLhWN7LYaOE__tsA7bf2NjA
1213
#
1314
# Versions used for comparison:
14-
# TODO(rydmike): Update the used comparisons to their latest version.
1515
#
16-
# Core v3.0.0 : https://pub.dev/packages/lints
17-
# Recommended v3.0.0 : https://pub.dev/packages/lints
18-
# Flutter Lints v3.0.1 : https://pub.dev/packages/flutter_lints
16+
# Core v5.1.1 : https://pub.dev/packages/lints
17+
# Recommended v5.1.1 : https://pub.dev/packages/lints
18+
# Flutter Lints v5.0.0 : https://pub.dev/packages/flutter_lints
1919
# Pedantic v1.11.1 : https://pub.dev/packages/pedantic
2020
# Effective Dart v1.3.2 : https://pub.dev/packages/effective_dart
2121
# Flutter repo master : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
22-
# Lint v2.2.0 : https://pub.dev/packages/lint
23-
# VG Analysis v5.1.0 : https://pub.dev/packages/very_good_analysis
24-
# RydMike v2.1.0 : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
25-
#
22+
# Lint v2.3.0 : https://pub.dev/packages/lint
23+
# VG Analysis v7.0.0 : https://pub.dev/packages/very_good_analysis
24+
# RydMike v2.3.0 : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
2625
include: all_lint_rules.yaml
2726
analyzer:
2827
exclude:
@@ -249,6 +248,9 @@ linter:
249248
# where we voluntarily want to catch everything, especially as a library.
250249
# See https://github.com/dart-lang/linter/issues/3023
251250
#
251+
# The above issue has been resolved and closed, so the rule is now enabled
252+
# starting in version 2.3.0.
253+
#
252254
# Other known linters use:
253255
#
254256
# Core disabled : https://pub.dev/packages/lints
@@ -259,8 +261,11 @@ linter:
259261
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
260262
# Lint disabled : https://pub.dev/packages/lint
261263
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
262-
# RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
263-
avoid_catches_without_on_clauses: false
264+
# RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
265+
# PACKAGE: enabled : By commenting it out below.
266+
# APPLICATION: disabled : With false value.
267+
#
268+
#avoid_catches_without_on_clauses: false
264269

265270
# AVOID defining a class that contains only static members.
266271
#
@@ -501,8 +506,9 @@ linter:
501506
#
502507
# https://dart.dev/tools/linter-rules/diagnostic_describe_all_properties.html
503508
#
504-
# Consider using this lint rule if you are making a public Flutter package, for private ones and private apps
505-
# we recommend keeping it off as you probably won't be making diagnostic properties for all your
509+
# Consider using this lint rule if you are making a public Flutter package.
510+
# For private ones and private apps we recommend keeping it off as you probably
511+
# won't be making diagnostic properties for all your
506512
# classes, unless you are using a data class lib that does it for you via code generation.
507513
#
508514
# Other known linters use:
@@ -513,10 +519,10 @@ linter:
513519
# Pedantic disabled : https://pub.dev/packages/pedantic
514520
# Effective Dart disabled : https://pub.dev/packages/effective_dart
515521
# Lint disabled : https://pub.dev/packages/lint
516-
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
522+
# Flutter repo ENABLED? disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
517523
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
518524
# RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
519-
# PACKAGE: enabled : By commenting it out.
525+
# PACKAGE: enabled : By commenting it out, sometimes use it, not always.
520526
# APPLICATION: disabled : With false value. (Default, assume we are making an app most of the time.)
521527
diagnostic_describe_all_properties: false
522528

@@ -549,8 +555,10 @@ linter:
549555
#
550556
# Document ignore comments.
551557
#
552-
# RydMike: THis is good, but putting it false for now, as it is triggered a lot
553-
# in code bases that did not do this. Consider keeping it on for new projects.
558+
# RydMike: This is good, but putting it false for now. This lint is triggered a lot
559+
# in our code bases that did not do this originally.
560+
# Consider enabling it for new projects. May enable later in older projects too and
561+
# add explanations to all the ignored rules.
554562
#
555563
# Other known linters use:
556564
#
@@ -561,7 +569,7 @@ linter:
561569
# Effective Dart disabled : https://pub.dev/packages/effective_dart
562570
# Lint disabled : https://pub.dev/packages/lint
563571
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
564-
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
572+
# VG Analysis enabled : https://pub.dev/packages/very_good_analysis
565573
# RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
566574
document_ignores: false
567575

@@ -692,8 +700,8 @@ linter:
692700
# Pedantic disabled : https://pub.dev/packages/pedantic
693701
# Effective Dart disabled : https://pub.dev/packages/effective_dart
694702
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
695-
# Lint ? : https://pub.dev/packages/lint
696-
# VG Analysis ? : https://pub.dev/packages/very_good_analysis
703+
# Lint disabled : https://pub.dev/packages/lint
704+
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
697705
# RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
698706
omit_obvious_local_variable_types: false
699707

@@ -797,8 +805,8 @@ linter:
797805
#
798806
# https://dart.dev/tools/linter-rules/prefer_expression_function_bodies.html
799807
#
800-
# Certainly a good idea in many cases, but not always. For example, not always suitable for
801-
# Flutter, which may have a `build` method with a single return, but that return is still
808+
# Certainly a good idea in many cases, but not always. For example, it is not always suitable for
809+
# Flutter, which may have a `build` method with a single return. This return is still
802810
# complex enough that a "body" is worth it, and it might not even fit on a single line.
803811
# https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#consider-using--for-short-functions-and-methods
804812
#
@@ -850,7 +858,7 @@ linter:
850858
# https://dart.dev/tools/linter-rules/prefer_int_literals.html
851859
#
852860
# This rule goes against the preferred style of being explicit with
853-
# declarations and hides when a number is double, since we cannot declare it
861+
# declarations and hides when a number is double. We cannot declare it
854862
# as 0.0 or 1.0 when it is double, it has to be 0 or 1, making it look
855863
# like an integer, even if it is not. Sometimes doing that is OK, but let's
856864
# not enforce it.
@@ -893,11 +901,11 @@ linter:
893901
# Effective Dart enabled : https://pub.dev/packages/effective_dart
894902
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
895903
# Lint disabled : https://pub.dev/packages/lint
896-
# VG Analysis enabled : https://pub.dev/packages/very_good_analysis
904+
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
897905
# RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
898906
# PACKAGE: enabled : By commenting it out. (My default, I start with this)
899907
# APPLICATION: disabled : With false value. (But usually uncomment the false value if it is an app)
900-
public_member_api_docs: false
908+
#public_member_api_docs: false
901909

902910
# DO use trailing commas for all function calls and declarations unless the function call or
903911
# definition, from the start of the function name up to the closing parenthesis,
@@ -926,13 +934,20 @@ linter:
926934
#
927935
# We do like this lint rule, but we want to have the default constructor first, followed
928936
# by its properties, after this, other named constructors and factories. This rule gets
929-
# in the way of that and forces you to put (often final) constructor properties after all
937+
# in the way of that. It forces you to put (often final) constructor properties after all
930938
# the named constructors and factories, making them tedious to find and disconnected from
931939
# where we want to see, read and handily edit them. This is especially the case if there are
932940
# many constructors and factories, and they have a lot of parameters. For now, we disable
933-
# this rule and order things as described above, which apart from the default constructor
934-
# properties coming right after the constructor, is the only part where we in practice
935-
# deviate from this rule, so other yes, we do put constructors first as well anyway.
941+
# this rule and order things as described above. The default constructor properties coming
942+
# right after the constructor, is the only part where we in practice
943+
# deviate from this rule, so otherwise yes, we do put constructors first as well anyway.
944+
#
945+
# From version v2.3.0 started using this rule, but add exceptions for files with
946+
# classes that have a lot of properties and factory constructors. In those cases,
947+
# we disable this rule, so we can get a better overview of the class properties
948+
# and main constructor, before the factory constructors.
949+
#
950+
# Remove the comment below to disable this rule again.
936951
#
937952
# Other known linters use:
938953
#
@@ -945,8 +960,8 @@ linter:
945960
# Lint disabled : https://pub.dev/packages/lint
946961
# Discussion https://github.com/passsy/dart-lint/issues/1
947962
# VG Analysis enabled : https://pub.dev/packages/very_good_analysis
948-
# RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
949-
sort_constructors_first: false
963+
# RydMike enabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
964+
# sort_constructors_first: false
950965

951966
# DON'T use final for local variables.
952967
#

example/analysis_options.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,34 @@ linter:
2525
# APPLICATION: disabled : With false value. (Default, assume we are making an app most of the time.)
2626
diagnostic_describe_all_properties: false
2727

28+
# AVOID catches without on clauses.
29+
#
30+
# https://dart.dev/tools/linter-rules/avoid_catches_without_on_clauses.html
31+
#
32+
# Using catch clauses without on clauses makes your code prone to encountering unexpected
33+
# errors that won't be thrown (and thus will go unnoticed). However, there are situations
34+
# where we voluntarily want to catch everything, especially as a library.
35+
# See https://github.com/dart-lang/linter/issues/3023
36+
#
37+
# The above issue has been resolved and closed, so the rule is now enabled
38+
# starting in version 2.3.0, in packages, keeping it disabled in example and
39+
# Playground apps for now.
40+
#
41+
# Other known linters use:
42+
#
43+
# Core disabled : https://pub.dev/packages/lints
44+
# Recommended disabled : https://pub.dev/packages/lints
45+
# Flutter Lints disabled : https://pub.dev/packages/flutter_lints
46+
# Pedantic disabled : https://pub.dev/packages/pedantic
47+
# Effective Dart enabled : https://pub.dev/packages/effective_dart
48+
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
49+
# Lint disabled : https://pub.dev/packages/lint
50+
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
51+
# RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
52+
# PACKAGE: enabled : By commenting it out below.
53+
# APPLICATION: disabled : With false value.
54+
avoid_catches_without_on_clauses: false
55+
2856
# DO document all public members.
2957
#
3058
# https://dart-lang.github.io/linter/lints/public_member_api_docs.html

example/lib/example5_themes_playground/theme/code_theme.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ class CodeTheme extends ThemeExtension<CodeTheme> {
8989

9090
/// A harmonized code view color theme, based on [brightness] where colors
9191
/// are harmonized towards a given [sourceColor].
92+
// ignore: sort_constructors_first
9293
factory CodeTheme.harmonized(Color sourceColor, Brightness brightness) {
9394
final int sourceColorValue = sourceColor.value32bit;
9495

example/lib/example5_themes_playground/theme/topic_theme.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class TopicTheme extends ThemeExtension<TopicTheme> {
9696

9797
/// A color harmonized topic theme, based on [brightness] where colors
9898
/// are harmonized towards a given [sourceColor].
99+
// ignore: sort_constructors_first
99100
factory TopicTheme.harmonized(Color sourceColor, Brightness brightness) {
100101
final int sourceColorValue = sourceColor.value32bit;
101102

example/lib/example5_themes_playground/utils/import_export_playground_settings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ enum JsonKeys {
5555
typeEnumVisualDensity(key: 'enum_visual_density'),
5656
value(key: 'value');
5757

58-
final String key;
5958
const JsonKeys({required this.key});
59+
final String key;
6060
}
6161

6262
/// A function that exports the theme playground settings to JSON.

example/lib/example5_themes_playground/utils/query_params/query_params_handler_web.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ const bool _debug = !kReleaseMode && true;
1818
/// This implementation listens to URL changes and calls the provided callback
1919
/// when the query parameters change.
2020
class QueryParamsHandler implements QueryParamsHandlerInterface {
21-
final void Function(Map<String, String> params) _onParamsChanged;
22-
StreamSubscription<web.PopStateEvent>? _popStateSubscription;
23-
JSFunction? _locationChangeListener;
24-
2521
QueryParamsHandler(this._onParamsChanged) {
2622
_initializeWebListener();
2723
}
2824

25+
final void Function(Map<String, String> params) _onParamsChanged;
26+
StreamSubscription<web.PopStateEvent>? _popStateSubscription;
27+
JSFunction? _locationChangeListener;
28+
2929
void _initializeWebListener() {
3030
// Listen to PopState events (handles both URL changes and history changes)
3131
_popStateSubscription = web.window.onPopState.listen((_) {

example/lib/example5_themes_playground/utils/vertical_shape_border.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import 'package:flutter/material.dart';
33
/// A ShapeBorder that can draw left and right side outline borders with
44
/// different thickness and colors.
55
class VerticalShapeBorder extends ShapeBorder {
6-
final double cornerRadius;
7-
final BorderSide leftSide;
8-
final BorderSide rightSide;
9-
106
const VerticalShapeBorder({
117
this.cornerRadius = 8.0,
128
this.leftSide = BorderSide.none,
139
this.rightSide = BorderSide.none,
1410
});
1511

12+
final double cornerRadius;
13+
final BorderSide leftSide;
14+
final BorderSide rightSide;
15+
1616
@override
1717
EdgeInsetsGeometry get dimensions =>
1818
EdgeInsets.fromLTRB(leftSide.width, 0, rightSide.width, 0);

example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_material3/component_screen.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,8 @@ class _ButtonsState extends State<Buttons> {
365365
}
366366

367367
class ButtonsWithoutIcon extends StatelessWidget {
368-
final bool isDisabled;
369-
370368
const ButtonsWithoutIcon({super.key, required this.isDisabled});
369+
final bool isDisabled;
371370

372371
@override
373372
Widget build(BuildContext context) {

example/lib/example5_themes_playground/widgets/panels/theme_simulator/app_example_shop.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -897,10 +897,10 @@ class _SearchBarState extends State<SearchBar> {
897897
}
898898

899899
class Category {
900+
const Category({required this.title, required this.selections});
901+
900902
final String title;
901903
final List<String> selections;
902-
903-
Category({required this.title, required this.selections});
904904
}
905905

906906
void _pushScreen({required BuildContext context, required Widget screen}) {
@@ -911,6 +911,15 @@ void _pushScreen({required BuildContext context, required Widget screen}) {
911911
}
912912

913913
class Product {
914+
const Product(
915+
{required this.name,
916+
required this.imageUrls,
917+
required this.cost,
918+
this.description,
919+
this.sizes,
920+
required this.category,
921+
required this.productType});
922+
914923
final String name;
915924
final List<String> imageUrls;
916925
final double cost;
@@ -922,15 +931,6 @@ class Product {
922931

923932
/// Represents type of product such as shirt, jeans, pet treats, etc.
924933
final String productType;
925-
926-
Product(
927-
{required this.name,
928-
required this.imageUrls,
929-
required this.cost,
930-
this.description,
931-
this.sizes,
932-
required this.category,
933-
required this.productType});
934934
}
935935

936936
class Cart extends ChangeNotifier {
@@ -1054,17 +1054,17 @@ class OrderItem {
10541054
String? selectedColor;
10551055
}
10561056

1057-
Category _mensCategory = Category(title: 'Men', selections: <String>[
1057+
Category _mensCategory = const Category(title: 'Men', selections: <String>[
10581058
'Shirts',
10591059
'Jeans',
10601060
'Shorts',
10611061
'Jackets',
10621062
]);
1063-
Category _womensCategory = Category(title: 'Women', selections: <String>[
1063+
Category _womensCategory = const Category(title: 'Women', selections: <String>[
10641064
'Shirts',
10651065
'Jeans',
10661066
]);
1067-
Category _petsCategory = Category(title: 'Pets', selections: <String>[
1067+
Category _petsCategory = const Category(title: 'Pets', selections: <String>[
10681068
'Toys',
10691069
'Treats',
10701070
]);

0 commit comments

Comments
 (0)