Add support for the new generate checks and file suppression option
This commit is contained in:
parent
f063889778
commit
def9be96f1
3 changed files with 29 additions and 0 deletions
|
@ -314,6 +314,25 @@ public class CheckstyleOperation extends AbstractProcessOperation<CheckstyleOper
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates to output a suppression xml that will have suppress elements with {@code checks} and {@code files}
|
||||||
|
* attributes only to use to suppress all violations from user's config. Instead of printing every violation, all
|
||||||
|
* violations will be catched and single suppressions xml file will be printed out. Used only with the
|
||||||
|
* {@link #configurationFile(String) configurationFile} option. Output location can be
|
||||||
|
* specified with the {@link #outputPath(String) output} option.
|
||||||
|
*
|
||||||
|
* @param generateChecksAndFileSuppression {@code true} or {@code false}
|
||||||
|
* @return the checkstyle operation
|
||||||
|
*/
|
||||||
|
public CheckstyleOperation generateChecksAndFileSuppression(boolean generateChecksAndFileSuppression) {
|
||||||
|
if (generateChecksAndFileSuppression) {
|
||||||
|
options_.put("-G", "");
|
||||||
|
} else {
|
||||||
|
options_.remove("-G");
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates to output a suppression xml to use to suppress all violations from user's config. Instead of printing
|
* Generates to output a suppression xml to use to suppress all violations from user's config. Instead of printing
|
||||||
* every violation, all violations will be caught and single suppressions xml file will be printed out.
|
* every violation, all violations will be caught and single suppressions xml file will be printed out.
|
||||||
|
|
|
@ -235,6 +235,7 @@ class CheckstyleOperationTest {
|
||||||
.executeIgnoredModules(true)
|
.executeIgnoredModules(true)
|
||||||
.format(OutputFormat.XML)
|
.format(OutputFormat.XML)
|
||||||
.generateXpathSuppression(true)
|
.generateXpathSuppression(true)
|
||||||
|
.generateChecksAndFileSuppression(true)
|
||||||
.javadocTree(true)
|
.javadocTree(true)
|
||||||
.outputPath(new File("optionPath"))
|
.outputPath(new File("optionPath"))
|
||||||
.propertiesFile(new File("properties"))
|
.propertiesFile(new File("properties"))
|
||||||
|
@ -279,6 +280,14 @@ class CheckstyleOperationTest {
|
||||||
assertThat(op.options().get("-f")).isEqualTo("xml");
|
assertThat(op.options().get("-f")).isEqualTo("xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void generateChecksAndFileSuppression() {
|
||||||
|
var op = newCheckstyleOperation().generateChecksAndFileSuppression(true);
|
||||||
|
assertThat(op.options().containsKey("-G")).as(ADD).isTrue();
|
||||||
|
op = op.generateChecksAndFileSuppression(false);
|
||||||
|
assertThat(op.options().containsKey("-G")).as(REMOVE).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void generateXpathSuppression() {
|
void generateXpathSuppression() {
|
||||||
var op = newCheckstyleOperation().generateXpathSuppression(true);
|
var op = newCheckstyleOperation().generateXpathSuppression(true);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
-E
|
-E
|
||||||
-f
|
-f
|
||||||
-g
|
-g
|
||||||
|
-G
|
||||||
-j
|
-j
|
||||||
-J
|
-J
|
||||||
-o
|
-o
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue