Skip to content
Open
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
80 changes: 71 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.447</version>
<version>2.0</version>
</parent>

<artifactId>cppcheck</artifactId>
Expand All @@ -31,25 +31,30 @@
<name>Michal Turek</name>
<email>mixalturek@users.sf.net</email>
</developer>
<developer>
<id>marcosteffan</id>
<name>Marco Steffan</name>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/jenkinsci/cppcheck-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/cppcheck-plugin.git</developerConnection>
<tag>HEAD</tag>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<jaxb.api.version>2.2.1</jaxb.api.version>
<jaxb.impl.version>2.2.1.1</jaxb.impl.version>
<jaxb2.maven.plugin.version>2.1</jaxb2.maven.plugin.version>
<jaxb2.maven.plugin.version>1.3</jaxb2.maven.plugin.version>
<java2html.version>5.0</java2html.version>
<junit.version>4.8.2</junit.version>
<mockito.version>1.8.5</mockito.version>
<dashboard.view.version>2.0</dashboard.view.version>
<jenkins.version>2.30</jenkins.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -102,6 +107,59 @@
</dependencies>

<build>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only.
It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>[0.5,)
</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<!-- m2e doesn't know what to do with jacoco,
let's ignore it or annoying error markers appear
see http://wiki.eclipse.org/M2E_plugin_execution_not_covered
-->
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>InjectedTest.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>InjectedTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand All @@ -112,9 +170,11 @@
<id>generatedCppcheck1</id>
<configuration>
<packageName>com.thalesgroup.jenkinsci.plugins.cppcheck.model</packageName>
<sources>
<source>${basedir}/src/main/resources/com/thalesgroup/hudson/plugins/cppcheck/cppcheck-1.0.xsd</source>
</sources>
<schemaDirectory>${basedir}/src/main/resources/com/thalesgroup/hudson/plugins/cppcheck
</schemaDirectory>
<schemaFiles>cppcheck-1.0.xsd</schemaFiles>
<staleFile>${project.build.directory}/generated-sources/jaxb/cppcheck1/.staleFlag.
</staleFile>
<clearOutputDir>false</clearOutputDir>
</configuration>
<goals>
Expand All @@ -125,9 +185,11 @@
<id>generatedCppcheck2</id>
<configuration>
<packageName>org.jenkinsci.plugins.cppcheck.model</packageName>
<sources>
<source>${basedir}/src/main/resources/org/jenkinsci/plugins/cppcheck/cppcheck-2.0.xsd</source>
</sources>
<schemaDirectory>${basedir}/src/main/resources/org/jenkinsci/plugins/cppcheck
</schemaDirectory>
<schemaFiles>cppcheck-2.0.xsd</schemaFiles>
<staleFile>${project.build.directory}/generated-sources/jaxb/cppcheck2/.staleFlag.
</staleFile>
<clearOutputDir>false</clearOutputDir>
</configuration>
<goals>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,30 @@ public final String generateURL(final CategoryDataset dataset, final int row, fi
private NumberOnlyBuildLabel getLabel(final CategoryDataset dataset, final int column) {
return (NumberOnlyBuildLabel) dataset.getColumnKey(column);
}

/**
* Checks this instance for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> not permitted).
*
* @return A boolean.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof CppcheckAreaRenderer)) {
return false;
}
CppcheckAreaRenderer that = (CppcheckAreaRenderer) obj;

if (this.url != that.url) {
return false;
}
return super.equals(obj);
}

public int hashCode() {
return this.url.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import com.thalesgroup.hudson.plugins.cppcheck.model.CppcheckSourceContainer;
import com.thalesgroup.hudson.plugins.cppcheck.util.AbstractCppcheckBuildAction;
import com.thalesgroup.hudson.plugins.cppcheck.util.CppcheckBuildHealthEvaluator;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.model.HealthReport;
import hudson.util.ChartUtil;
import hudson.util.ChartUtil.NumberOnlyBuildLabel;
Expand All @@ -52,7 +52,7 @@ public class CppcheckBuildAction extends AbstractCppcheckBuildAction {
private CppcheckResult result;
private CppcheckConfig cppcheckConfig;

public CppcheckBuildAction(AbstractBuild<?, ?> owner, CppcheckResult result, CppcheckConfig cppcheckConfig) {
public CppcheckBuildAction(Run<?, ?> owner, CppcheckResult result, CppcheckConfig cppcheckConfig) {
super(owner);
this.result = result;
this.cppcheckConfig = cppcheckConfig;
Expand All @@ -78,7 +78,7 @@ public CppcheckResult getResult() {
return this.result;
}

AbstractBuild<?, ?> getBuild() {
Run<?, ?> getBuild() {
return this.owner;
}

Expand Down Expand Up @@ -139,7 +139,7 @@ public void doGraph(StaplerRequest req, StaplerResponse rsp) throws IOException
// Backward compatibility. Do not remove.
// CPPCHECK:OFF
@Deprecated
private transient AbstractBuild<?, ?> build;
private transient Run<?, ?> build;

/**
* Initializes members that were not present in previous versions of this plug-in.
Expand Down Expand Up @@ -203,6 +203,6 @@ private Object readResolve() {


return new org.jenkinsci.plugins.cppcheck.CppcheckBuildAction(owner,
newResult, 100);
newResult, newConfig, 100);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
import hudson.Util;
import hudson.model.BuildListener;
import hudson.remoting.VirtualChannel;
import jenkins.security.Roles;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.selectors.FileSelector;
import org.jenkinsci.remoting.RoleChecker;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -124,5 +126,9 @@ public boolean isSelected(File basedir, String filename, File file) throws Build
public String getCppcheckReportPattern() {
return cppcheckReportPattern;
}


@Override
public void checkRoles(RoleChecker checker) throws SecurityException {
checker.check(this, Roles.SLAVE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
package com.thalesgroup.hudson.plugins.cppcheck;

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

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.Result;
Expand All @@ -48,6 +50,7 @@ public CppcheckProjectAction(final AbstractProject<?, ?> project) {
}

@SuppressWarnings("unused")
@SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE")
public final boolean isDisplayGraph() {
//Latest
AbstractBuild<?, ?> b = getLastFinishedBuild();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class CppcheckResult implements Serializable {
/**
* The build owner
*/
private AbstractBuild<?, ?> owner;
private transient AbstractBuild<?, ?> owner;

public CppcheckResult(CppcheckReport report, CppcheckSourceContainer cppcheckSourceContainer, AbstractBuild<?, ?> owner) {
this.report = report;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
import de.java2html.javasource.JavaSource;
import de.java2html.javasource.JavaSourceParser;
import de.java2html.options.JavaSourceConversionOptions;
import hudson.model.AbstractBuild;
import hudson.model.Run;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.LineIterator;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;

import java.io.*;
import java.nio.charset.StandardCharsets;


public class CppcheckSource implements Serializable {
Expand All @@ -55,7 +56,7 @@ public class CppcheckSource implements Serializable {
/**
* The current build as owner of this object.
*/
private final AbstractBuild<?, ?> owner;
private transient final Run<?, ?> owner;

/**
* The cppcheck source file in the workspace to be shown.
Expand All @@ -73,7 +74,7 @@ public class CppcheckSource implements Serializable {
* @param owner the current build as owner of this object
* @param cppcheckWorkspaceFile the abstract workspace file
*/
public CppcheckSource(final AbstractBuild<?, ?> owner, CppcheckWorkspaceFile cppcheckWorkspaceFile) {
public CppcheckSource(final Run<?, ?> owner, CppcheckWorkspaceFile cppcheckWorkspaceFile) {
this.owner = owner;
this.cppcheckWorkspaceFile = cppcheckWorkspaceFile;
buildFileContent();
Expand Down Expand Up @@ -106,7 +107,7 @@ private void buildFileContent() {

splitSourceFile(highlightSource(is));
} catch (IOException exception) {
sourceCode = "Can't read file: " + exception.getLocalizedMessage();
sourceCode = "Can't read file : " + exception.getLocalizedMessage();
} catch (RuntimeException re) {
sourceCode = "Problem for display the source code content: " + re.getLocalizedMessage();
} finally {
Expand Down Expand Up @@ -226,7 +227,7 @@ private void copyLine(final StringBuilder output, final LineIterator lineIterato
*/
public final String highlightSource(final InputStream file) throws IOException {

JavaSource source = new JavaSourceParser().parse(new InputStreamReader(file));
JavaSource source = new JavaSourceParser().parse(new InputStreamReader(file, StandardCharsets.UTF_8));
JavaSource2HTMLConverter converter = new JavaSource2HTMLConverter();
StringWriter writer = new StringWriter();
JavaSourceConversionOptions options = JavaSourceConversionOptions.getDefault();
Expand Down Expand Up @@ -260,7 +261,7 @@ public CppcheckWorkspaceFile getCppcheckWorkspaceFile() {
*
* @return the build
*/
public AbstractBuild<?, ?> getOwner() {
public Run<?, ?> getOwner() {
return owner;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*******************************************************************************/
package com.thalesgroup.hudson.plugins.cppcheck.graph;

import hudson.model.AbstractBuild;
import hudson.model.Run;
import hudson.util.ColorPalette;
import hudson.util.Graph;
import hudson.util.ShiftedCategoryAxis;
Expand Down Expand Up @@ -67,7 +67,7 @@ public class CppcheckGraph extends Graph {
private static final List<Color> colors = Collections.unmodifiableList(
Arrays.asList(RED, BLUE, GREEN, YELLOW, BROWN, GRAY, VIOLET, PINK));

public CppcheckGraph(AbstractBuild<?, ?> owner, CategoryDataset categoryDataset,
public CppcheckGraph(Run<?, ?> owner, CategoryDataset categoryDataset,
String yLabel, int chartWidth, int chartHeight) {
super(owner.getTimestamp(), chartWidth, chartHeight);
this.yLabel = yLabel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

package com.thalesgroup.hudson.plugins.cppcheck.model;

import hudson.model.AbstractBuild;
import hudson.model.Run;

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

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

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

Expand Down Expand Up @@ -57,6 +59,7 @@ public class CppcheckWorkspaceFile implements Serializable {
*/
private transient CppcheckDiffState diffState = null;

@SuppressFBWarnings("NP_NULL_ON_SOME_PATH")
public CppcheckWorkspaceFile(File file) {
if (file != null)
this.fileName = file.getAbsolutePath().replace('\\', '/');
Expand Down Expand Up @@ -103,10 +106,10 @@ public final String getFileName() {
return fileName;
}

public String getTempName(final AbstractBuild<?, ?> owner) {
public String getTempName(final Run<?, ?> owner) {
if (fileName != null) {
return owner.getRootDir().getAbsolutePath() + "/"
+ DIR_WORKSPACE_FILES + "/"
return owner.getRootDir() + "/"
+ DIR_WORKSPACE_FILES + "/"
+ Integer.toHexString(fileName.hashCode()) + ".tmp";
}
return StringUtils.EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import org.kohsuke.stapler.StaplerProxy;

public abstract class AbstractCppcheckBuildAction extends Actionable implements Action, HealthReportingAction, StaplerProxy {
protected AbstractBuild<?, ?> owner;
protected Run<?, ?> owner;

protected AbstractCppcheckBuildAction(AbstractBuild<?, ?> owner) {
protected AbstractCppcheckBuildAction(Run<?, ?> owner) {
this.owner = owner;
}

public <T extends AbstractCppcheckBuildAction> T getPreviousResult() {
AbstractBuild<?, ?> b = owner;
Run<?, ?> b = owner;
while (true) {
b = b.getPreviousBuild();
if (b == null)
Expand All @@ -46,7 +46,7 @@ public <T extends AbstractCppcheckBuildAction> T getPreviousResult() {
}
}

public AbstractBuild<?, ?> getOwner() {
public Run<?, ?> getOwner() {
return owner;
}
}
Loading