Add baseline file for testing
This commit is contained in:
parent
5a2824507f
commit
6e3e5d0645
6 changed files with 34 additions and 5 deletions
8
.github/workflows/bld.yml
vendored
8
.github/workflows/bld.yml
vendored
|
@ -24,13 +24,17 @@ jobs:
|
|||
distribution: "zulu"
|
||||
java-version: ${{ matrix.java-version }}
|
||||
|
||||
- name: List directory
|
||||
working-directory: examples
|
||||
run: dir
|
||||
|
||||
- name: Download dependencies [examples]
|
||||
working-directory: examples
|
||||
run: ./bld download
|
||||
|
||||
- name: Run tests [examples]
|
||||
- name: Run Detekt [examples]
|
||||
working-directory: examples
|
||||
run: ./bld compile test
|
||||
run: ./bld compile detekt
|
||||
|
||||
- name: Download dependencies
|
||||
run: ./bld download
|
||||
|
|
2
examples/.gitignore
vendored
2
examples/.gitignore
vendored
|
@ -53,5 +53,3 @@ atlassian-ide-plugin.xml
|
|||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
detekt-baseline.xml
|
12
examples/detekt-baseline.xml
Normal file
12
examples/detekt-baseline.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" ?>
|
||||
<SmellBaseline>
|
||||
<ManuallySuppressedIssues/>
|
||||
<CurrentIssues>
|
||||
<ID>EmptyIfBlock:Example.kt$Example.Companion${ }</ID>
|
||||
<ID>MagicNumber:Example.kt$Example$5</ID>
|
||||
<ID>NewLineAtEndOfFile:ExampleTest.kt$com.example.ExampleTest.kt</ID>
|
||||
<ID>ThrowingExceptionsWithoutMessageOrCause:Example.kt$Example.Companion$IllegalStateException()</ID>
|
||||
<ID>UseCheckOrError:Example.kt$Example.Companion$throw IllegalStateException()</ID>
|
||||
<ID>VariableNaming:Example.kt$Example$// https://detekt.dev/docs/rules/naming#variablenaming val Message: String get() = "Hello World!"</ID>
|
||||
</CurrentIssues>
|
||||
</SmellBaseline>
|
|
@ -545,6 +545,12 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
|||
if (isNotBlank(baseline_)) {
|
||||
args.add("--baseline");
|
||||
args.add(cleanPath(baseline_));
|
||||
} else {
|
||||
var baseline = new File("detekt-baseline.xml");
|
||||
if (baseline.exists()) {
|
||||
args.add("--baseline");
|
||||
args.add(cleanPath(baseline.getAbsolutePath()));
|
||||
}
|
||||
}
|
||||
|
||||
// build-upon-default-config
|
||||
|
|
|
@ -264,6 +264,7 @@ class DetektOperationTest {
|
|||
var op = new DetektOperation()
|
||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
||||
"example", "Example"))
|
||||
.baseline("src/test/resources/detekt-baseline.xml")
|
||||
.maxIssues(8);
|
||||
assertThatNoException().isThrownBy(op::execute);
|
||||
}
|
||||
|
@ -281,6 +282,7 @@ class DetektOperationTest {
|
|||
var op = new DetektOperation()
|
||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
||||
"example", "Example"))
|
||||
.baseline("src/test/resources/detekt-baseline.xml")
|
||||
.report(new Report(ReportId.HTML, html.getAbsolutePath()))
|
||||
.report(new Report(ReportId.XML, xml.getAbsolutePath()))
|
||||
.report(new Report(ReportId.TXT, txt.getAbsolutePath()))
|
||||
|
@ -299,6 +301,7 @@ class DetektOperationTest {
|
|||
var op = new DetektOperation()
|
||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
||||
"example", "Example"))
|
||||
.baseline("src/test/resources/detekt-baseline.xml")
|
||||
.debug(true);
|
||||
assertThatThrownBy(op::execute).isInstanceOf(ExitStatusException.class);
|
||||
}
|
||||
|
|
6
src/test/resources/detekt-baseline.xml
Normal file
6
src/test/resources/detekt-baseline.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" ?>
|
||||
<SmellBaseline>
|
||||
<ManuallySuppressedIssues/>
|
||||
<CurrentIssues>
|
||||
</CurrentIssues>
|
||||
</SmellBaseline>
|
Loading…
Add table
Add a link
Reference in a new issue