Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(errors): align errorKindToString with SARIF level values #17058

Merged
merged 1 commit into from
Nov 12, 2024
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: 7 additions & 7 deletions compiler/src/dmd/sarif.d
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,22 @@
}

/**
Converts an `ErrorKind` value to a string representation.
Converts an `ErrorKind` value to a SARIF-compatible string representation for the severity level.

Params:
kind = The `ErrorKind` value to convert (e.g., error, warning, deprecation).

Returns:
A string representing the `ErrorKind` value, such as "Error" or "Warning".
A SARIF-compatible string representing the `ErrorKind` level, such as "error" or "warning".
*/
string errorKindToString(ErrorKind kind) nothrow
{
final switch (kind) {
case ErrorKind.error: return "Error";
case ErrorKind.warning: return "Warning";
case ErrorKind.deprecation: return "Deprecation";
case ErrorKind.tip: return "Tip";
case ErrorKind.message: return "Message";
case ErrorKind.error: return "error"; // Serious problem
case ErrorKind.warning: return "warning"; // Problem found
case ErrorKind.deprecation: return "note"; // Minor problem, opportunity for improvement
case ErrorKind.tip: return "note"; // Minor improvement suggestion
case ErrorKind.message: return "none"; // Not applicable for "fail" kind, so use "none"

Check warning on line 196 in compiler/src/dmd/sarif.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/sarif.d#L192-L196

Added lines #L192 - L196 were not covered by tests
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/test/fail_compilation/sarif_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ TEST_OUTPUT:
}],
"results": [
{
"ruleId": "DMD-Error",
"ruleId": "DMD-error",
"message": {
"text": "undefined identifier `x`"
},
"level": "Error",
"level": "error",
"locations": [{
"physicalLocation": {
"artifactLocation": {
Expand Down
8 changes: 4 additions & 4 deletions compiler/test/fail_compilation/sarifmultiple_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ TEST_OUTPUT:
}],
"results": [
{
"ruleId": "DMD-Error",
"ruleId": "DMD-error",
"message": {
"text": "undefined identifier `x`"
},
"level": "Error",
"level": "error",
"locations": [{
"physicalLocation": {
"artifactLocation": {
Expand All @@ -36,11 +36,11 @@ TEST_OUTPUT:
}]
},
{
"ruleId": "DMD-Error",
"ruleId": "DMD-error",
"message": {
"text": "undefined identifier `y`"
},
"level": "Error",
"level": "error",
"locations": [{
"physicalLocation": {
"artifactLocation": {
Expand Down
Loading