use of com.synopsys.integration.detector.base.DetectorEvaluation in project synopsys-detect by blackducksoftware.
the class DetectorTool method extractStatus.
private Map<DetectorType, StatusType> extractStatus(List<DetectorEvaluation> detectorEvaluations) {
EnumMap<DetectorType, StatusType> statusMap = new EnumMap<>(DetectorType.class);
for (DetectorEvaluation detectorEvaluation : detectorEvaluations) {
DetectorType detectorType = detectorEvaluation.getDetectorType();
Optional<StatusType> foundStatusType = determineDetectorExtractionStatus(detectorEvaluation);
if (foundStatusType.isPresent()) {
StatusType statusType = foundStatusType.get();
if (statusType == StatusType.FAILURE || !statusMap.containsKey(detectorType)) {
statusMap.put(detectorType, statusType);
}
}
}
return statusMap;
}
use of com.synopsys.integration.detector.base.DetectorEvaluation in project synopsys-detect by blackducksoftware.
the class DetectorToolTest method createEvaluationTree.
private DetectorEvaluationTree createEvaluationTree(Extraction extraction, DetectableResult extractionResult, File directory, DetectorRule<GoModCliDetectable> rule, DetectorRuleSet detectorRuleSet) {
DetectorEvaluation detectorEvaluation = new DetectorEvaluation(rule);
DetectorResult extractableResult = new DetectorResult(extractionResult.getPassed(), extractionResult.toDescription(), extractionResult.getClass(), Collections.emptyList(), Collections.emptyList());
detectorEvaluation.setExtractable(extractableResult);
detectorEvaluation.setExtraction(extraction);
detectorEvaluation.setApplicable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
detectorEvaluation.setSearchable(new DetectorResult(true, "", Collections.emptyList(), Collections.emptyList()));
detectorEvaluation.setDetectableEnvironment(new DetectableEnvironment(new File("")));
return new DetectorEvaluationTree(directory, 0, detectorRuleSet, Collections.singletonList(detectorEvaluation), new HashSet<>());
}
use of com.synopsys.integration.detector.base.DetectorEvaluation in project synopsys-detect by blackducksoftware.
the class ExtractionSummaryReporter method writeSummary.
public void writeSummary(ReportWriter writer, DetectorEvaluationTree rootEvaluation, Map<CodeLocation, DetectCodeLocation> detectableMap, Map<DetectCodeLocation, String> codeLocationNameMap, boolean writeCodeLocationNames) {
ReporterUtils.printHeader(writer, "Extraction results:");
boolean printedAny = false;
for (DetectorEvaluationTree it : rootEvaluation.asFlatList()) {
List<DetectorEvaluation> success = DetectorEvaluationUtils.filteredChildren(it, DetectorEvaluation::wasExtractionSuccessful);
List<DetectorEvaluation> exception = DetectorEvaluationUtils.filteredChildren(it, DetectorEvaluation::wasExtractionException);
List<DetectorEvaluation> failed = DetectorEvaluationUtils.filteredChildren(it, DetectorEvaluation::wasExtractionFailure);
if (success.size() > 0 || exception.size() > 0 || failed.size() > 0) {
writer.writeLine(it.getDirectory().toString());
List<String> codeLocationNames = findCodeLocationNames(it, detectableMap, codeLocationNameMap);
writer.writeLine("\tCode locations: " + codeLocationNames.size());
if (writeCodeLocationNames) {
codeLocationNames.forEach(name -> writer.writeLine("\t\t" + name));
}
writeEvaluationsIfNotEmpty(writer, "\tSuccess: ", success);
writeEvaluationsIfNotEmpty(writer, "\tFailure: ", failed);
writeEvaluationsIfNotEmpty(writer, "\tException: ", exception);
printedAny = true;
}
}
if (!printedAny) {
writer.writeLine("There were no extractions to be summarized - no code locations were generated or no detectors were evaluated.");
}
ReporterUtils.printFooter(writer);
}
use of com.synopsys.integration.detector.base.DetectorEvaluation in project synopsys-detect by blackducksoftware.
the class DetectorProfiler method addAggregateByDetectorGroupType.
private void addAggregateByDetectorGroupType(Map<DetectorType, Long> aggregate, List<Timing<DetectorEvaluation>> timings) {
for (Timing<DetectorEvaluation> timing : timings) {
DetectorType type = timing.getKey().getDetectorType();
if (!aggregate.containsKey(type)) {
aggregate.put(type, 0L);
}
long time = timing.getMs();
Long currentTime = aggregate.get(type);
Long sum = time + currentTime;
aggregate.put(type, sum);
}
}
use of com.synopsys.integration.detector.base.DetectorEvaluation in project synopsys-detect by blackducksoftware.
the class PreparationSummaryReporter method writeSummary.
private void writeSummary(ReportWriter writer, List<DetectorEvaluationTree> detectorEvaluationTrees) {
List<String> lines = new ArrayList<>();
for (DetectorEvaluationTree detectorEvaluationTree : detectorEvaluationTrees) {
List<DetectorEvaluation> applicable = DetectorEvaluationUtils.applicableChildren(detectorEvaluationTree);
List<DetectorEvaluation> ready = applicable.stream().filter(DetectorEvaluation::isExtractable).collect(Collectors.toList());
List<DetectorEvaluation> notExtractable = applicable.stream().filter(it -> !it.isExtractable()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(ready) || CollectionUtils.isNotEmpty(notExtractable)) {
lines.add(detectorEvaluationTree.getDirectory().toString());
if (CollectionUtils.isNotEmpty(ready)) {
lines.add("\t READY: " + ready.stream().map(it -> it.getDetectorRule().getDescriptiveName()).sorted().collect(Collectors.joining(", ")));
}
}
}
if (CollectionUtils.isNotEmpty(lines)) {
ReporterUtils.printHeader(writer, "Preparation for extraction");
lines.forEach(writer::writeLine);
ReporterUtils.printFooter(writer);
}
}
Aggregations