Search in sources :

Example 26 with DetectorEvaluation

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;
}
Also used : DetectorType(com.synopsys.integration.detector.base.DetectorType) StatusType(com.synopsys.integration.detect.workflow.status.StatusType) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation) EnumMap(java.util.EnumMap)

Example 27 with DetectorEvaluation

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<>());
}
Also used : DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) DetectorResult(com.synopsys.integration.detector.result.DetectorResult) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation) File(java.io.File) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment)

Example 28 with DetectorEvaluation

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);
}
Also used : DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation)

Example 29 with DetectorEvaluation

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);
    }
}
Also used : DetectorType(com.synopsys.integration.detector.base.DetectorType) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation)

Example 30 with DetectorEvaluation

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);
    }
}
Also used : DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation) ReportWriter(com.synopsys.integration.detect.workflow.report.writer.ReportWriter) List(java.util.List) DetectorEvaluationUtils(com.synopsys.integration.detect.workflow.report.util.DetectorEvaluationUtils) ReporterUtils(com.synopsys.integration.detect.workflow.report.util.ReporterUtils) DetectorEvaluationTree(com.synopsys.integration.detector.base.DetectorEvaluationTree) Collectors(java.util.stream.Collectors) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) DetectorEvaluation(com.synopsys.integration.detector.base.DetectorEvaluation)

Aggregations

DetectorEvaluation (com.synopsys.integration.detector.base.DetectorEvaluation)30 DetectorEvaluationTree (com.synopsys.integration.detector.base.DetectorEvaluationTree)28 File (java.io.File)15 Test (org.junit.jupiter.api.Test)14 DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)11 Detectable (com.synopsys.integration.detectable.Detectable)10 DetectorRule (com.synopsys.integration.detector.rule.DetectorRule)9 DetectorResult (com.synopsys.integration.detector.result.DetectorResult)8 DetectableResult (com.synopsys.integration.detectable.detectable.result.DetectableResult)7 ExtractionEnvironment (com.synopsys.integration.detectable.extraction.ExtractionEnvironment)7 List (java.util.List)7 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)7 Mockito (org.mockito.Mockito)7 Collections (java.util.Collections)6 DetectableException (com.synopsys.integration.detectable.detectable.exception.DetectableException)5 PassedDetectableResult (com.synopsys.integration.detectable.detectable.result.PassedDetectableResult)5 Extraction (com.synopsys.integration.detectable.extraction.Extraction)5 DetectorRuleSet (com.synopsys.integration.detector.rule.DetectorRuleSet)5 Function (java.util.function.Function)5 Predicate (java.util.function.Predicate)5