From 5175b010fca545652354cb3b5fae3f88d886dba0 Mon Sep 17 00:00:00 2001 From: shaark Date: Wed, 4 Dec 2024 15:37:29 +0200 Subject: [PATCH] issue-167. fixed after comments --- .../models/avoid_returning_widgets_parameters.dart | 3 ++- lib/src/models/exclude_params.dart | 11 +++++++---- ..._rule.dart => excluded_identifiers_parameter.dart} | 10 +++++----- 3 files changed, 14 insertions(+), 10 deletions(-) rename lib/src/models/{exclude_rule.dart => excluded_identifiers_parameter.dart} (66%) diff --git a/lib/src/lints/avoid_returning_widgets/models/avoid_returning_widgets_parameters.dart b/lib/src/lints/avoid_returning_widgets/models/avoid_returning_widgets_parameters.dart index 19c4eef..56c47b6 100644 --- a/lib/src/lints/avoid_returning_widgets/models/avoid_returning_widgets_parameters.dart +++ b/lib/src/lints/avoid_returning_widgets/models/avoid_returning_widgets_parameters.dart @@ -15,7 +15,8 @@ class AvoidReturningWidgetsParameters { factory AvoidReturningWidgetsParameters.fromJson(Map json) { return AvoidReturningWidgetsParameters( exclude: ExcludeParameters.fromJson( - excludeList: json['exclude'] as Iterable? ?? [], + excludeList: + json[ExcludeParameters.excludeParameterName] as Iterable? ?? [], ), ); } diff --git a/lib/src/models/exclude_params.dart b/lib/src/models/exclude_params.dart index 753cf1d..88d06eb 100644 --- a/lib/src/models/exclude_params.dart +++ b/lib/src/models/exclude_params.dart @@ -1,12 +1,15 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:collection/collection.dart'; -import 'package:solid_lints/src/models/exclude_rule.dart'; +import 'package:solid_lints/src/models/excluded_identifiers_parameter.dart'; /// A data model class that represents the "avoid returning widgets" input /// parameters. class ExcludeParameters { /// A list of methods that should be excluded from the lint. - final List exclude; + final List exclude; + + /// A json value name + static const String excludeParameterName = 'exclude'; /// Constructor for [ExcludeParameters] model ExcludeParameters({ @@ -17,11 +20,11 @@ class ExcludeParameters { factory ExcludeParameters.fromJson({ required Iterable excludeList, }) { - final exclude = []; + final exclude = []; for (final item in excludeList) { if (item is Map) { - exclude.add(ExcludeRule.fromJson(item)); + exclude.add(ExcludedIdentifiersParameter.fromJson(item)); } } return ExcludeParameters( diff --git a/lib/src/models/exclude_rule.dart b/lib/src/models/excluded_identifiers_parameter.dart similarity index 66% rename from lib/src/models/exclude_rule.dart rename to lib/src/models/excluded_identifiers_parameter.dart index 2231a4b..f222d17 100644 --- a/lib/src/models/exclude_rule.dart +++ b/lib/src/models/excluded_identifiers_parameter.dart @@ -1,22 +1,22 @@ /// Model class for ExcludeRule parameters -class ExcludeRule { +class ExcludedIdentifiersParameter { /// The name of the method that should be excluded from the lint. final String methodName; /// The name of the class that should be excluded from the lint. final String? className; - /// Constructor for [ExcludeRule] model - const ExcludeRule({ + /// Constructor for [ExcludedIdentifiersParameter] model + const ExcludedIdentifiersParameter({ required this.methodName, required this.className, }); /// - factory ExcludeRule.fromJson( + factory ExcludedIdentifiersParameter.fromJson( Map json, ) { - return ExcludeRule( + return ExcludedIdentifiersParameter( methodName: json['method_name'] as String, className: json['class_name'] as String?, );