Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Feb 27, 2024
1 parent 1d1cefd commit c53044a
Show file tree
Hide file tree
Showing 21 changed files with 35 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,4 @@ public void onAttached(final Run<?, ?> r) {
public void onLoad(final Run<?, ?> r) {
owner = r;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public boolean canDisplayFile(final Issue issue) {
Optional<Run<?, ?>> referenceBuild = getResult().getReferenceBuild();
return referenceBuild.filter(run -> ConsoleLogHandler.isInConsoleLog(issue.getFileName())
|| AffectedFilesResolver.hasAffectedFile(run, issue)).isPresent();

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ private QualityGateResult evaluateQualityGate(final Report issues, final DeltaRe
return Optional.empty();
}

@SuppressWarnings("PMD.CognitiveComplexity")
private Optional<Run<?, ?>> refineReferenceBasedOnQualityGate(final ResultSelector selector, final Report issues,
final Run<?, ?> reference) {
boolean isSkipped = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
public class WarningsQualityGateEvaluator extends QualityGateEvaluator<WarningsQualityGate> {
private final IssuesStatistics statistics;

/**
* Creates a new instance of {@link WarningsQualityGateEvaluator}.
*
* @param qualityGates
* the quality gates to evaluate
* @param statistics
* the statistics to evaluate
*/
public WarningsQualityGateEvaluator(final Collection<? extends WarningsQualityGate> qualityGates,
final IssuesStatistics statistics) {
super(qualityGates);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ public Descriptor() {
super(ID);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,4 @@ public Descriptor() {
super(ID);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ public Descriptor() {
super(ID);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public OwaspDependencyCheck() {
@Symbol("owaspDependencyCheck")
@Extension
public static class Descriptor extends AnalysisModelParserDescriptor {

/** Create instance. **/
public Descriptor() {
super(ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ public Descriptor() {
public StaticAnalysisLabelProvider getLabelProvider() {
return new IconLabelProvider(getId(), getDisplayName(), getDescriptionProvider(), ICON_NAME);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ public Descriptor() {
super(ID);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ protected Object readResolve() {
@Override
public Report scan(final Run<?, ?> run, final FilePath workspace, final Charset sourceCodeEncoding,
final LogHandler logger) throws ParsingException, ParsingCanceledException {

final UsernamePasswordCredentials httpClientCredentials = withValidCredentials(run.getParent());
final AxivionDashboard dashboard = new RemoteAxivionDashboard(projectUrl, httpClientCredentials, namedFilter);
final AxivionParser.Config config = new Config(projectUrl, expandBaseDir(run, basedir),
Expand Down Expand Up @@ -246,7 +245,6 @@ private static String expandBaseDir(final Run<?, ?> run, final String baseDir) {

/** Provides the Axivion icons. */
private static class LabelProvider extends IconLabelProvider {

LabelProvider() {
super(ID, "Axivion Suite", EMPTY_DESCRIPTION, "axivion");
}
Expand All @@ -256,7 +254,6 @@ private static class LabelProvider extends IconLabelProvider {
@Symbol({"axivionSuite", "axivion"})
@Extension
public static class AxivionSuiteToolDescriptor extends ToolDescriptor {

private static final JenkinsFacade JENKINS = new JenkinsFacade();

/** Creates the descriptor instance. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ public JsonObject getIssues(final AxIssueKind kind) {
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, credentials);

try (CloseableHttpClient client =
HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build()) {

try (CloseableHttpClient client
= HttpClients.custom().setDefaultCredentialsProvider(credentialsProvider).build()) {
URIBuilder uriBuilder = new URIBuilder(projectUrl + "/issues");
uriBuilder.setParameter("kind", kind.toString());
if (!namedFilter.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DynamicDocumentParser extends IssueParser {
private static final long serialVersionUID = -690643673847390322L;
private final Pattern pattern;
private static final int NO_LINE_NUMBER_AVAILABLE = 0;

private final GroovyExpressionMatcher expressionMatcher;

/**
Expand All @@ -35,7 +35,6 @@ class DynamicDocumentParser extends IssueParser {

pattern = Pattern.compile(regexp, Pattern.MULTILINE);
expressionMatcher = new GroovyExpressionMatcher(script);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ void shouldReturnPackagesJava() {
TabLabelProvider tabLabelProvider = createTabLabelProvider("Testfile.java");

assertThat(tabLabelProvider).hasPackages(Messages.Tab_Packages());

}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import edu.hm.hafner.util.SerializableTest;

class AxivionSuiteSerializationTest extends SerializableTest<AxivionSuite> {

@Override
protected AxivionSuite createSerializable() {
return restore(readAllBytes("axivion-suite-9.0.1.ser"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.jenkins.plugins.analysis.warnings.axivion;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

class AxivionSuiteTest {
import static org.assertj.core.api.Assertions.*;

class AxivionSuiteTest {

Check notice

Code scanning / CodeQL

Unused classes and interfaces Note test

Unused class: AxivionSuiteTest is not referenced within this codebase. If not used as an external API it should be removed.
private static AxivionSuite newTool(final String projectUrl) {
return new AxivionSuite(projectUrl, "", "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* Tests the class {@link GroovyScript}.
*/
class GroovyScriptITest extends IntegrationTestWithJenkinsPerSuite {

/** Tests that the descriptor's canScanConsoleLog method returns the same as the configured permission ... for the "true" case */
@Test
void descriptorMethodCanScanConsoleLogReturnsTrueIfConfigurationSaysConsoleLogScanningPermittedIsTrue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,4 @@ private StaticAnalysisToolFactory getToolProvider() {
private GroovyParser createParser() {
return new GroovyParser(ID, NAME, "regexp", "script", "example");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.Test;

import hudson.util.FormValidation;

import io.jenkins.plugins.util.GlobalConfigurationFacade;

import static io.jenkins.plugins.analysis.core.testutil.Assertions.*;
Expand Down Expand Up @@ -107,6 +108,5 @@ void deleteShouldRemoveOnlySpecifiedParser() {

configuration.deleteParser(firstTestParser.getId());
assertThat(configuration.getParsers()).containsExactly(secondTestParser);

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.jenkins.plugins.analysis.warnings;

import java.util.List;
import java.util.Map;

import org.junit.Test;
import org.openqa.selenium.By;
Expand All @@ -14,7 +13,6 @@
import org.jenkinsci.test.acceptance.po.WorkflowJob;

import io.jenkins.plugins.analysis.warnings.AnalysisResult.Tab;
import io.jenkins.plugins.analysis.warnings.DashboardTable.DashboardTableEntry;

import static io.jenkins.plugins.analysis.warnings.Assertions.*;
import static io.jenkins.plugins.analysis.warnings.IssuesColumnConfiguration.*;
Expand Down Expand Up @@ -134,17 +132,18 @@ private void verifyColumnCount(final Build build) {
assertThat(column).hasTotalCount("33");
}

private void verifyDashboardTablePortlet(final DashboardTable dashboardTable, final String jobName) {
assertThat(dashboardTable.getHeaders()).containsExactly(
"Job", CHECKSTYLE_ICON, DRY_ICON, FINDBUGS_ICON, ANALYSIS_ICON, PMD_ICON);

Map<String, Map<String, DashboardTableEntry>> table = dashboardTable.getTable();
assertThat(table.get(jobName).get(FINDBUGS_ICON)).hasWarningsCount(0);
assertThat(table.get(jobName).get(CHECKSTYLE_ICON)).hasWarningsCount(3);
assertThat(table.get(jobName).get(ANALYSIS_ICON)).hasWarningsCount(8);
assertThat(table.get(jobName).get(PMD_ICON)).hasWarningsCount(2);
assertThat(table.get(jobName).get(DRY_ICON)).hasWarningsCount(20);
}
// FIXME: re-enable dashboard view tests

Check warning on line 135 in ui-tests/src/test/java/io/jenkins/plugins/analysis/warnings/SmokeTests.java

View check run for this annotation

ci.jenkins.io / Open Tasks Scanner

FIXME

HIGH: re-enable dashboard view tests
// private void verifyDashboardTablePortlet(final DashboardTable dashboardTable, final String jobName) {
// assertThat(dashboardTable.getHeaders()).containsExactly(
// "Job", CHECKSTYLE_ICON, DRY_ICON, FINDBUGS_ICON, ANALYSIS_ICON, PMD_ICON);
//
// Map<String, Map<String, DashboardTableEntry>> table = dashboardTable.getTable();
// assertThat(table.get(jobName).get(FINDBUGS_ICON)).hasWarningsCount(0);
// assertThat(table.get(jobName).get(CHECKSTYLE_ICON)).hasWarningsCount(3);
// assertThat(table.get(jobName).get(ANALYSIS_ICON)).hasWarningsCount(8);
// assertThat(table.get(jobName).get(PMD_ICON)).hasWarningsCount(2);
// assertThat(table.get(jobName).get(DRY_ICON)).hasWarningsCount(20);
// }

private void createRecordIssuesStep(final WorkflowJob job, final int buildNumber) {
job.script.set("node {\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ protected String readFileToString(final String fileName) {
}

/**
* Reads all the bytes from a file. The method ensures that the file is
* closed when all bytes have been read or an I/O error, or other runtime
* exception, is thrown.
* Reads all the bytes from a file. The method ensures that the file is closed when all bytes have been read or an
* I/O error, or other runtime exception, is thrown.
*
* <p>
* Note that this method is intended for simple cases where it is convenient to read all bytes into a byte array. It
* is not intended for reading in large files.
* </p>
*
* <p> Note that this method is intended for simple cases where it is
* convenient to read all bytes into a byte array. It is not intended for
* reading in large files.
**
* @param fileName
* name of the desired resource
*
Expand Down

0 comments on commit c53044a

Please sign in to comment.