Refactor common code on multiple methods of InferRestults

Reviewed By: sblackshear

Differential Revision: D3611216

fbshipit-source-id: 28ebd23
master
Lázaro Clapp Jiménez Labora 8 years ago committed by Facebook Github Bot 1
parent 6a1a0d68da
commit cbd1b9c7ba

@ -154,76 +154,64 @@ public class InferResults {
return inferResults; return inferResults;
} }
public static InferResults loadInferResults(Class currentClass, String sourceFile) { private static InferResults loadResultsFromPath(Class currentClass, String sourceFile,
String csvPath, Pattern procnamePattern) {
BufferedReader reader = BufferedReader reader =
new BufferedReader( new BufferedReader(
new InputStreamReader( new InputStreamReader(
currentClass.getResourceAsStream( currentClass.getResourceAsStream(csvPath)));
"/infer/tests/codetoanalyze/java/infer/report.csv")));
return loadResultsFromReader( return loadResultsFromReader(
Preconditions.checkNotNull(reader), Preconditions.checkNotNull(reader),
sourceFile, sourceFile,
InferResults.JAVA_METHOD_NAME); procnamePattern);
}
public static InferResults loadInferResults(Class currentClass, String sourceFile) {
return loadResultsFromPath(
currentClass,
sourceFile,
"/infer/tests/codetoanalyze/java/infer/report.csv",
InferResults.JAVA_METHOD_NAME);
} }
public static InferResults loadEradicateResults(Class currentClass, String sourceFile) { public static InferResults loadEradicateResults(Class currentClass, String sourceFile) {
BufferedReader reader = return loadResultsFromPath(
new BufferedReader( currentClass,
new InputStreamReader( sourceFile,
currentClass.getResourceAsStream( "/infer/tests/codetoanalyze/java/eradicate/report.csv",
"/infer/tests/codetoanalyze/java/eradicate/report.csv"))); InferResults.JAVA_METHOD_NAME);
return loadResultsFromReader(
Preconditions.checkNotNull(reader),
sourceFile,
InferResults.JAVA_METHOD_NAME);
} }
public static InferResults loadCheckersResults(Class currentClass, String sourceFile) { public static InferResults loadCheckersResults(Class currentClass, String sourceFile) {
BufferedReader reader = return loadResultsFromPath(
new BufferedReader( currentClass,
new InputStreamReader( sourceFile,
currentClass.getResourceAsStream( "/infer/tests/codetoanalyze/java/checkers/report.csv",
"/infer/tests/codetoanalyze/java/checkers/report.csv"))); InferResults.JAVA_METHOD_NAME);
return loadResultsFromReader(
Preconditions.checkNotNull(reader),
sourceFile,
InferResults.JAVA_METHOD_NAME);
} }
public static InferResults loadTracingResults(Class currentClass, String sourceFile) { public static InferResults loadTracingResults(Class currentClass, String sourceFile) {
BufferedReader reader = return loadResultsFromPath(
new BufferedReader( currentClass,
new InputStreamReader( sourceFile,
currentClass.getResourceAsStream( "/infer/tests/codetoanalyze/java/tracing/report.csv",
"/infer/tests/codetoanalyze/java/tracing/report.csv"))); InferResults.JAVA_METHOD_NAME);
return loadResultsFromReader(
Preconditions.checkNotNull(reader),
sourceFile,
InferResults.JAVA_METHOD_NAME);
} }
public static InferResults loadTracingComparisonResults(Class currentClass, String sourceFile) { public static InferResults loadTracingComparisonResults(Class currentClass, String sourceFile) {
BufferedReader reader = return loadResultsFromPath(
new BufferedReader( currentClass,
new InputStreamReader( sourceFile,
currentClass.getResourceAsStream( "/infer/tests/codetoanalyze/java/infer/comparison_report.csv",
"/infer/tests/codetoanalyze/java/infer/comparison_report.csv"))); InferResults.JAVA_METHOD_NAME);
return loadResultsFromReader(
Preconditions.checkNotNull(reader),
sourceFile,
InferResults.JAVA_METHOD_NAME);
} }
public static InferResults loadCInferResults(Class currentClass, String sourceFile) { public static InferResults loadCInferResults(Class currentClass, String sourceFile) {
BufferedReader reader = return loadResultsFromPath(
new BufferedReader( currentClass,
new InputStreamReader( sourceFile,
currentClass.getResourceAsStream( "/infer/tests/codetoanalyze/c/errors/report.csv",
"/infer/tests/codetoanalyze/c/errors/report.csv"))); InferResults.C_FUNCTION_NAME);
return loadResultsFromReader(
Preconditions.checkNotNull(reader),
sourceFile,
InferResults.C_FUNCTION_NAME);
} }
} }

Loading…
Cancel
Save