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
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
= new CppcheckSourceContainer(listener, build.getWorkspace(),
build.getModuleRoot(), cppcheckReport.getAllErrors());

CppcheckResult result = new CppcheckResult(cppcheckReport.getStatistics(), build);
CppcheckResult result = new CppcheckResult(cppcheckReport.getStatistics(), build, cppcheckSourceContainer);
CppcheckConfigSeverityEvaluation severityEvaluation
= cppcheckConfig.getConfigSeverityEvaluation();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
*/
public class CppcheckResult implements Serializable {
private static final long serialVersionUID = 2L;

private int newFailures = 0;

/**
* The Cppcheck report.
Expand Down Expand Up @@ -70,6 +72,26 @@ public CppcheckResult(CppcheckStatistics statistics, AbstractBuild<?, ?> owner)
this.owner = owner;
}

/**
* Alternate Constructor.
*
* @param statistics
* the Cppcheck report statistics
* @param owner
* the build owner
*
* @param CppcheckSourcesContainer
* Container for check results
*
* Added to enable "new errors" to work off all new errors instead of the sum.
*/

public CppcheckResult(CppcheckStatistics statistics, AbstractBuild<?, ?> owner, CppcheckSourceContainer cppcheckSourceContainer) {
this.statistics = statistics;
this.owner = owner;
this.cppcheckSourceContainer = cppcheckSourceContainer;
}

/**
* Constructor. Only for backward compatibility with previous versions.
*
Expand Down Expand Up @@ -344,8 +366,9 @@ public int getNumberErrorsAccordingConfiguration(

if (checkNewError) {
if (previousResult != null) {
return nbErrors - nbPreviousError;
} else {
diffCurrentAndPrevious(null);
return this.newFailures;
} else {
return 0;
}
} else {
Expand All @@ -367,6 +390,7 @@ public int getNumberErrorsAccordingConfiguration(
*/
public Collection<CppcheckWorkspaceFile> diffCurrentAndPrevious(
Set<CppcheckDiffState> filter) {
this.newFailures = 0;
CppcheckSourceContainer cur = getCppcheckSourceContainer();
CppcheckResult prevResult = getPreviousResult();
List<CppcheckWorkspaceFile> curValues
Expand Down Expand Up @@ -429,6 +453,7 @@ public Collection<CppcheckWorkspaceFile> diffCurrentAndPrevious(
if(curFile.getDiffState() != null) {
continue;
}
this.newFailures += 1;

curFile.setDiffState(CppcheckDiffState.NEW);
}
Expand Down