Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit 7e30f04

Browse files
authored
feat: support detailed metric config with backward compatibility (#510)
1 parent 3270891 commit 7e30f04

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/src/analyzers/lint_analyzer/metrics/metric_utils.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ T? readNullableThreshold<T extends num>(
1616
Map<String, Object?> config,
1717
String metricId,
1818
) {
19-
final configValue = config[metricId]?.toString();
19+
final metricConfig = config[metricId];
20+
21+
final configValue = metricConfig is Map<String, Object?>
22+
? metricConfig['threshold']?.toString()
23+
: metricConfig?.toString();
2024

2125
if (configValue != null && T == int) {
2226
return int.tryParse(configValue) as T?;

test/analyzers/lint_analyzer/metrics/metric_utils_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void main() {
3333

3434
const _config = {
3535
metricId1: '$metricId1Value',
36-
metricId2: '$metricId2Value',
36+
metricId2: {'threshold': '$metricId2Value'},
3737
metricId3: '',
3838
metricId4: null,
3939
};

0 commit comments

Comments
 (0)