Fixed the LGTM error "Command line is built with string concatenation" by introducing a String array.
Runtime runtime = Runtime.getRuntime();
try {
if (os.contains("win")) {
- runtime.exec("rundll32 url.dll,FileProtocolHandler " + this.url);
+ runtime.exec(createCommand("rundll32", "url.dll,FileProtocolHandler", this.url));
} else if (os.contains("mac")) {
- runtime.exec("open " + this.url);
+ runtime.exec(createCommand("open", this.url));
} else {
- runtime.exec("xdg-open " + this.url);
+ runtime.exec(createCommand("xdg-open", this.url));
}
} catch (IOException e) {
LOGGER.warn("Can't recognize your OS and open the url {}.", this.url);
@@ -142,6 +142,10 @@ private boolean hasConfirmation() {
return confirmed.get() != null && confirmed.get();
}
+ private String[] createCommand(String... arguments) {
+ return arguments;
+ }
+
/**
* Sets the {@link UIButtonWebBrowser#url} value and sets {@link UIButtonWebBrowser#confirmed}
* to true if the given URL is already trusted, otherwise confirmed is false.
