Skip to content
Permalink
Browse files
[FIXED JENKINS-9309] sloccount trend report only works up to last fai…
…led build (3th version)
  • Loading branch information
Karsten Brandt authored and Karsten Brandt committed Jun 7, 2012
1 parent 92f5ca9 commit 2d0f2d6358cad6ae144abef5e6f304c4e3e5bb94
Showing 2 changed files with 24 additions and 22 deletions.
@@ -49,29 +49,30 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene

SloccountResult result;

FilePath workspace = build.getWorkspace();
PrintStream logger = listener.getLogger();
SloccountParser parser = new SloccountParser(this.getRealEncoding(), this.getRealPattern(), logger);
SloccountReport report;
SloccountReport report = new SloccountReport();
SloccountParser parser = new SloccountParser(this.getRealEncoding(), this.getRealPattern(), logger, report);

try{
if(this.canContinue(build.getResult())){
if(this.canContinue(build.getResult())){

try{
FilePath workspace = build.getWorkspace();
report = workspace.act(parser);
}else{
// generate an empty report
// TODO: Replace this empty report with the last valid one?
report = new SloccountReport();

}catch(IOException ioe){
ioe.printStackTrace(logger);
return false;

}catch(InterruptedException ie){
ie.printStackTrace(logger);
return false;
}

}catch(IOException ioe){
ioe.printStackTrace(logger);
return false;

}catch(InterruptedException ie){
ie.printStackTrace(logger);
return false;
}else{

// continue with empty report object
}

result = new SloccountResult(report, build);

SloccountBuildAction buildAction = new SloccountBuildAction(build, result);
@@ -21,26 +21,27 @@ public class SloccountParser implements FilePath.FileCallable<SloccountReport> {
private final String encoding;
private final String filePattern;
private transient PrintStream logger = null;
private transient SloccountReport report = null;

public SloccountParser(String encoding, String filePattern, PrintStream logger){
public SloccountParser(String encoding, String filePattern, PrintStream logger, SloccountReport report){
this.report = report;
this.logger = logger;
this.filePattern = filePattern;
this.encoding = encoding;
}


public SloccountReport invoke(java.io.File workspace, VirtualChannel channel) throws IOException {
SloccountReport report = new SloccountReport();

FileFinder finder = new FileFinder(this.filePattern);
String[] found = finder.find(workspace);

for(String fileName : found){
this.parse(workspace, fileName, report);
this.parse(workspace, fileName, this.report);
}

report.simplifyNames();
return report;
this.report.simplifyNames();
return this.report;
}

private void parse(java.io.File workspace, String fileName, SloccountReport report) throws IOException {

0 comments on commit 2d0f2d6

Please sign in to comment.