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

refactor: make violations field of summary lint report record as integer #544

Merged
merged 4 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@
"files.eol": "\n",
"files.insertFinalNewline": true,
"cSpell.words": [
"Backport",
"Gitlab",
"Halstead",
"McCabe's",
"SLOC",
"ansicolor",
"Backport",
"codeclimate",
"codecov",
"cyclomatic",
"dartanalyzer",
"dartdocs",
"dependabot",
"dkrutskikh",
"Gitlab",
"Halstead",
"incendial",
"lcov",
"McCabe's",
"mocktail",
"nullsafety",
"pubignore",
"pubspec",
"semver",
"setstate"
"setstate",
"SLOC",
"unawaited"
]
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

* refactor: make violations field of summary lint report record as integer

## 4.6.0

* feat: CLI now can be compiled to and used as compiled executable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MaintainabilityIndexMetric extends FunctionMetric<int> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue<num>> otherMetricsValues,
Iterable<MetricValue> otherMetricsValues,
) =>
super.supports(
node,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NumberOfParametersMetric extends FunctionMetric<int> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue<num>> otherMetricsValues,
Iterable<MetricValue> otherMetricsValues,
) {
if (node is FunctionDeclaration) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class WeightOfClassMetric extends ClassMetric<double> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue<num>> otherMetricsValues,
Iterable<MetricValue> otherMetricsValues,
) =>
super.supports(
node,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/analyzers/lint_analyzer/metrics/models/metric.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ abstract class Metric<T extends num> {
Iterable<ScopedClassDeclaration> classDeclarations,
Iterable<ScopedFunctionDeclaration> functionDeclarations,
InternalResolvedUnitResult source,
Iterable<MetricValue<num>> otherMetricsValues,
Iterable<MetricValue> otherMetricsValues,
) =>
true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ class SummaryLintReportRecord<T> {
final String title;

final T value;
final T? violations;
final int violations;

const SummaryLintReportRecord({
this.status = SummaryLintReportRecordStatus.none,
required this.title,
required this.value,
this.violations,
this.violations = 0,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@ class LintJsonReporter
SummaryLintReportRecord<Object> record,
) {
final recordValue = record.value;
final recordViolations = record.violations;

return {
'status': record.status.toString(),
'title': record.title,
'value': recordValue is Iterable ? recordValue.toList() : recordValue,
if (recordViolations != null)
'violations': recordViolations is Iterable
? recordViolations.toList()
: recordViolations,
'violations': record.violations,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:dart_code_metrics/src/analyzers/lint_analyzer/reporters/reporter
import 'package:mocktail/mocktail.dart';
import 'package:test/test.dart';

import 'report_example.dart';
import '../report_example.dart';

class IOSinkMock extends Mock implements IOSink {}

Expand Down Expand Up @@ -89,6 +89,7 @@ void main() {
'status': 'none',
'title': 'Scanned package folders',
'value': ['bin', 'example', 'lib', 'test'],
'violations': 0,
}),
);

Expand Down
Empty file.
3 changes: 3 additions & 0 deletions tools/analyzer_plugin/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ environment:

dependencies:
dart_code_metrics: ^4.6.0

dev_dependencies:
lints: ^1.0.1
2 changes: 1 addition & 1 deletion website/docs/cli/analyze.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ The reporter prints a single JSON object containing meta information and the vio
- `status` - a status of information in this record
- `title` - a message with information about the record
- `value` - an actual value of this record (can be an array or a single value)
- `violations` - a value of a violations of a metric associated with this record (can be an array or a single value) _(optional)_
- `violations` - a value of a violations count of a metric associated with this record

```JSON
{
Expand Down