dart-code-metrics
dart-code-metrics copied to clipboard
[BUG] No error code returned for technical-debt metric
- Dart code metrics version: 4.13.0
- Dart sdk version: 2.16.1
Please show your full configuration:
Configuration
dart_code_metrics:
metrics:
technical-debt:
threshold: 0
todo-cost: 0
deprecated-annotations-cost: 0
ignore-cost: 1
ignore-for-file-cost: 0
as-dynamic-cost: 0
file-nullsafety-migration-cost: 0
What did you do? Please include the source code example causing the issue.
dart run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings
What did you expect to happen? The above command to return an error code when using an ignore rule comment.
What actually happened?
There was an alarm raised for technical debt but no error code was returned. Even when setting --set-exit-on-violation-level there is no error code returned.
Are you willing to submit a pull request to fix this bug? No
@NickBalnaves can you provide full cli command with --set-exit-on-violation-level ?
@dkrutskikh
dart run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings --set-exit-on-violation-level=warning
and
dart run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings --set-exit-on-violation-level=alarm
Just noticed using the noted level returns an error code when there is an alarm:
dart run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings --set-exit-on-violation-level=noted
On further inspection dart run dart_code_metrics:metrics analyze lib --fatal-style --fatal-performance --fatal-warnings --set-exit-on-violation-level=noted returns an error code even when there are no issues
@dkrutskikh @incendial any idea? Bit annoying since it avoids enforcing these rules during CI checks
@NickBalnaves sorry for long response. I think set --set-exit-on-violation-level=noted not a good idea. Please look at this:
if (value > warningLevel * 2) {
return MetricValueLevel.alarm;
} else if (value > warningLevel) {
return MetricValueLevel.warning;
} else if (value > warningLevel * 0.8) {
return MetricValueLevel.noted;
}
You can faced noted level in html report. We mark method or class by noted level if that now close to warning level.
@dkrutskikh thanks for that information, there is still a problem with the warning level not returning an error code though?
Facing the same issue. I've got a threshold set for tech debt and no error is returned even though its being exceeded.
I've got the following turned as well, so I expect that if treshhold is being exceeded that my commit has failed the checks but it shows me a green check every time 😢:
fatal_warnings: true
fatal_style: true
fatal_performance: true