refactor: Encapsulate the error messages into static strings.
@@ -35,18 +35,20 @@ import com.synopsys.integration.executable.ExecutableRunnerException;
public class GoModCommandExecutor {
private static final String FAILURE_MSG_QUERYING_FOR_THE_GO_MOD_GRAPH = "Querying for the go mod graph failed:";
+ private static final String FAILURE_MSG_QUERYING_GO_FOR_THE_LIST_OF_MODULES = "Querying go for the list of modules failed: ";
+ private static final String FAILURE_MSG_QUERYING_FOR_THE_VERSION = "Querying for the version failed: ";
private final DetectableExecutableRunner executableRunner;
- public GoModCommandExecutor(final DetectableExecutableRunner executableRunner) {
+ public GoModCommandExecutor(DetectableExecutableRunner executableRunner) {
this.executableRunner = executableRunner;
}
List<String> generateGoListOutput(File directory, File goExe) throws ExecutableRunnerException, DetectableException {
- return execute(directory, goExe, "Querying go for the list of modules failed: ", "list", "-m");
+ return execute(directory, goExe, FAILURE_MSG_QUERYING_GO_FOR_THE_LIST_OF_MODULES, "list", "-m");
}
List<String> generateGoListUJsonOutput(File directory, File goExe) throws ExecutableRunnerException, DetectableException {
- List<String> goVersionOutput = execute(directory, goExe, "Querying for the version failed: ", "version");
+ List<String> goVersionOutput = execute(directory, goExe, FAILURE_MSG_QUERYING_FOR_THE_VERSION, "version");
Pattern pattern = Pattern.compile("\\d+\\.[\\d.]+");
Matcher matcher = pattern.matcher(goVersionOutput.get(0));
if (matcher.find()) {
