Skip to content

Commit

Permalink
issue-167. fixed after comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shaark committed Dec 4, 2024
1 parent bdbfca1 commit 5175b01
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class AvoidReturningWidgetsParameters {
factory AvoidReturningWidgetsParameters.fromJson(Map<String, dynamic> json) {
return AvoidReturningWidgetsParameters(
exclude: ExcludeParameters.fromJson(
excludeList: json['exclude'] as Iterable? ?? [],
excludeList:
json[ExcludeParameters.excludeParameterName] as Iterable? ?? [],
),
);
}
Expand Down
11 changes: 7 additions & 4 deletions lib/src/models/exclude_params.dart
Original file line number Diff line number Diff line change
@@ -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<ExcludeRule> exclude;
final List<ExcludedIdentifiersParameter> exclude;

/// A json value name
static const String excludeParameterName = 'exclude';

/// Constructor for [ExcludeParameters] model
ExcludeParameters({
Expand All @@ -17,11 +20,11 @@ class ExcludeParameters {
factory ExcludeParameters.fromJson({
required Iterable<dynamic> excludeList,
}) {
final exclude = <ExcludeRule>[];
final exclude = <ExcludedIdentifiersParameter>[];

for (final item in excludeList) {
if (item is Map) {
exclude.add(ExcludeRule.fromJson(item));
exclude.add(ExcludedIdentifiersParameter.fromJson(item));
}
}
return ExcludeParameters(
Expand Down
Original file line number Diff line number Diff line change
@@ -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<dynamic, dynamic> json,
) {
return ExcludeRule(
return ExcludedIdentifiersParameter(
methodName: json['method_name'] as String,
className: json['class_name'] as String?,
);
Expand Down

0 comments on commit 5175b01

Please sign in to comment.