Skip to content

Commit

Permalink
Merge pull request #2194 from guwirth/save-metrics
Browse files Browse the repository at this point in the history
make save measures for InputFiles more robust
  • Loading branch information
guwirth authored Jun 15, 2021
2 parents 4c9e5b6 + 3605dcf commit dcf815e
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,23 +358,21 @@ private CxxSquidConfiguration createConfiguration() {
}

private void save(Collection<SourceCode> sourceCodeFiles) {
// don't publish metrics on modules, which were not analyzed
// otherwise hierarchical multi-module projects will contain wrong metrics ( == 0)
// see also AggregateMeasureComputer
if (sourceCodeFiles.isEmpty()) {
return;
}

for (var sourceCodeFile : sourceCodeFiles) {
var sourceFile = (SourceFile) sourceCodeFile;
var ioFile = new File(sourceFile.getKey());
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().is(ioFile));

saveMeasures(inputFile, sourceFile);
saveViolations(inputFile, sourceFile);
saveFileLinesContext(inputFile, sourceFile);
saveCpdTokens(inputFile, sourceFile);
saveHighlighting(inputFile, sourceFile);
try {
var sourceFile = (SourceFile) sourceCodeFile;
var ioFile = new File(sourceFile.getKey());
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().is(ioFile));

saveMeasures(inputFile, sourceFile);
saveViolations(inputFile, sourceFile);
saveFileLinesContext(inputFile, sourceFile);
saveCpdTokens(inputFile, sourceFile);
saveHighlighting(inputFile, sourceFile);
} catch (IllegalStateException e) {
var msg = "Cannot save all measures for file '" + sourceCodeFile.getKey() + "'";
CxxUtils.validateRecovery(msg, e, context.config());
}
}
}

Expand Down

0 comments on commit dcf815e

Please sign in to comment.