This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 258
/
stubs_builders.dart
105 lines (101 loc) · 3.41 KB
/
stubs_builders.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import 'package:code_checker/metrics.dart';
import 'package:dart_code_metrics/src/models/component_record.dart';
import 'package:dart_code_metrics/src/models/component_report.dart';
import 'package:dart_code_metrics/src/models/function_record.dart';
import 'package:dart_code_metrics/src/models/function_report.dart';
ComponentRecord buildComponentRecordStub({
int firstLine = 0,
int lastLine = 0,
int methodsCount = 0,
double weightOfClass = 1,
}) =>
ComponentRecord(
firstLine: firstLine,
lastLine: lastLine,
methodsCount: methodsCount,
weightOfClass: weightOfClass,
);
FunctionRecord buildFunctionRecordStub({
int firstLine = 0,
int lastLine = 0,
int argumentsCount = 0,
Map<int, int> cyclomaticLinesComplexity = const <int, int>{},
Iterable<int> linesWithCode = const <int>[],
Iterable<Iterable<int>> nestingLines = const [<int>[]],
Map<int, int> operators = const <int, int>{},
Map<int, int> operands = const <int, int>{},
}) =>
FunctionRecord(
firstLine: firstLine,
lastLine: lastLine,
argumentsCount: argumentsCount,
cyclomaticComplexityLines: Map.unmodifiable(cyclomaticLinesComplexity),
linesWithCode: linesWithCode,
nestingLines: nestingLines,
operators: Map.unmodifiable(operators),
operands: Map.unmodifiable(operands),
);
ComponentReport buildComponentReportStub({
int methodsCount = 0,
MetricValueLevel methodsCountViolationLevel = MetricValueLevel.none,
double weightOfClass = 1,
MetricValueLevel weightOfClassViolationLevel = MetricValueLevel.none,
}) =>
ComponentReport(
methodsCount: MetricValue<int>(
metricsId: '',
value: methodsCount,
level: methodsCountViolationLevel,
comment: '',
),
weightOfClass: MetricValue<double>(
metricsId: '',
value: weightOfClass,
level: weightOfClassViolationLevel,
comment: '',
),
);
FunctionReport buildFunctionReportStub({
int cyclomaticComplexity = 0,
MetricValueLevel cyclomaticComplexityViolationLevel = MetricValueLevel.none,
int linesOfExecutableCode = 0,
MetricValueLevel linesOfExecutableCodeViolationLevel = MetricValueLevel.none,
double maintainabilityIndex = 0,
MetricValueLevel maintainabilityIndexViolationLevel = MetricValueLevel.none,
int argumentsCount = 0,
MetricValueLevel argumentsCountViolationLevel = MetricValueLevel.none,
int maximumNestingLevel = 0,
MetricValueLevel maximumNestingLevelViolationLevel = MetricValueLevel.none,
}) =>
FunctionReport(
cyclomaticComplexity: MetricValue<int>(
metricsId: '',
value: cyclomaticComplexity,
level: cyclomaticComplexityViolationLevel,
comment: '',
),
linesOfExecutableCode: MetricValue<int>(
metricsId: '',
value: linesOfExecutableCode,
level: linesOfExecutableCodeViolationLevel,
comment: '',
),
maintainabilityIndex: MetricValue<double>(
metricsId: '',
value: maintainabilityIndex,
level: maintainabilityIndexViolationLevel,
comment: '',
),
argumentsCount: MetricValue<int>(
metricsId: '',
value: argumentsCount,
level: argumentsCountViolationLevel,
comment: '',
),
maximumNestingLevel: MetricValue<int>(
metricsId: '',
value: maximumNestingLevel,
level: maximumNestingLevelViolationLevel,
comment: '',
),
);