Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #9 from mixalturek/master
Browse files Browse the repository at this point in the history
[JENKINS-22214] Fix findings from FindBugs static analysis
  • Loading branch information
mixalturek committed Mar 16, 2014
2 parents 08bfa8b + 1aa01f2 commit d72781b
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 33 deletions.
Expand Up @@ -9,7 +9,7 @@ public static int convert(String threshold) {
if (isValid(threshold)) {
if (StringUtils.isNotBlank(threshold)) {
try {
return Integer.valueOf(threshold);
return Integer.parseInt(threshold);
} catch (NumberFormatException exception) {
// not valid
}
Expand All @@ -21,7 +21,7 @@ public static int convert(String threshold) {
public static boolean isValid(final String threshold) {
if (StringUtils.isNotBlank(threshold)) {
try {
return Integer.valueOf(threshold) >= 0;
return Integer.parseInt(threshold) >= 0;
} catch (NumberFormatException exception) {
// not valid
}
Expand Down
Expand Up @@ -70,7 +70,6 @@ public CppcheckResult(CppcheckReport report, CppcheckSourceContainer cppcheckSou
*
* @return the remote API
*/
@SuppressWarnings("unused")
public Api getApi() {
return new Api(report);
}
Expand All @@ -80,12 +79,10 @@ public CppcheckReport getReport() {
return report;
}

@SuppressWarnings("unused")
public AbstractBuild<?, ?> getOwner() {
return owner;
}

@SuppressWarnings("unused")
public CppcheckSourceContainer getCppcheckSourceContainer() {
return cppcheckSourceContainer;
}
Expand All @@ -99,7 +96,6 @@ public CppcheckSourceContainer getCppcheckSourceContainer() {
* @return the dynamic result of the analysis (detail page).
* @throws java.io.IOException if an error occurs
*/
@SuppressWarnings("unused")
public Object getDynamic(final String link, final StaplerRequest request, final StaplerResponse response) throws IOException {

if (link.startsWith("source.")) {
Expand Down Expand Up @@ -127,7 +123,6 @@ public Object getDynamic(final String link, final StaplerRequest request, final
*
* @return the HTML fragment of the summary Cppcheck report
*/
@SuppressWarnings("unused")
public String getSummary() {
return CppcheckSummary.createReportSummary(this);
}
Expand All @@ -137,26 +132,10 @@ public String getSummary() {
*
* @return the HTML fragment of the summary Cppcheck report
*/
@SuppressWarnings("unused")
public String getDetails() {
return CppcheckSummary.createReportSummaryDetails(this);
}

/**
* Gets the previous Cppcheck report for the build result.
*
* @return the previous Cppcheck report
*/
@SuppressWarnings("unused")
private CppcheckReport getPreviousReport() {
CppcheckResult previous = this.getPreviousResult();
if (previous == null) {
return null;
} else {
return previous.getReport();
}
}

/**
* Gets the previous Cppcheck result for the build result.
*
Expand Down
Expand Up @@ -24,21 +24,23 @@
package com.thalesgroup.hudson.plugins.cppcheck.model;

import com.thalesgroup.hudson.plugins.cppcheck.util.CppcheckLogger;

import hudson.FilePath;
import hudson.model.BuildListener;

import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CppcheckSourceContainer {

public class CppcheckSourceContainer implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 1L;

private Map<Integer, CppcheckWorkspaceFile> internalMap = new HashMap<Integer, CppcheckWorkspaceFile>();

public CppcheckSourceContainer(BuildListener listener, FilePath basedir, List<CppcheckFile> files) throws IOException, InterruptedException {

int key = 1;
for (CppcheckFile cppcheckFile : files) {

Expand Down Expand Up @@ -71,7 +73,6 @@ public CppcheckSourceContainer(BuildListener listener, FilePath basedir, List<Cp
}
}


public Map<Integer, CppcheckWorkspaceFile> getInternalMap() {
return internalMap;
}
Expand Down
Expand Up @@ -24,12 +24,17 @@
package com.thalesgroup.hudson.plugins.cppcheck.model;

import hudson.model.AbstractBuild;

import org.apache.commons.lang.StringUtils;
import org.jenkinsci.plugins.cppcheck.CppcheckDiffState;

import java.io.File;
import java.io.Serializable;

public class CppcheckWorkspaceFile implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 1L;

public class CppcheckWorkspaceFile {
/**
* Subdirectory of build directory to store the workspace files.
*/
Expand Down
Expand Up @@ -7,6 +7,8 @@
* @author Gregory Boissinot
*/
public class CppcheckConfig implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 1L;

private String pattern;
private boolean ignoreBlankFiles;
Expand Down
Expand Up @@ -6,6 +6,8 @@
* @author Gregory Boissinot
*/
public class CppcheckConfigGraph implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 1L;

public static final int DEFAULT_CHART_WIDTH = 500;
public static final int DEFAULT_CHART_HEIGHT = 200;
Expand Down
Expand Up @@ -6,6 +6,8 @@
* @author Gregory Boissinot
*/
public class CppcheckConfigSeverityEvaluation implements Serializable {
/** Serial version UID. */
private static final long serialVersionUID = 1L;

private String threshold;

Expand Down
Expand Up @@ -10,7 +10,7 @@ public static int convert(String threshold) {
if (isValid(threshold)) {
if (StringUtils.isNotBlank(threshold)) {
try {
return Integer.valueOf(threshold);
return Integer.parseInt(threshold);
} catch (NumberFormatException exception) {
// not valid
}
Expand All @@ -22,7 +22,7 @@ public static int convert(String threshold) {
public static boolean isValid(final String threshold) {
if (StringUtils.isNotBlank(threshold)) {
try {
return Integer.valueOf(threshold) >= 0;
return Integer.parseInt(threshold) >= 0;
} catch (NumberFormatException exception) {
// not valid
}
Expand Down
Expand Up @@ -43,6 +43,8 @@ public void createWorkspace() throws Exception {
}

public void deleteWorkspace() throws Exception {
workspace.deleteRecursive();
if(workspace != null) {
workspace.deleteRecursive();
}
}
}
Expand Up @@ -94,7 +94,7 @@ private void processCheckstyle(String filename,
int nbSeveritiesError,
int nbSeveritiesNoCategory) throws Exception {

CppcheckReport cppcheckReport = cppcheckParser.parse(new File(this.getClass().getResource(filename).toURI()));
CppcheckReport cppcheckReport = cppcheckParser.parse(new File(CppcheckParserTest.class.getResource(filename).toURI()));

List<CppcheckFile> everyErrors = cppcheckReport.getEverySeverities();
List<CppcheckFile> possibileErrorSeverities = cppcheckReport.getPossibleErrorSeverities();
Expand Down
Expand Up @@ -36,7 +36,7 @@ private void processCppcheck(String filename,
int nbSeveritiesError,
int nbSeveritiesNoCategory) throws Exception {

CppcheckReport cppcheckReport = cppcheckParser.parse(new File(this.getClass().getResource(filename).toURI()));
CppcheckReport cppcheckReport = cppcheckParser.parse(new File(CppcheckParserTest.class.getResource(filename).toURI()));

List<CppcheckFile> everyErrors = cppcheckReport.getEverySeverities();
List<CppcheckFile> possibileErrorSeverities = cppcheckReport.getPossibleErrorSeverities();
Expand Down

0 comments on commit d72781b

Please sign in to comment.