-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
part of 'avoid_late_keyword_parameters.dart'; | ||
|
||
class _ConfigParser { | ||
static const _allowInitializedConfig = 'allow_initialized'; | ||
static const _ignoredTypesConfig = 'ignored_types'; | ||
|
||
static bool parseAllowInitialized(Map<String, Object?> config) => | ||
config[_allowInitializedConfig] as bool? ?? false; | ||
|
||
static Iterable<String> parseIgnoredTypes(Map<String, Object?> config) => | ||
config.containsKey(_ignoredTypesConfig) && | ||
config[_ignoredTypesConfig] is Iterable | ||
? List<String>.from(config[_ignoredTypesConfig] as Iterable) | ||
: <String>['AnimationController']; | ||
} |
13 changes: 10 additions & 3 deletions
13
lib/lints/avoid_late_keyword/models/avoid_late_keyword_parameters.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
part '_config_parser.dart'; | ||
|
||
/// A data model class that represents the "avoid late keyword" input | ||
/// parameters. | ||
class AvoidLateKeywordParameters { | ||
/// Maximum number of parameters | ||
/// Allow to dynamically initialize | ||
final bool allowInitialized; | ||
|
||
/// Types that would be ignored by avoid-late rule | ||
final Iterable<String> ignoredTypes; | ||
|
||
/// Constructor for [AvoidLateKeywordParameters] model | ||
const AvoidLateKeywordParameters({ | ||
this.allowInitialized = false, | ||
this.allowInitialized = false, | ||
this.ignoredTypes = const [], | ||
}); | ||
|
||
/// Method for creating from json data | ||
factory AvoidLateKeywordParameters.fromJson(Map<String, Object?> json) => | ||
AvoidLateKeywordParameters( | ||
allowInitialized: json['allow_initialized'] as bool?, | ||
allowInitialized: _ConfigParser.parseAllowInitialized(json), | ||
ignoredTypes: _ConfigParser.parseIgnoredTypes(json), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters