Added includes and excludes collection
Changed Collection<String> to Collection<File> whenever applicable
This commit is contained in:
parent
29255aae21
commit
a6be88bf54
2 changed files with 228 additions and 54 deletions
|
@ -17,6 +17,8 @@
|
||||||
package rife.bld.extension;
|
package rife.bld.extension;
|
||||||
|
|
||||||
import rife.bld.BaseProject;
|
import rife.bld.BaseProject;
|
||||||
|
import rife.bld.extension.detekt.Report;
|
||||||
|
import rife.bld.extension.detekt.ReportId;
|
||||||
import rife.bld.operations.AbstractProcessOperation;
|
import rife.bld.operations.AbstractProcessOperation;
|
||||||
import rife.bld.operations.exceptions.ExitStatusException;
|
import rife.bld.operations.exceptions.ExitStatusException;
|
||||||
import rife.tools.exceptions.FileUtilsErrorException;
|
import rife.tools.exceptions.FileUtilsErrorException;
|
||||||
|
@ -24,6 +26,7 @@ import rife.tools.exceptions.FileUtilsErrorException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -53,12 +56,13 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
"sarif4k-jvm-",
|
"sarif4k-jvm-",
|
||||||
"snakeyaml-engine-",
|
"snakeyaml-engine-",
|
||||||
"trove4j-");
|
"trove4j-");
|
||||||
private static final Logger LOGGER = Logger.getLogger(DetektReport.class.getName());
|
private static final Logger LOGGER = Logger.getLogger(Report.class.getName());
|
||||||
private final Collection<String> classpath_ = new ArrayList<>();
|
private final Collection<File> classpath_ = new ArrayList<>();
|
||||||
private final Collection<String> config_ = new ArrayList<>();
|
private final Collection<File> config_ = new ArrayList<>();
|
||||||
private final Collection<String> input_ = new ArrayList<>();
|
private final Collection<String> excludes_ = new ArrayList<>();
|
||||||
private final Collection<String> plugins_ = new ArrayList<>();
|
private final Collection<File> input_ = new ArrayList<>();
|
||||||
private final Collection<DetektReport> report_ = new ArrayList<>();
|
private final Collection<File> plugins_ = new ArrayList<>();
|
||||||
|
private final Collection<Report> report_ = new ArrayList<>();
|
||||||
private boolean allRules_;
|
private boolean allRules_;
|
||||||
private boolean autoCorrect_;
|
private boolean autoCorrect_;
|
||||||
private String basePath_;
|
private String basePath_;
|
||||||
|
@ -68,9 +72,8 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
private boolean createBaseline_;
|
private boolean createBaseline_;
|
||||||
private boolean debug_;
|
private boolean debug_;
|
||||||
private boolean disableDefaultRuleSets_;
|
private boolean disableDefaultRuleSets_;
|
||||||
private String excludes_;
|
|
||||||
private boolean generateConfig_;
|
private boolean generateConfig_;
|
||||||
private String includes_;
|
private final Collection<String> includes_ = new ArrayList<>();
|
||||||
private String jdkHome_;
|
private String jdkHome_;
|
||||||
private String jvmTarget_;
|
private String jvmTarget_;
|
||||||
private String languageVersion_;
|
private String languageVersion_;
|
||||||
|
@ -117,6 +120,19 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies a directory as the base path. Currently, it impacts all file
|
||||||
|
* paths in the formatted reports. File paths in console output and txt
|
||||||
|
* report are not affected and remain as absolute paths.
|
||||||
|
*
|
||||||
|
* @param path the directory path
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation basePath(File path) {
|
||||||
|
basePath_ = path.getAbsolutePath();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a baseline xml file is passed in, only new code smells not in the
|
* If a baseline xml file is passed in, only new code smells not in the
|
||||||
* baseline are printed in the console.
|
* baseline are printed in the console.
|
||||||
|
@ -129,6 +145,18 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a baseline xml file is passed in, only new code smells not in the
|
||||||
|
* baseline are printed in the console.
|
||||||
|
*
|
||||||
|
* @param baseline the baseline xml file
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation baseline(File baseline) {
|
||||||
|
baseline_ = baseline.getAbsolutePath();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preconfigures detekt with a bunch of rules and some opinionated defaults
|
* Preconfigures detekt with a bunch of rules and some opinionated defaults
|
||||||
* for you. Allows additional provided configurations to override the
|
* for you. Allows additional provided configurations to override the
|
||||||
|
@ -143,51 +171,93 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXPERIMENTAL: Paths where to find user class files and depending jar files.
|
* EXPERIMENTAL: Paths where to find user class files and jar dependencies.
|
||||||
|
* Used for type resolution.
|
||||||
|
*
|
||||||
|
* @param paths one or more files
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation classPath(File... paths) {
|
||||||
|
classpath_.addAll(List.of(paths));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EXPERIMENTAL: Paths where to find user class files and jar dependencies.
|
||||||
* Used for type resolution.
|
* Used for type resolution.
|
||||||
*
|
*
|
||||||
* @param paths one or more files
|
* @param paths one or more files
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation classPath(String... paths) {
|
public DetektOperation classPath(String... paths) {
|
||||||
classpath_.addAll(List.of(paths));
|
classpath_.addAll(Arrays.stream(paths).map(File::new).toList());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EXPERIMENTAL: Paths where to find user class files and depending jar files.
|
* EXPERIMENTAL: Paths where to find user class files and jar dependencies.
|
||||||
* Used for type resolution.
|
* Used for type resolution.
|
||||||
*
|
*
|
||||||
* @param paths the list of files
|
* @param paths the paths
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation classPath(Collection<String> paths) {
|
public DetektOperation classPath(Collection<File> paths) {
|
||||||
classpath_.addAll(paths);
|
classpath_.addAll(paths);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the config file ({@code path/to/config.yml}).
|
* Paths where to find user class files and jar dependencies.
|
||||||
|
*
|
||||||
|
* @return the paths
|
||||||
|
*/
|
||||||
|
public Collection<File> classPath() {
|
||||||
|
return classpath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paths to the config files ({@code path/to/config.yml}).
|
||||||
*
|
*
|
||||||
* @param configs one or more config files
|
* @param configs one or more config files
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation config(String... configs) {
|
public DetektOperation config(File... configs) {
|
||||||
config_.addAll(List.of(configs));
|
config_.addAll(List.of(configs));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the config file ({@code path/to/config.yml}).
|
* Paths to the config files ({@code path/to/config.yml}).
|
||||||
*
|
*
|
||||||
* @param configs the list pf config files
|
* @param configs one or more config files
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation config(Collection<String> configs) {
|
public DetektOperation config(String... configs) {
|
||||||
|
config_.addAll(Arrays.stream(configs).map(File::new).toList());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paths to the config files ({@code path/to/config.yml}).
|
||||||
|
*
|
||||||
|
* @param configs the config files
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation config(Collection<File> configs) {
|
||||||
config_.addAll(configs);
|
config_.addAll(configs);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Paths to config files.
|
||||||
|
*
|
||||||
|
* @return the config files paths.
|
||||||
|
*/
|
||||||
|
public Collection<File> config() {
|
||||||
|
return config_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path to the config resource on detekt's classpath ({@code path/to/config.yml}).
|
* Path to the config resource on detekt's classpath ({@code path/to/config.yml}).
|
||||||
*
|
*
|
||||||
|
@ -199,6 +269,17 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path to the config resource on detekt's classpath ({@code path/to/config.yml}).
|
||||||
|
*
|
||||||
|
* @param resource the config resource path
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation configResource(File resource) {
|
||||||
|
configResource_ = resource.getAbsolutePath();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Treats current analysis findings as a smell baseline for future detekt
|
* Treats current analysis findings as a smell baseline for future detekt
|
||||||
* runs.
|
* runs.
|
||||||
|
@ -236,14 +317,34 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
/**
|
/**
|
||||||
* Globbing patterns describing paths to exclude from the analysis.
|
* Globbing patterns describing paths to exclude from the analysis.
|
||||||
*
|
*
|
||||||
* @param patterns the patterns
|
* @param patterns one or more pattern
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation excludes(String patterns) {
|
public DetektOperation excludes(String... patterns) {
|
||||||
excludes_ = patterns;
|
excludes_.addAll(List.of(patterns));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Globbing patterns describing paths to exclude from the analysis.
|
||||||
|
*
|
||||||
|
* @param patterns a collection of patterns
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation excludes(Collection<String> patterns) {
|
||||||
|
excludes_.addAll(patterns);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the globbing patterns describing paths to exclude from the analysis.
|
||||||
|
*
|
||||||
|
* @return the globbing patterns
|
||||||
|
*/
|
||||||
|
public Collection<String> excludes() {
|
||||||
|
return excludes_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the operation.
|
* Performs the operation.
|
||||||
*
|
*
|
||||||
|
@ -311,13 +412,13 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
// classpath
|
// classpath
|
||||||
if (!classpath_.isEmpty()) {
|
if (!classpath_.isEmpty()) {
|
||||||
args.add("--classpath");
|
args.add("--classpath");
|
||||||
args.add(String.join(File.pathSeparator, classpath_.stream().filter(this::isNotBlank).toList()));
|
args.add(String.join(File.pathSeparator, classpath_.stream().map(File::getAbsolutePath).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// config
|
// config
|
||||||
if (!config_.isEmpty()) {
|
if (!config_.isEmpty()) {
|
||||||
args.add("-config");
|
args.add("-config");
|
||||||
args.add(String.join(";", config_.stream().filter(this::isNotBlank).toList()));
|
args.add(String.join(";", config_.stream().map(File::getAbsolutePath).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// config-resource
|
// config-resource
|
||||||
|
@ -342,9 +443,9 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// excludes
|
// excludes
|
||||||
if (isNotBlank(excludes_)) {
|
if (!excludes_.isEmpty()) {
|
||||||
args.add("--excludes");
|
args.add("--excludes");
|
||||||
args.add(excludes_);
|
args.add(String.join(",", excludes_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate-config
|
// generate-config
|
||||||
|
@ -353,15 +454,15 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// includes
|
// includes
|
||||||
if (isNotBlank(includes_)) {
|
if (!includes_.isEmpty()) {
|
||||||
args.add("--includes");
|
args.add("--includes");
|
||||||
args.add(includes_);
|
args.add(String.join(",", includes_));
|
||||||
}
|
}
|
||||||
|
|
||||||
// input
|
// input
|
||||||
if (!input_.isEmpty()) {
|
if (!input_.isEmpty()) {
|
||||||
args.add("--input");
|
args.add("--input");
|
||||||
args.add(String.join(",", input_.stream().filter(this::isNotBlank).toList()));
|
args.add(String.join(",", input_.stream().map(File::getAbsolutePath).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// jdk-home
|
// jdk-home
|
||||||
|
@ -396,7 +497,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
// plugins
|
// plugins
|
||||||
if (!plugins_.isEmpty()) {
|
if (!plugins_.isEmpty()) {
|
||||||
args.add("--plugins");
|
args.add("--plugins");
|
||||||
args.add(String.join(",", plugins_.stream().filter(this::isNotBlank).toList()));
|
args.add(String.join(",", plugins_.stream().map(File::getAbsolutePath).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// report
|
// report
|
||||||
|
@ -433,7 +534,7 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
if (baseline.exists()) {
|
if (baseline.exists()) {
|
||||||
baseline_ = baseline.getAbsolutePath();
|
baseline_ = baseline.getAbsolutePath();
|
||||||
}
|
}
|
||||||
excludes(".*/build/.*,.*/resources/.*");
|
excludes(".*/build/.*", ".*/resources/.*");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,23 +577,44 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Globbing patterns describing paths to include in the analysis. Useful in
|
* Globbing patterns describing paths to include in the analysis. Useful in
|
||||||
* combination with {@link #excludes(String) excludes} patterns.
|
* combination with {@link #excludes() excludes} patterns.
|
||||||
*
|
*
|
||||||
* @param patterns the patterns
|
* @param patterns one or more patterns
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation includes(String patterns) {
|
public DetektOperation includes(String... patterns) {
|
||||||
includes_ = patterns;
|
includes_.addAll(List.of(patterns));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Globbing patterns describing paths to include in the analysis. Useful in
|
||||||
|
* combination with {@link #excludes() excludes} patterns.
|
||||||
|
*
|
||||||
|
* @param patterns a collection of patterns
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation includes(Collection<String> patterns) {
|
||||||
|
includes_.addAll(patterns);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the globbing patterns describing paths to include in the analysis.
|
||||||
|
*
|
||||||
|
* @return the globbing patterns
|
||||||
|
*/
|
||||||
|
public Collection<String> includes() {
|
||||||
|
return includes_;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input paths to analyze. If not specified the current working directory is used.
|
* Input paths to analyze. If not specified the current working directory is used.
|
||||||
*
|
*
|
||||||
* @param paths the list of paths
|
* @param paths the paths
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation input(Collection<String> paths) {
|
public DetektOperation input(Collection<File> paths) {
|
||||||
input_.addAll(paths);
|
input_.addAll(paths);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -504,16 +626,28 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation input(String... paths) {
|
public DetektOperation input(String... paths) {
|
||||||
|
input_.addAll(Arrays.stream(paths).map(File::new).toList());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Input paths to analyze. If not specified the current working directory is used.
|
||||||
|
*
|
||||||
|
* @param paths one or more paths
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation input(File... paths) {
|
||||||
input_.addAll(List.of(paths));
|
input_.addAll(List.of(paths));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the input paths to analyze.
|
* Returns the input paths to analyze.
|
||||||
*
|
*
|
||||||
* @return the input paths
|
* @return the input paths
|
||||||
*/
|
*/
|
||||||
public Collection<String> input() {
|
public Collection<File> input() {
|
||||||
return input_;
|
return input_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,6 +730,17 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation plugins(String... jars) {
|
public DetektOperation plugins(String... jars) {
|
||||||
|
plugins_.addAll(Arrays.stream(jars).map(File::new).toList());
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra paths to plugin jars.
|
||||||
|
*
|
||||||
|
* @param jars one or more jars
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public DetektOperation plugins(File... jars) {
|
||||||
plugins_.addAll(List.of(jars));
|
plugins_.addAll(List.of(jars));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -603,16 +748,25 @@ public class DetektOperation extends AbstractProcessOperation<DetektOperation> {
|
||||||
/**
|
/**
|
||||||
* Extra paths to plugin jars.
|
* Extra paths to plugin jars.
|
||||||
*
|
*
|
||||||
* @param jars the list of jars
|
* @param jars the jars paths
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public DetektOperation plugins(Collection<String> jars) {
|
public DetektOperation plugins(Collection<File> jars) {
|
||||||
plugins_.addAll(jars);
|
plugins_.addAll(jars);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a report for given {@link DetektReportId report-id} and stores it on given 'path'.
|
* Extra path to plugins jars.
|
||||||
|
*
|
||||||
|
* @return the jars paths
|
||||||
|
*/
|
||||||
|
public Collection<File> plugins() {
|
||||||
|
return plugins_;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates a report for given {@link ReportId report-id} and stores it on given 'path'.
|
||||||
*
|
*
|
||||||
* @param reports one or more reports
|
* @param reports one or more reports
|
||||||
* @return this operation instance
|
* @return this operation instance
|
||||||
|
|
|
@ -36,7 +36,6 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
class DetektOperationTest {
|
class DetektOperationTest {
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
|
@ -67,34 +66,55 @@ class DetektOperationTest {
|
||||||
|
|
||||||
assertThat(args).isNotEmpty();
|
assertThat(args).isNotEmpty();
|
||||||
|
|
||||||
var params = new DetektOperation()
|
var op = new DetektOperation()
|
||||||
.fromProject(new BaseProject())
|
.fromProject(new BaseProject())
|
||||||
.allRules(true)
|
.allRules(true)
|
||||||
.autoCorrect(true)
|
.autoCorrect(true)
|
||||||
.basePath("basePath")
|
.basePath("basePath")
|
||||||
|
.basePath(new File("basePath"))
|
||||||
.baseline("baseline")
|
.baseline("baseline")
|
||||||
.buildUponDefaultConfig(true)
|
.buildUponDefaultConfig(true)
|
||||||
.classPath("classpath")
|
.classPath(new File("path1"))
|
||||||
.classPath(List.of("path2", "path3"))
|
.classPath("path2", "path3")
|
||||||
.config("config")
|
.classPath(List.of(new File("path4"), new File("path5")))
|
||||||
.config(List.of("config2", "config4"))
|
.config(new File("config1"))
|
||||||
|
.config("config2", "config3")
|
||||||
|
.config(List.of(new File("config4"), new File("config5")))
|
||||||
.configResource("configResource")
|
.configResource("configResource")
|
||||||
|
.configResource(new File("configResource"))
|
||||||
.createBaseline(true)
|
.createBaseline(true)
|
||||||
.debug(true)
|
.debug(true)
|
||||||
.disableDefaultRuleSets(true)
|
.disableDefaultRuleSets(true)
|
||||||
.excludes("excludes")
|
.excludes(List.of("excludes1", "excludes2"))
|
||||||
|
.excludes("excludes3", "excludes4")
|
||||||
.generateConfig(true)
|
.generateConfig(true)
|
||||||
.includes("patterns")
|
.includes(List.of("includes1", "includes2"))
|
||||||
.input("input")
|
.includes("includes3", "includes4", "includes5")
|
||||||
|
.input(new File("input1"))
|
||||||
|
.input("input2", "input3")
|
||||||
|
.input(List.of(new File("input4"), new File("input5")))
|
||||||
.jdkHome("jdkHome")
|
.jdkHome("jdkHome")
|
||||||
.jvmTarget("jvmTarget")
|
.jvmTarget("jvmTarget")
|
||||||
.languageVersion("languageVersion")
|
.languageVersion("languageVersion")
|
||||||
.maxIssues(10)
|
.maxIssues(10)
|
||||||
.parallel(true)
|
.parallel(true)
|
||||||
.plugins("jars")
|
.plugins(new File("jar1"))
|
||||||
.plugins(List.of("jars2", "jar3"))
|
.plugins("jar2", "jar3")
|
||||||
.report(new DetektReport(DetektReportId.HTML, "reports"))
|
.plugins(List.of(new File("jar4"), new File("jar5")))
|
||||||
.executeConstructProcessCommandList();
|
.report(new Report(ReportId.HTML, "reports"));
|
||||||
|
|
||||||
|
assertThat(op.excludes()).as("excludes[]").containsExactly(".*/build/.*", ".*/resources/.*",
|
||||||
|
"excludes1", "excludes2", "excludes3", "excludes4");
|
||||||
|
|
||||||
|
for (var i = 1; i < 6; i++) {
|
||||||
|
assertThat(op.classPath()).as("classPath[" + i + ']').hasSize(5).contains(new File("path" + i));
|
||||||
|
assertThat(op.config()).as("config[" + i + ']').hasSize(5).contains(new File("config" + i));
|
||||||
|
assertThat(op.includes()).as("includes[" + i + ']').hasSize(5).contains("includes" + i);
|
||||||
|
assertThat(op.input()).as("input[" + i + ']').hasSize(5).contains(new File("input" + i));
|
||||||
|
assertThat(op.plugins()).as("plugins[" + i + ']').hasSize(5).contains(new File("jar" + i));
|
||||||
|
}
|
||||||
|
|
||||||
|
var params = op.executeConstructProcessCommandList();
|
||||||
|
|
||||||
for (var p : args) {
|
for (var p : args) {
|
||||||
var found = false;
|
var found = false;
|
||||||
|
@ -117,7 +137,7 @@ class DetektOperationTest {
|
||||||
var op = new DetektOperation()
|
var op = new DetektOperation()
|
||||||
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
.fromProject(new BaseProjectBlueprint(new File("examples"), "com.example",
|
||||||
"Example"))
|
"Example"))
|
||||||
.baseline(baseline.getAbsolutePath())
|
.baseline(baseline)
|
||||||
.createBaseline(true);
|
.createBaseline(true);
|
||||||
op.execute();
|
op.execute();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue