Skip to content
Permalink
Browse files
[JENKINS-49237] - Cleanup FindBugs issues unrelated to serialization
  • Loading branch information
oleg-nenashev committed Jan 30, 2018
1 parent f47bd2e commit 0ddbdc19c17aef848902cc3b9b71475401f35fed
@@ -92,13 +92,17 @@ public void doGraph(StaplerRequest req, StaplerResponse rsp) throws IOException
return;
}

Calendar t = getProject().getLastBuild().getTimestamp();
final AbstractBuild<?, ?> lastBuild = getProject().getLastBuild();
if (lastBuild == null) { // No sense to build graph if there is no builds, right?
return;
}

Calendar t = lastBuild.getTimestamp();
if (req.checkIfModified(t, rsp)) {
return; // up to date
}

ChartUtil.generateGraph(req, rsp, GraphHelper.buildChart(getProject().getLastBuild(), getFunctionCcnViolationThreshold(), getFunctionNcssViolationThreshold()), getGraphWidth(),
ChartUtil.generateGraph(req, rsp, GraphHelper.buildChart(lastBuild, getFunctionCcnViolationThreshold(), getFunctionNcssViolationThreshold()), getGraphWidth(),
getGraphHeight());
}

@@ -1,5 +1,6 @@
package hudson.plugins.cppncss;

import hudson.AbortException;
import hudson.FilePath;
import hudson.model.AbstractBuild;
import hudson.model.Action;
@@ -50,6 +51,11 @@ public boolean performFromMaster(AbstractBuild<?, ?> build, FilePath executionRo
if (targets != null && targets.length > 0) {
List<Action> actions = build.getActions();
Result buildResult = build.getResult();
if (buildResult == null) {
// The entire method need to be modified to support Pipeline
throw new AbortException("Cannot perform publisher for a running job. The plugin needs to be updated to support plugins like Any Build Step. File a JIRA ticket if you need that");
}

for (Action action : actions) {
if(action instanceof CppNCSSBuildIndividualReport) {
CppNCSSBuildIndividualReport cppncssAction = (CppNCSSBuildIndividualReport)action;
@@ -8,6 +8,9 @@

import org.apache.commons.beanutils.Converter;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/**
* Created by IntelliJ IDEA. User: stephen Date: 18-Mar-2008 Time: 06:04:17 To change this template use File | Settings
* | File Templates.
@@ -135,18 +138,17 @@ static float measureNew(CppNCSSHealthMetrics metrics, CppNCSSBuildIndividualRepo
return newValue;

};

private static CppNCSSBuildIndividualReport getPreviousCppNCSSReport(AbstractBuild<?, ?> build){

@CheckForNull
private static CppNCSSBuildIndividualReport getPreviousCppNCSSReport(@Nonnull AbstractBuild<?, ?> build){
AbstractBuild<?, ?> previousBuild = build.getPreviousBuild();
CppNCSSBuildIndividualReport resultReport = null;
while(previousBuild != null && resultReport == null){
CppNCSSBuildIndividualReport action = (CppNCSSBuildIndividualReport)previousBuild.getAction(AbstractBuildReport.class);
previousBuild = previousBuild.getPreviousBuild();
if(action != null){
resultReport = action;
break;
}
while(previousBuild != null){
AbstractBuildReport report = previousBuild.getAction(AbstractBuildReport.class);
if (report instanceof CppNCSSBuildIndividualReport) {
return (CppNCSSBuildIndividualReport)report;
}
previousBuild = previousBuild.getPreviousBuild();
}
return resultReport;
return null;
}
}
@@ -1,5 +1,6 @@
package hudson.plugins.cppncss;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.model.AbstractProject;
import hudson.model.Action;
@@ -51,6 +52,8 @@ public Integer getFunctionNcssViolationThreshold() {
return functionNcssViolationThreshold;
}

// TODO: replace by lists
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Legacy code, suppressed due to the performance reasons")
public CppNCSSHealthTarget[] getTargets() {
return targets;
}
@@ -88,6 +91,9 @@ public String getDisplayName() {
}

public Publisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
if (req == null) {
throw new IllegalStateException("Request has not been passed to " + DescriptorImpl.class);
}
ConvertUtils.register(CppNCSSHealthMetrics.CONVERTER, CppNCSSHealthMetrics.class);
return req.bindJSON(CppNCSSPublisher.class, formData);
}
@@ -6,8 +6,8 @@
* @author Shaohua Wen
*/
public class PluginImpl {
public static String DISPLAY_NAME = "Cpp NCSS Report";
public static String GRAPH_NAME = "Cpp NCSS Trend";
public static String URL = "cppncss";
public static String ICON_FILE_NAME = "graph.gif";
public final static String DISPLAY_NAME = "Cpp NCSS Report";
public final static String GRAPH_NAME = "Cpp NCSS Trend";
public final static String URL = "cppncss";
public final static String ICON_FILE_NAME = "graph.gif";
}
@@ -85,6 +85,9 @@ public static StatisticsResult parse(File inFile) throws IOException, XmlPullPar
lastTag = null;
lastText = null;
break;
default:
// Do nothing
break;
}
}
Statistic s = new Statistic(data.get("name"));
@@ -93,8 +96,8 @@ public static StatisticsResult parse(File inFile) throws IOException, XmlPullPar
String file = fileStr.substring(0,fileStr.lastIndexOf(":"));
s.setParentElement(file);
}
s.setNcss(Long.valueOf(data.get(functionValueNames[1]).trim()));
s.setCcn(Long.valueOf(data.get(functionValueNames[2]).trim()));
s.setNcss(Long.parseLong(data.get(functionValueNames[1]).trim()));
s.setCcn(Long.parseLong(data.get(functionValueNames[2]).trim()));
functionResults.add(s);
}
parser.next();
@@ -137,12 +140,15 @@ public static StatisticsResult parse(File inFile) throws IOException, XmlPullPar
lastTag = null;
lastText = null;
break;
default:
// Do nothing
break;
}
}
Statistic s = new Statistic(data.get("name"));
s.setNcss(Long.valueOf(data.get(fileValueNames[1]).trim()));
s.setCcn(Long.valueOf(data.get(fileValueNames[2]).trim()));
s.setFunctions(Long.valueOf(data.get(fileValueNames[3]).trim()));
s.setNcss(Long.parseLong(data.get(fileValueNames[1]).trim()));
s.setCcn(Long.parseLong(data.get(fileValueNames[2]).trim()));
s.setFunctions(Long.parseLong(data.get(fileValueNames[3]).trim()));
fileResults.add(s);
}
parser.next();
@@ -139,7 +139,9 @@ public void updateBuild(AbstractBuild<?, ?> build) {
}

// update the result
if (result != null && result.isWorseThan(build.getResult())) {
// TODO: Logic needs to be updated to support Any Build Step and Pipeline jobs
Result currentResult = build.getResult();
if (result != null && currentResult != null && result.isWorseThan(currentResult)) {
build.setResult(result);
}
}
@@ -28,6 +28,7 @@
import org.kohsuke.stapler.StaplerResponse;

import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/**
* TODO javadoc.
@@ -233,17 +234,20 @@ private static void build_category(AbstractBuild<?, ?> build,
rendu.setBasePaint(color);
categoryPlot.setRenderer(index,rendu);
}

private static CategoryDataset buildDataset(AbstractBuild<?, ?> build, DataCollector collector) {

@Nonnull
private static CategoryDataset buildDataset(@CheckForNull AbstractBuild<?, ?> build, @Nonnull DataCollector collector) {
DataSetBuilder<String, NumberOnlyBuildLabel> builder = new DataSetBuilder<String, NumberOnlyBuildLabel>();

for (AbstractBuild<?, ?> lastBuild = build; lastBuild != null; lastBuild = lastBuild.getPreviousBuild()) {
ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel((Run<?, ?>) lastBuild);
AbstractBuildReport action = lastBuild.getAction(AbstractBuildReport.class);
if (action != null) {
builder.add(collector.getCollectedNumber(action), collector.getTitle(), label);
}
}

if (build != null) {
for (AbstractBuild<?, ?> lastBuild = build; lastBuild != null; lastBuild = lastBuild.getPreviousBuild()) {
ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel((Run<?, ?>) lastBuild);
AbstractBuildReport action = lastBuild.getAction(AbstractBuildReport.class);
if (action != null) {
builder.add(collector.getCollectedNumber(action), collector.getTitle(), label);
}
}
}
return builder.build();
}
}

0 comments on commit 0ddbdc1

Please sign in to comment.