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

Commit b3d2806

Browse files
authored
refactor: cleanup metric documentation (#547)
* refactor: cleanup metric documentation * refactor: file metrics collector
1 parent 39011e5 commit b3d2806

File tree

18 files changed

+38
-39
lines changed

18 files changed

+38
-39
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
* feat: introduce file metrics
6+
* refactor: cleanup metric documentation
67

78
## 4.6.0
89

lib/src/analyzers/lint_analyzer/lint_analyzer.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ class LintAnalyzer {
194194
final classMetrics =
195195
_checkClassMetrics(visitor, internalResult, config);
196196

197+
final fileMetrics = _checkFileMetrics(internalResult);
198+
197199
final functionMetrics =
198200
_checkFunctionMetrics(visitor, internalResult, config);
199201

@@ -208,12 +210,7 @@ class LintAnalyzer {
208210
return LintFileReport(
209211
path: filePath,
210212
relativePath: relativePath,
211-
file: Report(
212-
location:
213-
nodeLocation(node: internalResult.unit, source: internalResult),
214-
metrics: const [],
215-
declaration: internalResult.unit,
216-
),
213+
file: fileMetrics,
217214
classes: Map.unmodifiable(classMetrics
218215
.map<String, Report>((key, value) => MapEntry(key.name, value))),
219216
functions: Map.unmodifiable(functionMetrics.map<String, Report>(
@@ -325,6 +322,16 @@ class LintAnalyzer {
325322
return classRecords;
326323
}
327324

325+
Report _checkFileMetrics(InternalResolvedUnitResult source) {
326+
final metrics = <MetricValue<num>>[];
327+
328+
return Report(
329+
location: nodeLocation(node: source.unit, source: source),
330+
declaration: source.unit,
331+
metrics: metrics,
332+
);
333+
}
334+
328335
Map<ScopedFunctionDeclaration, Report> _checkFunctionMetrics(
329336
ScopeVisitor visitor,
330337
InternalResolvedUnitResult source,

lib/src/analyzers/lint_analyzer/metrics/metrics_list/cyclomatic_complexity/cyclomatic_complexity_metric.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import 'cyclomatic_complexity_flow_visitor.dart';
1919
const _documentation = MetricDocumentation(
2020
name: 'Cyclomatic Complexity',
2121
shortName: 'CYCLO',
22-
brief: 'The number of linearly-independent paths through a code block',
2322
measuredType: EntityType.methodEntity,
2423
recomendedThreshold: 20,
2524
);

lib/src/analyzers/lint_analyzer/metrics/metrics_list/halstead_volume/halstead_volume_metric.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import 'halstead_volume_ast_visitor.dart';
1616
const _documentation = MetricDocumentation(
1717
name: 'Halstead Volume',
1818
shortName: 'HALVOL',
19-
brief:
20-
'The Halstead Volume is based on the Length and the Vocabulary. You can view this as the "bulk" of the code – how much information does the reader of the code have to absorb to understand its meaning. The biggest influence on the Volume metric is the Halstead length which causes a linear increase in the Volume i.e doubling the Length will double the Volume. In the case of the Vocabulary the increase is logarithmic.',
2119
measuredType: EntityType.methodEntity,
2220
recomendedThreshold: 150,
2321
);

lib/src/analyzers/lint_analyzer/metrics/metrics_list/lines_of_code_metric.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import '../models/metric_value.dart';
1313
const _documentation = MetricDocumentation(
1414
name: 'Lines of Code',
1515
shortName: 'LOC',
16-
brief:
17-
'The number of physical lines of code of a method, including blank lines and comments',
1816
measuredType: EntityType.methodEntity,
1917
recomendedThreshold: 100,
2018
);

lib/src/analyzers/lint_analyzer/metrics/metrics_list/maintainability_index_metric.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import 'source_lines_of_code/source_lines_of_code_metric.dart';
1818
const _documentation = MetricDocumentation(
1919
name: 'Maintainability Index',
2020
shortName: 'MI',
21-
brief:
22-
'Maintainability Index is a software metric which measures how maintainable (easy to support and change) the source code is.',
2321
measuredType: EntityType.methodEntity,
2422
recomendedThreshold: 50,
2523
);

lib/src/analyzers/lint_analyzer/metrics/metrics_list/maximum_nesting_level/maximum_nesting_level_metric.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import 'nesting_level_visitor.dart';
1717
const _documentation = MetricDocumentation(
1818
name: 'Maximum Nesting Level',
1919
shortName: 'MAXNESTING',
20-
brief: 'The maximum nesting level of control structures within a method',
2120
measuredType: EntityType.methodEntity,
2221
recomendedThreshold: 5,
2322
);

lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_methods_metric.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import '../scope_utils.dart';
1616
const _documentation = MetricDocumentation(
1717
name: 'Number of Methods',
1818
shortName: 'NOM',
19-
brief: 'The number of methods of a class.',
2019
measuredType: EntityType.classEntity,
2120
recomendedThreshold: 10,
2221
);

lib/src/analyzers/lint_analyzer/metrics/metrics_list/number_of_parameters_metric.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import '../models/metric_value.dart';
1414
const _documentation = MetricDocumentation(
1515
name: 'Number of Parameters',
1616
shortName: 'NOP',
17-
brief: 'Number of parameters received by a method',
1817
measuredType: EntityType.methodEntity,
1918
recomendedThreshold: 4,
2019
);

lib/src/analyzers/lint_analyzer/metrics/metrics_list/source_lines_of_code/source_lines_of_code_metric.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import 'source_code_visitor.dart';
1616
const _documentation = MetricDocumentation(
1717
name: 'Source lines of Code',
1818
shortName: 'SLOC',
19-
brief:
20-
'The approximate number of source code lines in a method, blank lines and comments are not counted.',
2119
measuredType: EntityType.methodEntity,
2220
recomendedThreshold: 50,
2321
);

0 commit comments

Comments
 (0)