-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for actual warning in SAVE from the file (#366)
* Support reading of actual warning in SAVE from the file What's done: * Added reading of actual warning from the file Co-authored-by: Kirill Gevorkyan <26010098+kgevorkyan@users.noreply.github.com>
- Loading branch information
1 parent
9074bba
commit 1fe5103
Showing
6 changed files
with
175 additions
and
19 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
examples/kotlin-diktat/sarif-actual-expected/save-warnings-actual.sarif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", | ||
"version": "2.1.0", | ||
"runs": [ | ||
{ | ||
"originalUriBaseIds": { | ||
"%SRCROOT%": { | ||
"uri": "file://D:/projects/" | ||
} | ||
}, | ||
"results": [ | ||
{ | ||
"level": "error", | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"artifactLocation": { | ||
"uri": "src\\kotlin\\EnumValueSnakeCaseTest.kt", | ||
"uriBaseId": "%SRCROOT%" | ||
}, | ||
"region": { | ||
"startColumn": 5, | ||
"startLine": 18 | ||
} | ||
} | ||
} | ||
], | ||
"message": { | ||
"text": "[ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: NAme_MYa_sayR_" | ||
}, | ||
"ruleId": "diktat-ruleset:identifier-naming" | ||
} | ||
], | ||
"tool": { | ||
"driver": { | ||
"downloadUri": "https://github.com/pinterest/ktlint/releases/tag/0.42.0", | ||
"fullName": "ktlint", | ||
"informationUri": "https://github.com/pinterest/ktlint/", | ||
"language": "en", | ||
"name": "ktlint", | ||
"organization": "pinterest", | ||
"rules": [ | ||
], | ||
"semanticVersion": "0.42.0", | ||
"version": "0.42.0" | ||
} | ||
} | ||
} | ||
] | ||
} |
50 changes: 50 additions & 0 deletions
50
examples/kotlin-diktat/sarif-actual-expected/save-warnings-expected.sarif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", | ||
"version": "2.1.0", | ||
"runs": [ | ||
{ | ||
"originalUriBaseIds": { | ||
"%SRCROOT%": { | ||
"uri": "file://D:/projects/" | ||
} | ||
}, | ||
"results": [ | ||
{ | ||
"level": "error", | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"artifactLocation": { | ||
"uri": "src\\kotlin\\EnumValueSnakeCaseTest.kt", | ||
"uriBaseId": "%SRCROOT%" | ||
}, | ||
"region": { | ||
"startColumn": 5, | ||
"startLine": 18 | ||
} | ||
} | ||
} | ||
], | ||
"message": { | ||
"text": "[ENUM_VALUE] enum values should be in selected UPPER_CASE snake/PascalCase format: NAme_MYa_sayR_" | ||
}, | ||
"ruleId": "diktat-ruleset:identifier-naming" | ||
} | ||
], | ||
"tool": { | ||
"driver": { | ||
"downloadUri": "https://github.com/pinterest/ktlint/releases/tag/0.42.0", | ||
"fullName": "ktlint", | ||
"informationUri": "https://github.com/pinterest/ktlint/", | ||
"language": "en", | ||
"name": "ktlint", | ||
"organization": "pinterest", | ||
"rules": [ | ||
], | ||
"semanticVersion": "0.42.0", | ||
"version": "0.42.0" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[general] | ||
tags = ["warn", "sarif"] | ||
description = "Test warnings discovered by diKTat, reading expected warnings from SARIF file" | ||
suiteName = "Only Warnings: with SARIF format" | ||
|
||
[warn] | ||
# regular expression to detect tests | ||
testNameRegex = ".*Test.kt" | ||
expectedWarningsFormat = "SARIF" | ||
expectedWarningsFileName = "save-warnings-expected.sarif" | ||
actualWarningsFormat = "SARIF" | ||
actualWarningsFileName = "save-warnings-actual.sarif" | ||
# diktat warnings have the following format: filename.kt:1:15: [WARN_NAME] my warning | ||
actualWarningsPattern="(\\w+\\..+):(\\d+):(\\d+): (\\[.*\\].*)" | ||
fileNameCaptureGroupOut = 1 | ||
lineCaptureGroupOut = 2 | ||
columnCaptureGroupOut = 3 | ||
messageCaptureGroupOut = 4 | ||
exactWarningsMatch = false | ||
warningTextHasColumn = true | ||
warningTextHasLine = true |
15 changes: 15 additions & 0 deletions
15
examples/kotlin-diktat/sarif-actual-expected/src/kotlin/EnumValueSnakeCaseTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.cqfn.diktat.test.resources.test.paragraph1.naming.enum_ | ||
|
||
// ;warn:3:1: [MISSING_KDOC_TOP_LEVEL] all public and internal top-level classes and functions should have Kdoc: EnumValueSnakeCaseTest (cannot be auto-corrected) | ||
// ;warn:35: [WRONG_DECLARATIONS_ORDER] declarations of constants and enum members should be sorted alphabetically: enum entries order is incorrect | ||
// ;warn:10:5: [ENUMS_SEPARATED] enum is incorrectly formatted: enums must end with semicolon | ||
enum class EnumValueSnakeCaseTest { | ||
// ;warn:$line+1:5: [ENUM_VALUE] enum values should be{{ in }}selected UPPER_CASE snake/PascalCase format: paSC_SAl_l | ||
paSC_SAl_l, | ||
|
||
// ;warn:5: [ENUM_VALUE] enum values{{ should }}be in selected{{ UPPER_CASE }}snake/PascalCase format: PascAsl_f | ||
PascAsl_f | ||
// ;warn:$line-2:5: [ENUMS_SEPARATED] enum is incorrectly formatted: last enum entry must end with a comma | ||
|
||
// ;warn:1:9: {{.*}}[PACKAGE_NAME_INCORRECT_PREFIX] package name should start from company's domain: org.cqfn.save{{.*}} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters