Skip to content

Commit

Permalink
Chore: Update to RydMike lints 2.3.0 and fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
rydmike committed Dec 28, 2024
1 parent d395b43 commit 774c0ee
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 65 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ All changes to the **FlexColorScheme** (FCS) package are documented here.

## 8.1.0

**Dec 28, 2024**
**Dec 29, 2024**

### Package

Expand Down
77 changes: 46 additions & 31 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
# RydMike LINTER Preferences v2.3.0
# TODO(rydmike): Review and publish this v2.3.0 updated version.
#
# Get this file here: https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
#
# We include and activate all lint rules, later below we disable the not used or desired ones.
# You can find a list of all lint rules to put in your all_lint_rules.yaml file here:
# https://dart.dev/tools/linter-rules/all
#
# This version is updated for Flutter 3.27 and Dart 3.6.
#
# For a comparison of all lint rules settings in rule styles listed below, please see this Google
# sheet: https://docs.google.com/spreadsheets/d/1Nc1gFjmCOMubWZD7f2E4fLhWN7LYaOE__tsA7bf2NjA
#
# Versions used for comparison:
# TODO(rydmike): Update the used comparisons to their latest version.
#
# Core v3.0.0 : https://pub.dev/packages/lints
# Recommended v3.0.0 : https://pub.dev/packages/lints
# Flutter Lints v3.0.1 : https://pub.dev/packages/flutter_lints
# Core v5.1.1 : https://pub.dev/packages/lints
# Recommended v5.1.1 : https://pub.dev/packages/lints
# Flutter Lints v5.0.0 : https://pub.dev/packages/flutter_lints
# Pedantic v1.11.1 : https://pub.dev/packages/pedantic
# Effective Dart v1.3.2 : https://pub.dev/packages/effective_dart
# Flutter repo master : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
# Lint v2.2.0 : https://pub.dev/packages/lint
# VG Analysis v5.1.0 : https://pub.dev/packages/very_good_analysis
# RydMike v2.1.0 : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
#
# Lint v2.3.0 : https://pub.dev/packages/lint
# VG Analysis v7.0.0 : https://pub.dev/packages/very_good_analysis
# RydMike v2.3.0 : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
include: all_lint_rules.yaml
analyzer:
exclude:
Expand Down Expand Up @@ -249,6 +248,9 @@ linter:
# where we voluntarily want to catch everything, especially as a library.
# See https://github.com/dart-lang/linter/issues/3023
#
# The above issue has been resolved and closed, so the rule is now enabled
# starting in version 2.3.0.
#
# Other known linters use:
#
# Core disabled : https://pub.dev/packages/lints
Expand All @@ -259,8 +261,11 @@ linter:
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
# Lint disabled : https://pub.dev/packages/lint
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
# RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
avoid_catches_without_on_clauses: false
# RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
# PACKAGE: enabled : By commenting it out below.
# APPLICATION: disabled : With false value.
#
#avoid_catches_without_on_clauses: false

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

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

Expand Down Expand Up @@ -692,8 +700,8 @@ linter:
# Pedantic disabled : https://pub.dev/packages/pedantic
# Effective Dart disabled : https://pub.dev/packages/effective_dart
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
# Lint ? : https://pub.dev/packages/lint
# VG Analysis ? : https://pub.dev/packages/very_good_analysis
# Lint disabled : https://pub.dev/packages/lint
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
# RydMike disabled : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
omit_obvious_local_variable_types: false

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

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

# DON'T use final for local variables.
#
Expand Down
28 changes: 28 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,34 @@ linter:
# APPLICATION: disabled : With false value. (Default, assume we are making an app most of the time.)
diagnostic_describe_all_properties: false

# AVOID catches without on clauses.
#
# https://dart.dev/tools/linter-rules/avoid_catches_without_on_clauses.html
#
# Using catch clauses without on clauses makes your code prone to encountering unexpected
# errors that won't be thrown (and thus will go unnoticed). However, there are situations
# where we voluntarily want to catch everything, especially as a library.
# See https://github.com/dart-lang/linter/issues/3023
#
# The above issue has been resolved and closed, so the rule is now enabled
# starting in version 2.3.0, in packages, keeping it disabled in example and
# Playground apps for now.
#
# Other known linters use:
#
# Core disabled : https://pub.dev/packages/lints
# Recommended disabled : https://pub.dev/packages/lints
# Flutter Lints disabled : https://pub.dev/packages/flutter_lints
# Pedantic disabled : https://pub.dev/packages/pedantic
# Effective Dart enabled : https://pub.dev/packages/effective_dart
# Flutter repo disabled : https://github.com/flutter/flutter/blob/master/analysis_options.yaml
# Lint disabled : https://pub.dev/packages/lint
# VG Analysis disabled : https://pub.dev/packages/very_good_analysis
# RydMike : https://gist.github.com/rydmike/fdb53ddd933c37d20e6f3188a936cd4c
# PACKAGE: enabled : By commenting it out below.
# APPLICATION: disabled : With false value.
avoid_catches_without_on_clauses: false

# DO document all public members.
#
# https://dart-lang.github.io/linter/lints/public_member_api_docs.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class CodeTheme extends ThemeExtension<CodeTheme> {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class TopicTheme extends ThemeExtension<TopicTheme> {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ enum JsonKeys {
typeEnumVisualDensity(key: 'enum_visual_density'),
value(key: 'value');

final String key;
const JsonKeys({required this.key});
final String key;
}

/// A function that exports the theme playground settings to JSON.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const bool _debug = !kReleaseMode && true;
/// This implementation listens to URL changes and calls the provided callback
/// when the query parameters change.
class QueryParamsHandler implements QueryParamsHandlerInterface {
final void Function(Map<String, String> params) _onParamsChanged;
StreamSubscription<web.PopStateEvent>? _popStateSubscription;
JSFunction? _locationChangeListener;

QueryParamsHandler(this._onParamsChanged) {
_initializeWebListener();
}

final void Function(Map<String, String> params) _onParamsChanged;
StreamSubscription<web.PopStateEvent>? _popStateSubscription;
JSFunction? _locationChangeListener;

void _initializeWebListener() {
// Listen to PopState events (handles both URL changes and history changes)
_popStateSubscription = web.window.onPopState.listen((_) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import 'package:flutter/material.dart';
/// A ShapeBorder that can draw left and right side outline borders with
/// different thickness and colors.
class VerticalShapeBorder extends ShapeBorder {
final double cornerRadius;
final BorderSide leftSide;
final BorderSide rightSide;

const VerticalShapeBorder({
this.cornerRadius = 8.0,
this.leftSide = BorderSide.none,
this.rightSide = BorderSide.none,
});

final double cornerRadius;
final BorderSide leftSide;
final BorderSide rightSide;

@override
EdgeInsetsGeometry get dimensions =>
EdgeInsets.fromLTRB(leftSide.width, 0, rightSide.width, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ class _ButtonsState extends State<Buttons> {
}

class ButtonsWithoutIcon extends StatelessWidget {
final bool isDisabled;

const ButtonsWithoutIcon({super.key, required this.isDisabled});
final bool isDisabled;

@override
Widget build(BuildContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,10 @@ class _SearchBarState extends State<SearchBar> {
}

class Category {
const Category({required this.title, required this.selections});

final String title;
final List<String> selections;

Category({required this.title, required this.selections});
}

void _pushScreen({required BuildContext context, required Widget screen}) {
Expand All @@ -911,6 +911,15 @@ void _pushScreen({required BuildContext context, required Widget screen}) {
}

class Product {
const Product(
{required this.name,
required this.imageUrls,
required this.cost,
this.description,
this.sizes,
required this.category,
required this.productType});

final String name;
final List<String> imageUrls;
final double cost;
Expand All @@ -922,15 +931,6 @@ class Product {

/// Represents type of product such as shirt, jeans, pet treats, etc.
final String productType;

Product(
{required this.name,
required this.imageUrls,
required this.cost,
this.description,
this.sizes,
required this.category,
required this.productType});
}

class Cart extends ChangeNotifier {
Expand Down Expand Up @@ -1054,17 +1054,17 @@ class OrderItem {
String? selectedColor;
}

Category _mensCategory = Category(title: 'Men', selections: <String>[
Category _mensCategory = const Category(title: 'Men', selections: <String>[
'Shirts',
'Jeans',
'Shorts',
'Jackets',
]);
Category _womensCategory = Category(title: 'Women', selections: <String>[
Category _womensCategory = const Category(title: 'Women', selections: <String>[
'Shirts',
'Jeans',
]);
Category _petsCategory = Category(title: 'Pets', selections: <String>[
Category _petsCategory = const Category(title: 'Pets', selections: <String>[
'Toys',
'Treats',
]);
Expand Down
Loading

0 comments on commit 774c0ee

Please sign in to comment.