Skip to content

Commit

Permalink
simplified code and removed unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanSpieker committed Sep 19, 2019
1 parent dc2eeb2 commit aa28890
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/main/java/htmlpublisher/HtmlPublisher.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.io.PrintStream;
import java.io.Reader;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
Expand Down Expand Up @@ -108,7 +109,7 @@ private static String writeFile(List<String> lines, File path) throws IOExceptio
for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i) + "\n";
bw.write(line);
sha1.update(line.getBytes("UTF-8"));
sha1.update(line.getBytes(StandardCharsets.UTF_8));
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/htmlpublisher/HtmlPublisherTarget.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -540,13 +541,13 @@ public boolean equals(Object obj) {
return false;
}
final HtmlPublisherTarget other = (HtmlPublisherTarget) obj;
if ((this.reportName == null) ? (other.reportName != null) : !this.reportName.equals(other.reportName)) {
if (!Objects.equals(this.reportName, other.reportName)) {
return false;
}
if ((this.reportDir == null) ? (other.reportDir != null) : !this.reportDir.equals(other.reportDir)) {
if (!Objects.equals(this.reportDir, other.reportDir)) {
return false;
}
if ((this.reportFiles == null) ? (other.reportFiles != null) : !this.reportFiles.equals(other.reportFiles)) {
if (!Objects.equals(this.reportFiles, other.reportFiles)) {
return false;
}
if (this.alwaysLinkToLastBuild != other.alwaysLinkToLastBuild) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
package htmlpublisher.workflow;

import java.util.Arrays;
import java.util.Collections;

import javax.inject.Inject;

Expand Down Expand Up @@ -67,8 +67,8 @@ protected Void run() throws Exception {
throw new AbortException("Cannot publish the report. Target is not specified");
}

boolean res = HtmlPublisher.publishReports(build, ws, listener,
Arrays.asList(target), HtmlPublisher.class);
boolean res = HtmlPublisher.publishReports(build, ws, listener,
Collections.singletonList(target), HtmlPublisher.class);
if (!res) {
throw new AbortException("Cannot publish HTML files");
}
Expand Down
1 change: 0 additions & 1 deletion src/test/java/htmlpublisher/HtmlPublisherTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package htmlpublisher;

import org.junit.Assert;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand Down
1 change: 0 additions & 1 deletion src/test/java/htmlpublisher/Security784Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.model.FreeStyleProject;
import hudson.model.Job;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import edu.umd.cs.findbugs.annotations.NonNull;
import htmlpublisher.HtmlPublisherTarget;
import hudson.model.Action;
import hudson.model.FreeStyleProject;
import hudson.model.Node;
import hudson.model.Result;
Expand Down Expand Up @@ -208,7 +207,7 @@ private void setupAndRunProject(@NonNull HtmlPublisherTarget target) throws Exce
", keepAll: " + target.getKeepAll() + ", reportDir: '" + target.getReportDir() +
"', reportFiles: '" + target.getReportFiles() + "', reportName: '" + target.getReportName() + "']) \n"
+ "}", true));
QueueTaskFuture<WorkflowRun> runFuture = job.scheduleBuild2(0, new Action[0]);
QueueTaskFuture<WorkflowRun> runFuture = job.scheduleBuild2(0);
assertThat("build was actually scheduled", runFuture, Matchers.notNullValue());
run = runFuture.get();
}
Expand Down

0 comments on commit aa28890

Please sign in to comment.