-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add exclude config to the
cyclomatic_complexity
rule
- Loading branch information
Showing
7 changed files
with
114 additions
and
15 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
28 changes: 17 additions & 11 deletions
28
lib/src/lints/cyclomatic_complexity/models/cyclomatic_complexity_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,19 +1,25 @@ | ||
/// Cyclomatic complexity metric limits configuration. | ||
import 'package:solid_lints/src/lints/cyclomatic_complexity/models/max_cyclomatic_complexity_parameters.dart'; | ||
import 'package:solid_lints/src/models/ignored_entities_model/ignored_entities_model.dart'; | ||
|
||
/// Config parameters for the `cyclomatic_complexity` rule | ||
class CyclomaticComplexityParameters { | ||
/// Threshold cyclomatic complexity level, exceeding it triggers a warning. | ||
final int maxComplexity; | ||
/// `max_complexity` configuration | ||
final MaxCyclomaticComplexityParameters maxCyclomaticComplexity; | ||
|
||
/// Reference: NIST 500-235 item 2.5 | ||
static const _defaultMaxComplexity = 10; | ||
/// `exclude` configuration | ||
final IgnoredEntitiesModel ignoredEntities; | ||
|
||
/// Constructor for [CyclomaticComplexityParameters] model | ||
const CyclomaticComplexityParameters({ | ||
required this.maxComplexity, | ||
required this.maxCyclomaticComplexity, | ||
required this.ignoredEntities, | ||
}); | ||
|
||
/// Method for creating from json data | ||
factory CyclomaticComplexityParameters.fromJson(Map<String, Object?> json) => | ||
CyclomaticComplexityParameters( | ||
maxComplexity: json['max_complexity'] as int? ?? _defaultMaxComplexity, | ||
); | ||
/// | ||
factory CyclomaticComplexityParameters.fromJson(Map<String, Object?> json) { | ||
return CyclomaticComplexityParameters( | ||
ignoredEntities: IgnoredEntitiesModel.fromJson(json), | ||
maxCyclomaticComplexity: MaxCyclomaticComplexityParameters.fromJson(json), | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
lib/src/lints/cyclomatic_complexity/models/max_cyclomatic_complexity_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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// Cyclomatic complexity metric limits configuration. | ||
class MaxCyclomaticComplexityParameters { | ||
/// Threshold cyclomatic complexity level, exceeding it triggers a warning. | ||
final int maxComplexity; | ||
|
||
/// Reference: NIST 500-235 item 2.5 | ||
static const _defaultMaxComplexity = 10; | ||
|
||
/// Constructor for [MaxCyclomaticComplexityParameters] model | ||
const MaxCyclomaticComplexityParameters({ | ||
required this.maxComplexity, | ||
}); | ||
|
||
/// Method for creating from json data | ||
factory MaxCyclomaticComplexityParameters.fromJson( | ||
Map<String, Object?> json, | ||
) => | ||
MaxCyclomaticComplexityParameters( | ||
maxComplexity: json['max_complexity'] as int? ?? _defaultMaxComplexity, | ||
); | ||
} |
4 changes: 2 additions & 2 deletions
4
lib/src/models/ignored_entities_model/ignored_entities_model.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
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,13 @@ | ||
analyzer: | ||
plugins: | ||
- ../custom_lint | ||
|
||
custom_lint: | ||
rules: | ||
- cyclomatic_complexity: | ||
max_complexity: 4 | ||
exclude: | ||
- method_name: excludeMethod | ||
class_name: ExcludeClass | ||
- method_name: excludeFunction | ||
- class_name: ExcludeEntireClass |
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