-
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.
ignoreLines feature for filtering the input file (#307)
* feature/ignoreLines ###What's done: * Added ignoreLines option for Fix plugin. * Added tests for ignoreLines and Fix plugin. * Added ignoreLines option for Warn plugin. * Added tests for ignoreLines and Warn plugin. * Implemented copying a file in Warn plugin in order to filter out lines that match any regex from ignoreLines. (#303)
- Loading branch information
1 parent
0388458
commit 530f7e8
Showing
27 changed files
with
319 additions
and
65 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...iktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Expected.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,21 @@ | ||
package org.cqfn.save.IgnoreLinesTest.IgnoreLines | ||
|
||
class D { | ||
val x = 0 | ||
|
||
/** | ||
* @return | ||
*/ | ||
fun bar(): Bar { | ||
val qux = 42 | ||
return Bar(qux) | ||
} | ||
} | ||
|
||
/** | ||
* @param foo | ||
*/ | ||
fun readFile(foo: Foo) { | ||
var bar: Bar | ||
} | ||
// ;warn:0: [TEST] JUST_A_TEST |
12 changes: 12 additions & 0 deletions
12
...in-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/Bug1Test.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,12 @@ | ||
package test.smoke.src.main.kotlin | ||
|
||
fun readFile(foo: Foo) { | ||
var bar: Bar | ||
} | ||
|
||
class D {val x = 0 | ||
fun bar(): Bar {val qux = 42; return Bar(qux)} | ||
} | ||
// ;warn:0: [TEST] JUST_A_TEST | ||
// IGNORE_ME | ||
# I WILL DISSAPEAR AS WELL |
7 changes: 7 additions & 0 deletions
7
...tlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLines/save.toml
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,7 @@ | ||
[general] | ||
tags = ["FixIgnoreLines"] | ||
description = "Test for ignoreLines option in Fix" | ||
suiteName = "Autofix: Smoke Tests" | ||
|
||
[fix] | ||
ignoreLines = ["^// IGNORE.*", "^#.*"] |
22 changes: 22 additions & 0 deletions
22
...ix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Expected.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,22 @@ | ||
package org.cqfn.save.IgnoreLinesTest.IgnoreLinesIsEmpty | ||
|
||
class D { | ||
val x = 0 | ||
|
||
/** | ||
* @return | ||
*/ | ||
fun bar(): Bar { | ||
val qux = 42 | ||
return Bar(qux) | ||
} | ||
} | ||
|
||
/** | ||
* @param foo | ||
*/ | ||
fun readFile(foo: Foo) { | ||
var bar: Bar | ||
} | ||
// ;warn:0: [TEST] JUST_A_TEST | ||
// IGNORE_ME |
11 changes: 11 additions & 0 deletions
11
...at/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/Bug1Test.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,11 @@ | ||
package test.smoke.src.main.kotlin | ||
|
||
fun readFile(foo: Foo) { | ||
var bar: Bar | ||
} | ||
|
||
class D {val x = 0 | ||
fun bar(): Bar {val qux = 42; return Bar(qux)} | ||
} | ||
// ;warn:0: [TEST] JUST_A_TEST | ||
// IGNORE_ME |
7 changes: 7 additions & 0 deletions
7
...ktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/IgnoreLinesIsEmpty/save.toml
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,7 @@ | ||
[general] | ||
tags = ["smoke"] | ||
description = "Smoke tests for diktat" | ||
suiteName = "Autofix: Smoke Tests" | ||
|
||
[fix] | ||
ignoreLines = [] |
21 changes: 21 additions & 0 deletions
21
...tat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Expected.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,21 @@ | ||
package org.cqfn.save.IgnoreLinesTest.NoIgnoreLines | ||
|
||
class D { | ||
val x = 0 | ||
|
||
/** | ||
* @return | ||
*/ | ||
fun bar(): Bar { | ||
val qux = 42 | ||
return Bar(qux) | ||
} | ||
} | ||
|
||
/** | ||
* @param foo | ||
*/ | ||
fun readFile(foo: Foo) { | ||
var bar: Bar | ||
} | ||
// IGNORE_ME |
11 changes: 11 additions & 0 deletions
11
...-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/Bug1Test.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,11 @@ | ||
package test.smoke.src.main.kotlin | ||
|
||
fun readFile(foo: Foo) { | ||
var bar: Bar | ||
} | ||
|
||
class D {val x = 0 | ||
fun bar(): Bar {val qux = 42; return Bar(qux)} | ||
} | ||
// ;warn:0: [TEST] JUST_A_TEST | ||
// IGNORE_ME |
6 changes: 6 additions & 0 deletions
6
...in-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/IgnoreLinesTest/NoIgnoreLines/save.toml
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,6 @@ | ||
[general] | ||
tags = ["smoke"] | ||
description = "Smoke tests for diktat" | ||
suiteName = "Autofix: Smoke Tests" | ||
|
||
[fix] |
6 changes: 6 additions & 0 deletions
6
examples/kotlin-diktat/fix/smoke/src/main/kotlin/org/cqfn/save/chapter1/save.toml
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,6 @@ | ||
[general] | ||
tags = ["smoke"] | ||
description = "Smoke tests for diktat" | ||
suiteName = "Autofix: Smoke Tests" | ||
|
||
[fix] |
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 |
---|---|---|
|
@@ -5,4 +5,3 @@ | |
expectedWarningsPattern = "// ;warn:?(.*):(\\d*): (.+)" | ||
timeOutMillis = 30000 | ||
|
||
|
16 changes: 16 additions & 0 deletions
16
examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/EnumTestDetection.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,16 @@ | ||
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: EnumTestDetection (cannot be auto-corrected) | ||
// ;warn:30: [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 EnumTestDetection { | ||
// ;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{{.*}} | ||
} | ||
// ;warn:0:0: [YOU SHOULD NOT SEE THIS] this warning should not be shown |
7 changes: 7 additions & 0 deletions
7
examples/kotlin-diktat/warn/chapter1/IgnoreLinesTest/save.toml
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,7 @@ | ||
[general] | ||
tags = ["WarnIgnoreLines"] | ||
description = "Test suite that checks if filtering by regex work." | ||
|
||
[warn] | ||
testNameRegex = "^E.*T.*D.*" | ||
ignoreLines = [".*// ;warn:0:0: \\[YOU SHOULD NOT SEE THIS\\] this warning should not be shown.*"] |
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
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
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
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
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
Oops, something went wrong.