| 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | // Copyright 2026 Egothor | |
| 3 | // Copyright 2026 Accenture | |
| 4 | package org.egothor.methodatlas.evidencereport; | |
| 5 | ||
| 6 | import java.io.IOException; | |
| 7 | import java.nio.file.Path; | |
| 8 | import java.util.List; | |
| 9 | ||
| 10 | import org.egothor.methodatlas.emit.TestMethodSink; | |
| 11 | ||
| 12 | /** | |
| 13 | * Single public entry point used by {@code MethodAtlasApp} to drive {@code -evidence-report}. | |
| 14 | * | |
| 15 | * <p> | |
| 16 | * The package's collector, report records, and writer are all package-private so they remain | |
| 17 | * implementation details. The facade exposes only the operations the CLI needs: | |
| 18 | * </p> | |
| 19 | * <ol> | |
| 20 | * <li>prepare a collector (returning a handle that must be threaded through the orchestrator | |
| 21 | * as an extra sink);</li> | |
| 22 | * <li>after the scan, ask the same handle to write the Markdown evidence report.</li> | |
| 23 | * </ol> | |
| 24 | */ | |
| 25 | public final class EvidenceReportFacade { | |
| 26 | ||
| 27 | /** Default filename used when {@code -evidence-report-file} is not supplied. */ | |
| 28 | public static final String DEFAULT_REPORT_FILENAME = "security-evidence-report.md"; | |
| 29 | ||
| 30 | private EvidenceReportFacade() { | |
| 31 | // Utility class. | |
| 32 | } | |
| 33 | ||
| 34 | /** | |
| 35 | * Prepares an evidence-report collector. | |
| 36 | * | |
| 37 | * @param minConfidence AI minimum-confidence threshold; AI-only evidence below this | |
| 38 | * value is excluded from the report | |
| 39 | * @param scanRoots paths passed to the scan; included verbatim in the report header | |
| 40 | * @return handle ready for use by the orchestrator and writer | |
| 41 | */ | |
| 42 | public static Handle prepare(double minConfidence, List<Path> scanRoots) { | |
| 43 | EvidenceReportCollector collector = new EvidenceReportCollector(minConfidence, scanRoots); | |
| 44 |
1
1. prepare : replaced return value with null for org/egothor/methodatlas/evidencereport/EvidenceReportFacade::prepare → NO_COVERAGE |
return new Handle(collector); |
| 45 | } | |
| 46 | ||
| 47 | /** | |
| 48 | * Opaque handle returned by {@link #prepare(double, List)}. Carries the collector through | |
| 49 | * the scan and yields the Markdown report when the scan is done. | |
| 50 | */ | |
| 51 | public static final class Handle { | |
| 52 | ||
| 53 | /** Backing collector — owned by this handle, never exposed directly. */ | |
| 54 | private final EvidenceReportCollector collector; | |
| 55 | ||
| 56 | private Handle(EvidenceReportCollector collector) { | |
| 57 | this.collector = collector; | |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * Returns the {@link TestMethodSink} that the orchestrator must receive every | |
| 62 | * per-method record on. | |
| 63 | * | |
| 64 | * @return collector as a sink | |
| 65 | */ | |
| 66 | public TestMethodSink asSink() { | |
| 67 |
1
1. asSink : replaced return value with null for org/egothor/methodatlas/evidencereport/EvidenceReportFacade$Handle::asSink → NO_COVERAGE |
return collector; |
| 68 | } | |
| 69 | ||
| 70 | /** | |
| 71 | * Builds the evidence report and writes it to {@code outputFile} as Markdown. | |
| 72 | * | |
| 73 | * @param toolVersion resolved tool version string | |
| 74 | * @param outputFile destination path | |
| 75 | * @throws IOException if the file cannot be written | |
| 76 | */ | |
| 77 | public void write(String toolVersion, Path outputFile) throws IOException { | |
| 78 | EvidenceReport report = collector.buildReport(toolVersion); | |
| 79 | EvidenceReportWriter.write(report, outputFile); | |
| 80 | } | |
| 81 | } | |
| 82 | } | |
Mutations | ||
| 44 |
1.1 |
|
| 67 |
1.1 |