Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-72054] Add an option to skip the time-consuming post-processing step #1651

Merged
merged 6 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import io.jenkins.plugins.analysis.core.model.StaticAnalysisLabelProvider;
import io.jenkins.plugins.analysis.core.model.Tool;
import io.jenkins.plugins.analysis.core.steps.IssuesScanner.BlameMode;
import io.jenkins.plugins.analysis.core.steps.IssuesScanner.PostProcessingMode;
import io.jenkins.plugins.analysis.core.steps.WarningChecksPublisher.AnnotationScope;
import io.jenkins.plugins.analysis.core.util.HealthDescriptor;
import io.jenkins.plugins.analysis.core.util.ModelValidation;
Expand Down Expand Up @@ -127,6 +128,8 @@
private boolean skipPublishingChecks; // by default, checks will be published
private boolean publishAllIssues; // by default, only new issues will be published

private boolean skipPostProcessing; // @since 10.6.0: by default, post-processing will be enabled

@CheckForNull
private ChecksInfo checksInfo;

Expand Down Expand Up @@ -414,7 +417,7 @@
}

/**
* Returns whether SCM blaming should be disabled.
* Returns whether the SCM blaming should be disabled.
*
* @return {@code true} if SCM blaming should be disabled
*/
Expand All @@ -429,7 +432,7 @@
}

/**
* Returns whether SCM blaming should be disabled.
* Returns whether the SCM blaming should be disabled.
*
* @return {@code true} if SCM blaming should be disabled
*/
Expand Down Expand Up @@ -482,6 +485,20 @@
this.skipPublishingChecks = skipPublishingChecks;
}

/**
* Returns whether post-processing of the issues should be disabled.
*
* @return {@code true} if post-processing of the issues should be disabled.
*/
public boolean isSkipPostProcessing() {
return skipPostProcessing;

Check warning on line 494 in plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/IssuesRecorder.java#L494

Added line #L494 was not covered by tests
}

@DataBoundSetter
public void setSkipPostProcessing(final boolean skipPostProcessing) {
this.skipPostProcessing = skipPostProcessing;
}

/**
* Returns whether all issues should be published using the Checks API. If set to {@code false} only new issues will
* be published.
Expand Down Expand Up @@ -643,7 +660,7 @@
}

/**
* Sets the healthy threshold, i.e. the number of issues when health is reported as 0%.
* Sets the healthy threshold, i.e., the number of issues when health is reported as 0%.
*
* @param unhealthy
* the number of issues when health is reported as 0%
Expand Down Expand Up @@ -806,7 +823,8 @@
final Tool tool) throws IOException, InterruptedException {
IssuesScanner issuesScanner = new IssuesScanner(tool, getFilters(), getSourceCodeCharset(),
workspace, getSourceCodePaths(), run, new FilePath(run.getRootDir()), listener,
scm, isBlameDisabled ? BlameMode.DISABLED : BlameMode.ENABLED, quiet);
scm, isBlameDisabled ? BlameMode.DISABLED : BlameMode.ENABLED,
skipPostProcessing ? PostProcessingMode.DISABLED : PostProcessingMode.ENABLED, quiet);

return issuesScanner.scan();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@ class IssuesScanner {
private final TaskListener listener;
private final String scm;
private final BlameMode blameMode;
private final PostProcessingMode postProcessingMode;
private final boolean quiet;

enum BlameMode {
ENABLED, DISABLED
}

enum PostProcessingMode {
ENABLED, DISABLED
}

@SuppressWarnings("checkstyle:ParameterNumber")
IssuesScanner(final Tool tool, final List<RegexpFilter> filters, final Charset sourceCodeEncoding,
final FilePath workspace, final Set<String> sourceDirectories, final Run<?, ?> run,
final FilePath jenkinsRootDir, final TaskListener listener,
final String scm, final BlameMode blameMode, final boolean quiet) {
final String scm, final BlameMode blameMode, final PostProcessingMode postProcessingMode, final boolean quiet) {
this.filters = new ArrayList<>(filters);
this.sourceCodeEncoding = sourceCodeEncoding;
this.tool = tool;
Expand All @@ -95,6 +100,7 @@ enum BlameMode {
this.listener = listener;
this.scm = scm;
this.blameMode = blameMode;
this.postProcessingMode = postProcessingMode;
this.quiet = quiet;
}

Expand Down Expand Up @@ -123,7 +129,9 @@ private RepositoryStatistics getRepositoryStatistics(final Report report) {
}

private AnnotatedReport postProcessReport(final Report report) throws IOException, InterruptedException {
if (tool.getDescriptor().isPostProcessingEnabled() && report.isNotEmpty()) {
if (tool.getDescriptor().isPostProcessingEnabled()
&& report.isNotEmpty()
&& postProcessingMode == PostProcessingMode.ENABLED) {
report.logInfo("Post processing issues on '%s' with source code encoding '%s'",
getAgentName(), sourceCodeEncoding);
AnnotatedReport result = workspace.act(createPostProcessor(report));
Expand Down Expand Up @@ -170,7 +178,6 @@ private Blamer createBlamer(final Report report) {
report.logInfo("-> Filtering SCMs by key '%s'", scm);
}
Blamer blamer = BlamerFactory.findBlamer(scm, run, workspace, listener, log);
log.logSummary();
report.mergeLogMessages(log);

return blamer;
Expand Down Expand Up @@ -283,7 +290,6 @@ private Blames blame(final Report filtered, final FileLocations fileLocations) {
}
FilteredLog log = new FilteredLog("Errors while extracting author and commit information from Git:");
Blames blames = blamer.blame(fileLocations, log);
log.logSummary();
filtered.mergeLogMessages(log);
return blames;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@

private boolean isBlameDisabled;

private boolean skipPostProcessing; // @since 10.6.0: by default, post-processing will be enabled
private boolean skipPublishingChecks; // by default, checks will be published
private boolean publishAllIssues; // by default, only new issues will be published

Expand Down Expand Up @@ -850,34 +851,48 @@
@DataBoundSetter
public void setSkipBlames(final boolean skipBlames) {
isBlameDisabled = skipBlames;
}

/**
* Not used anymore.
*
* @return {@code true} if SCM forensics should be disabled
* @deprecated Forensics will be automatically skipped if the Forensics recorder is not activated.
*/
@SuppressWarnings("PMD.BooleanGetMethodName")
@Deprecated
public boolean getForensicsDisabled() {
return false;
}

/**
* Not used anymore.
*
* @param forensicsDisabled
* not used
*
* @deprecated Forensics will be automatically skipped if the Forensics recorder is not activated.
*/
@DataBoundSetter
@Deprecated
public void setForensicsDisabled(final boolean forensicsDisabled) {
// do nothing
}

/**
* Returns whether post-processing of the issues should be disabled.
*
* @return {@code true} if post-processing of the issues should be disabled.
*/
public boolean isSkipPostProcessing() {
return skipPostProcessing;
}

@DataBoundSetter
public void setSkipPostProcessing(final boolean skipPostProcessing) {
this.skipPostProcessing = skipPostProcessing;
}

Check warning on line 894 in plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

NORMAL: Found duplicated code.
Raw output
<pre><code>} /** * Not used anymore. * * &#64;return {&#64;code true} if SCM forensics should be disabled * &#64;deprecated Forensics will be automatically skipped if the Forensics recorder is not activated. */ &#64;SuppressWarnings(&#34;PMD.BooleanGetMethodName&#34;) &#64;Deprecated public boolean getForensicsDisabled() { return false; } /** * Not used anymore. * * &#64;param forensicsDisabled * not used * * &#64;deprecated Forensics will be automatically skipped if the Forensics recorder is not activated. */ &#64;DataBoundSetter &#64;Deprecated public void setForensicsDisabled(final boolean forensicsDisabled) { // do nothing } /** * Returns whether post-processing of the issues should be disabled. * * &#64;return {&#64;code true} if post-processing of the issues should be disabled. */ public boolean isSkipPostProcessing() { return skipPostProcessing; } &#64;DataBoundSetter public void setSkipPostProcessing(final boolean skipPostProcessing) { this.skipPostProcessing &#61; skipPostProcessing; }</code></pre>

Check warning on line 894 in plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/RecordIssuesStep.java#L893-L894

Added lines #L893 - L894 were not covered by tests

/**
* Returns whether publishing checks should be skipped.
*
Expand Down Expand Up @@ -1140,6 +1155,7 @@
recorder.setEnabledForFailure(step.getEnabledForFailure());
recorder.setAggregatingResults(step.getAggregatingResults());
recorder.setBlameDisabled(step.getBlameDisabled());
recorder.setSkipPostProcessing(step.isSkipPostProcessing());
recorder.setScm(step.getScm());
recorder.setSkipPublishingChecks(step.isSkipPublishingChecks());
recorder.setPublishAllIssues(step.isPublishAllIssues());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.jenkins.plugins.analysis.core.filter.RegexpFilter;
import io.jenkins.plugins.analysis.core.model.Tool;
import io.jenkins.plugins.analysis.core.steps.IssuesScanner.BlameMode;
import io.jenkins.plugins.analysis.core.steps.IssuesScanner.PostProcessingMode;
import io.jenkins.plugins.prism.SourceCodeDirectory;

/**
Expand All @@ -41,6 +42,7 @@
private String sourceDirectory = StringUtils.EMPTY;
private Set<SourceCodeDirectory> sourceDirectories = new HashSet<>(); // @since 9.11.0
private boolean isBlameDisabled;
private boolean skipPostProcessing; // @since 10.6.0: by default, post-processing will be enabled
private boolean quiet;

private List<RegexpFilter> filters = new ArrayList<>();
Expand Down Expand Up @@ -125,81 +127,95 @@
@DataBoundSetter
public void setBlameDisabled(final boolean blameDisabled) {
isBlameDisabled = blameDisabled;
}

/**
* Not used anymore.
*
* @return {@code true} if SCM forensics should be disabled
* @deprecated Forensics will be automatically skipped if the Forensics recorder is not activated.
*/
@SuppressWarnings("PMD.BooleanGetMethodName")
@Deprecated
public boolean getForensicsDisabled() {
return false;
}

/**
* Not used anymore.
*
* @param forensicsDisabled
* not used
*
* @deprecated Forensics will be automatically skipped if the Forensics recorder is not activated.
*/
@DataBoundSetter
@Deprecated
public void setForensicsDisabled(final boolean forensicsDisabled) {
// do nothing
}

/**
* Returns whether post-processing of the issues should be disabled.
*
* @return {@code true} if post-processing of the issues should be disabled.
*/
public boolean isSkipPostProcessing() {
return skipPostProcessing;
}

@DataBoundSetter
public void setSkipPostProcessing(final boolean skipPostProcessing) {
this.skipPostProcessing = skipPostProcessing;
}

Check warning on line 170 in plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

NORMAL: Found duplicated code.
Raw output
<pre><code>} /** * Not used anymore. * * &#64;return {&#64;code true} if SCM forensics should be disabled * &#64;deprecated Forensics will be automatically skipped if the Forensics recorder is not activated. */ &#64;SuppressWarnings(&#34;PMD.BooleanGetMethodName&#34;) &#64;Deprecated public boolean getForensicsDisabled() { return false; } /** * Not used anymore. * * &#64;param forensicsDisabled * not used * * &#64;deprecated Forensics will be automatically skipped if the Forensics recorder is not activated. */ &#64;DataBoundSetter &#64;Deprecated public void setForensicsDisabled(final boolean forensicsDisabled) { // do nothing } /** * Returns whether post-processing of the issues should be disabled. * * &#64;return {&#64;code true} if post-processing of the issues should be disabled. */ public boolean isSkipPostProcessing() { return skipPostProcessing; } &#64;DataBoundSetter public void setSkipPostProcessing(final boolean skipPostProcessing) { this.skipPostProcessing &#61; skipPostProcessing; }</code></pre>

Check warning on line 170 in plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java#L169-L170

Added lines #L169 - L170 were not covered by tests

@CheckForNull
public String getSourceCodeEncoding() {
return sourceCodeEncoding;
}

/**
* Sets the encoding to use to read source files.
*
* @param sourceCodeEncoding
* the encoding, e.g. "ISO-8859-1"
*/
@DataBoundSetter
public void setSourceCodeEncoding(final String sourceCodeEncoding) {
this.sourceCodeEncoding = sourceCodeEncoding;
}

public String getSourceDirectory() {
return sourceDirectory;
}

/**
* Sets the path to the folder that contains the source code. If not relative and thus not part of the workspace
* then this folder needs to be added in Jenkins global configuration.
*
* @param sourceDirectory
* a folder containing the source code
*/
@DataBoundSetter
public void setSourceDirectory(final String sourceDirectory) {
this.sourceDirectory = sourceDirectory;
}

/**
* Sets the paths to the directories that contain the source code. If not relative and thus not part of the
* workspace then these directories need to be added in Jenkins global configuration to prevent accessing of
* forbidden resources.
*
* @param sourceDirectories
* directories containing the source code
*/
@DataBoundSetter
public void setSourceDirectories(final List<SourceCodeDirectory> sourceDirectories) {
this.sourceDirectories = new HashSet<>(sourceDirectories);
}

public List<SourceCodeDirectory> getSourceDirectories() {
return new ArrayList<>(sourceDirectories);

Check warning on line 218 in plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

NORMAL: Found duplicated code.
Raw output
<pre><code>} &#64;CheckForNull public String getSourceCodeEncoding() { return sourceCodeEncoding; } /** * Sets the encoding to use to read source files. * * &#64;param sourceCodeEncoding * the encoding, e.g. &#34;ISO-8859-1&#34; */ &#64;DataBoundSetter public void setSourceCodeEncoding(final String sourceCodeEncoding) { this.sourceCodeEncoding &#61; sourceCodeEncoding; } public String getSourceDirectory() { return sourceDirectory; } /** * Sets the path to the directory that contains the source code. If not relative and thus not part of the workspace * then this directory needs to be added in Jenkins global configuration to prevent accessing of forbidden resources. * * &#64;param sourceDirectory * directory containing the source code */ &#64;DataBoundSetter public void setSourceDirectory(final String sourceDirectory) { this.sourceDirectory &#61; sourceDirectory; } /** * Sets the paths to the directories that contain the source code. If not relative and thus not part of the workspace * then these directories need to be added in Jenkins global configuration to prevent accessing of forbidden resources. * * &#64;param sourceDirectories * directories containing the source code */ &#64;DataBoundSetter public void setSourceDirectories(final List&lt;SourceCodeDirectory&gt; sourceDirectories) { this.sourceDirectories &#61; new HashSet&lt;&gt;(sourceDirectories); } public List&lt;SourceCodeDirectory&gt; getSourceDirectories() { return new ArrayList&lt;&gt;(sourceDirectories); }</code></pre>
}

private Set<String> getAllSourceDirectories() {

Check warning on line 221 in plugin/src/main/java/io/jenkins/plugins/analysis/core/steps/ScanForIssuesStep.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

HIGH: Found duplicated code.
Raw output
<pre><code>} &#64;CheckForNull public String getSourceCodeEncoding() { return sourceCodeEncoding; } /** * Sets the encoding to use to read source files. * * &#64;param sourceCodeEncoding * the encoding, e.g. &#34;ISO-8859-1&#34; */ &#64;DataBoundSetter public void setSourceCodeEncoding(final String sourceCodeEncoding) { this.sourceCodeEncoding &#61; sourceCodeEncoding; } public String getSourceDirectory() { return sourceDirectory; } /** * Sets the path to the folder that contains the source code. If not relative and thus not part of the workspace * then this folder needs to be added in Jenkins global configuration. * * &#64;param sourceDirectory * a folder containing the source code */ &#64;DataBoundSetter public void setSourceDirectory(final String sourceDirectory) { this.sourceDirectory &#61; sourceDirectory; } /** * Sets the paths to the directories that contain the source code. If not relative and thus not part of the * workspace then these directories need to be added in Jenkins global configuration to prevent accessing of * forbidden resources. * * &#64;param sourceDirectories * directories containing the source code */ &#64;DataBoundSetter public void setSourceDirectories(final List&lt;SourceCodeDirectory&gt; sourceDirectories) { this.sourceDirectories &#61; new HashSet&lt;&gt;(sourceDirectories); } public List&lt;SourceCodeDirectory&gt; getSourceDirectories() { return new ArrayList&lt;&gt;(sourceDirectories); } private List&lt;SourceCodeDirectory&gt; getAllSourceDirectories() {<!-- --></code></pre>
Expand Down Expand Up @@ -228,6 +244,7 @@
private final Tool tool;
private final String sourceCodeEncoding;
private final boolean isBlameDisabled;
private final boolean skipPostProcessing;
private final List<RegexpFilter> filters;
private final Set<String> sourceDirectories;
private final String scm;
Expand All @@ -250,6 +267,7 @@
filters = step.getFilters();
sourceDirectories = step.getAllSourceDirectories();
scm = step.getScm();
skipPostProcessing = step.isSkipPostProcessing();
quiet = step.isQuiet();
}

Expand All @@ -261,7 +279,9 @@
IssuesScanner issuesScanner = new IssuesScanner(tool, filters,
getCharset(sourceCodeEncoding), workspace, sourceDirectories,
getRun(), new FilePath(getRun().getRootDir()), listener,
scm, isBlameDisabled ? BlameMode.DISABLED : BlameMode.ENABLED, quiet);
scm, isBlameDisabled ? BlameMode.DISABLED : BlameMode.ENABLED,
skipPostProcessing ? PostProcessingMode.DISABLED : PostProcessingMode.ENABLED,
quiet);

return issuesScanner.scan();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
If this option is unchecked, then the plugin automatically resolves absolute paths, fingerprints,
package and module names from the source files in the workspace.
If this operation slows down your build, you can use this option to deactivate this feature.
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
If this option is unchecked, then the plugin automatically resolves absolute paths, fingerprints,
package and module names from the source files in the workspace.
If this operation slows down your build, you can use this option to deactivate this feature.
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
If this option is unchecked, then the plugin automatically resolves absolute paths, fingerprints,
package and module names from the source files in the workspace.
If this operation slows down your build, you can use this option to deactivate this feature.
</div>
4 changes: 4 additions & 0 deletions plugin/src/main/resources/issues/scan-parameters.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

<i:hr title="${%Reading Affected Files}"/>

<f:entry field="skipPostProcessing">
<f:checkbox title="${%title.skipPostProcessing}" />
</f:entry>

<p:sourceConfig/>

<i:hr title="${%Issue filters}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title.sourceDirectories=Source Directories
description.sourceDirectories=Additional paths to the source code if not in the root of the workspace \
(or outside the workspace).
title.blameDisabled=Disable retrieval of blame information (author and commit) from SCM
title.skipPostProcessing=Disable post-processing of issues (package and modul names, file paths, fingerprints)
title.filter=Issue Filters
description.filter=Issues will be matched with all the specified filters. If no filter is \
defined, then all issues will be published. Filters with empty regular expression will be ignored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
class DetailsTableModelTest extends AbstractDetailsModelTest {
@Test
@org.jvnet.hudson.test.Issue("JENKINS-64051")
@org.junitpioneer.jupiter.Issue("JENKINS-64051")
void shouldNotRemoveWhitespace() {
try (IssueBuilder builder = new IssueBuilder()) {
builder.setMessage("project: Defaults to NumberGroupSeparator on .NET Core except on Windows.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void shouldCollectSingleResultForSingleAxis() {
verify(recorder).publishResult(any(), any(), anyString(), any(), anyString(), any());
}

@Test @org.jvnet.hudson.test.Issue("JENKINS-59178")
@Test @org.junitpioneer.jupiter.Issue("JENKINS-59178")
void shouldCollectDifferentResultsForTwoAxes() {
IssuesRecorder recorder = mock(IssuesRecorder.class);
IssuesAggregator aggregator = createIssueAggregator(recorder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private String getWorkspacePath(final WorkflowJob project, final String fileName
/**
* Tests JENKINS-56484: Error while parsing clang errors with active timestamper plugin.
*/
@Test @org.jvnet.hudson.test.Issue("JENKINS-56484")
@Test @org.junitpioneer.jupiter.Issue("JENKINS-56484")
void shouldCorrectlyParseClangErrors() {
WorkflowJob project = createPipeline();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void shouldShowNoFilesOutsideWorkspace() {
* Verifies that a source code file will be copied from outside the workspace if configured correspondingly.
*/
@Test
@org.jvnet.hudson.test.Issue("JENKINS-55998")
@org.junitpioneer.jupiter.Issue("JENKINS-55998")
void shouldShowFileOutsideWorkspaceIfConfigured() {
FreeStyleProject job = createFreeStyleProject();
prepareGccLog(job);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class MiscIssuesRecorderITest extends IntegrationTestWithJenkinsPerSuite {
/**
* Verifies that {@link FindBugs} handles the different severity mapping modes ({@link PriorityProperty}).
*/
@Test @org.jvnet.hudson.test.Issue("JENKINS-55514")
@Test @org.junitpioneer.jupiter.Issue("JENKINS-55514")
void shouldMapSeverityFilterForFindBugs() {
FreeStyleProject project = createFreeStyleProjectWithWorkspaceFilesWithSuffix("findbugs-severities.xml");

Expand Down Expand Up @@ -208,7 +208,6 @@ void shouldCreateSingleActionIfAggregationEnabled() {
first -> assertThat(first).endsWith("checkstyle-issues.txt"),
second -> assertThat(second).endsWith("pmd-warnings-issues.txt")
);

}

private List<AnalysisResult> runJobWithAggregation(final boolean isAggregationEnabled) {
Expand All @@ -223,7 +222,7 @@ private List<AnalysisResult> runJobWithAggregation(final boolean isAggregationEn

/**
* Runs the CheckStyle and PMD tools for two corresponding files which contain 10 issues in total. Since a filter
* afterwords removes all issues, the actual result contains no warnings. However, the two origins are still
* afterword removes all issues, the actual result contains no warnings. However, the two origins are still
* reported with a total of 0 warnings per origin.
*/
@Test
Expand Down Expand Up @@ -258,7 +257,7 @@ void shouldHaveOriginsIfBuildContainsWarnings() {
* Verifies that a report that contains errors (since the report pattern does not find some files),
* will fail the step if the property {@link IssuesRecorder#setFailOnError(boolean)} is enabled.
*/
@Test @org.jvnet.hudson.test.Issue("JENKINS-58056")
@Test @org.junitpioneer.jupiter.Issue("JENKINS-58056")
void shouldFailBuildWhenFailBuildOnErrorsIsSet() {
FreeStyleProject job = createFreeStyleProject();
IssuesRecorder recorder = enableEclipseWarnings(job);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import hudson.FilePath;
import hudson.model.FreeStyleProject;
import hudson.model.Run;

import io.jenkins.plugins.analysis.core.model.ResultAction;
import io.jenkins.plugins.analysis.core.testutil.IntegrationTestWithJenkinsPerSuite;
Expand Down Expand Up @@ -104,18 +105,18 @@
* test doesn't check for correct precedence in every possible case as this might fail.
*/
@Test
void shouldShowModulesForVariousModulesDetectedForOsgiMavenAndAntInTheHtmlOutput() {
String[] workspaceFiles = {
BUILD_FILE_PATH + ANT_BUILD_FILE_LOCATION + "build.xml",
BUILD_FILE_PATH + ANT_BUILD_FILE_LOCATION + "m1/build.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "pom.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "m1/pom.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "m2/pom.xml",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m1/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m2/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m3/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "plugin.properties"};

Check warning on line 119 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ModuleDetectorITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>void shouldShowModulesForVariousModulesDetectedForOsgiMavenAndAntInTheHtmlOutput() { String[] workspaceFiles &#61; { BUILD_FILE_PATH &#43; ANT_BUILD_FILE_LOCATION &#43; &#34;build.xml&#34;, BUILD_FILE_PATH &#43; ANT_BUILD_FILE_LOCATION &#43; &#34;m1/build.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;pom.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;m1/pom.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;m2/pom.xml&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m1/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m2/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m3/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;plugin.properties&#34;};</code></pre>

ResultAction result = createResult(
workspaceFiles.length - 1,
Expand All @@ -129,6 +130,36 @@
new PropertyRow("Test-Bundle-Name", 1));
}

@Test
void shouldSkipPostProcessing() {
String[] workspaceFiles = {
BUILD_FILE_PATH + ANT_BUILD_FILE_LOCATION + "build.xml",
BUILD_FILE_PATH + ANT_BUILD_FILE_LOCATION + "m1/build.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "pom.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "m1/pom.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "m2/pom.xml",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m1/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m2/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m3/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "plugin.properties"};

Check warning on line 145 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ModuleDetectorITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>void shouldShowModulesForVariousModulesDetectedForOsgiMavenAndAntInTheHtmlOutput() { String[] workspaceFiles &#61; { BUILD_FILE_PATH &#43; ANT_BUILD_FILE_LOCATION &#43; &#34;build.xml&#34;, BUILD_FILE_PATH &#43; ANT_BUILD_FILE_LOCATION &#43; &#34;m1/build.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;pom.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;m1/pom.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;m2/pom.xml&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m1/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m2/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m3/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;plugin.properties&#34;};</code></pre>

FreeStyleProject project = createFreeStyleProject();
copyWorkspaceFiles(project, workspaceFiles, file -> file.replaceFirst("detectors/buildfiles/\\w*/", ""));
var recorder = enableGenericWarnings(project, new Eclipse());
recorder.setSkipPostProcessing(true);

createEclipseWarningsReport(workspaceFiles.length - 1, true,
getJenkins().jenkins.getWorkspaceFor(project));

Run<?, ?> build = buildSuccessfully(project);
ResultAction result = getResultAction(build);
assertThat(result.getResult().getIssues().getModules()).containsExactly("-");

assertThat(getConsoleLog(build)).doesNotContain("Resolving module names from module definitions (build.xml, pom.xml, or Manifest.mf files)");
assertThat(getConsoleLog(build)).contains("Skipping post processing");
}

/**
* Verifies that the output is correct if there are only Maven modules in the expected HTML output.
*/
Expand Down Expand Up @@ -195,18 +226,18 @@
* doesn't check for correct precedence in every possible case as this might fail.
*/
@Test
void shouldRunMavenAntAndOsgiAndCheckCorrectExecutionSequence() {
String[] workspaceFiles = {
BUILD_FILE_PATH + ANT_BUILD_FILE_LOCATION + "build.xml",
BUILD_FILE_PATH + ANT_BUILD_FILE_LOCATION + "m1/build.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "pom.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "m1/pom.xml",
BUILD_FILE_PATH + MAVEN_BUILD_FILE_LOCATION + "m2/pom.xml",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m1/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m2/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "m3/META-INF/MANIFEST.MF",
BUILD_FILE_PATH + OSGI_BUILD_FILE_LOCATION + "plugin.properties"};

Check warning on line 240 in plugin/src/test/java/io/jenkins/plugins/analysis/warnings/steps/ModuleDetectorITest.java

View check run for this annotation

ci.jenkins.io / CPD

CPD

LOW: Found duplicated code.
Raw output
<pre><code>void shouldShowModulesForVariousModulesDetectedForOsgiMavenAndAntInTheHtmlOutput() { String[] workspaceFiles &#61; { BUILD_FILE_PATH &#43; ANT_BUILD_FILE_LOCATION &#43; &#34;build.xml&#34;, BUILD_FILE_PATH &#43; ANT_BUILD_FILE_LOCATION &#43; &#34;m1/build.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;pom.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;m1/pom.xml&#34;, BUILD_FILE_PATH &#43; MAVEN_BUILD_FILE_LOCATION &#43; &#34;m2/pom.xml&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m1/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m2/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;m3/META-INF/MANIFEST.MF&#34;, BUILD_FILE_PATH &#43; OSGI_BUILD_FILE_LOCATION &#43; &#34;plugin.properties&#34;};</code></pre>

ResultAction result = createResult(
workspaceFiles.length - 1,
Expand Down
Loading
Loading