aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-08-27 14:49:41 -0400
committerJim Hahn <jrh3@att.com>2021-08-27 15:48:46 -0400
commit9d8894092ced589c0bdc5b9e85ee1bf1c85d3e36 (patch)
tree88ff5f3891e8780cf8386bb46283dec82c0b3897 /tools
parent18c8028c79d1bdd7bca80fe1e22e2cd9bc072695 (diff)
Address more sonars in apex-pdp
Fixed services-engine thru utilities. Fixed: - use "var" - use Files.delete() - only one method call in assert() Issue-ID: POLICY-3093 Change-Id: I6f62108c770c15e8b84bc51746066fefa409e0fc Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java4
-rw-r--r--tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java21
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java5
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java7
4 files changed, 19 insertions, 18 deletions
diff --git a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java
index ca123c9bb..8e607ebd4 100644
--- a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java
+++ b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/SimpleConsole.java
@@ -133,8 +133,8 @@ public class SimpleConsole extends WebSocketClient {
thread.setName("ClientThread");
thread.start();
- final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- StringBuilder event = new StringBuilder();
+ final var in = new BufferedReader(new InputStreamReader(System.in));
+ var event = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
if ("exit".equals(line)) {
diff --git a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java
index 9b0674df9..e3af4dcc1 100644
--- a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java
+++ b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/WsClientMain.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,14 +51,14 @@ public final class WsClientMain {
/**
* Run the command.
- *
+ *
* @param args the command line arguments
* @param outStream stream for output
*/
WsClientMain(final String[] args, final PrintStream outStream) {
- boolean console = false;
+ var console = false;
- final CliParser cli = new CliParser();
+ final var cli = new CliParser();
cli.addOption(CliOptions.HELP);
cli.addOption(CliOptions.VERSION);
cli.addOption(CliOptions.CONSOLE);
@@ -89,7 +90,7 @@ public final class WsClientMain {
/**
* Run the console or echo.
- *
+ *
* @param console if true, run the console otherwise run echo
* @param cmd the command line to run
* @param outStream stream for output
@@ -140,7 +141,7 @@ public final class WsClientMain {
outStream.println();
try {
- final SimpleEcho simpleEcho = new SimpleEcho(server, port, APP_NAME, outStream, outStream);
+ final var simpleEcho = new SimpleEcho(server, port, APP_NAME, outStream, outStream);
simpleEcho.connect();
} catch (final URISyntaxException uex) {
String message = APP_NAME + ": URI exception, could not create URI from server and port settings";
@@ -180,7 +181,7 @@ public final class WsClientMain {
outStream.println();
try {
- final SimpleConsole simpleConsole = new SimpleConsole(server, port, APP_NAME, outStream, outStream);
+ final var simpleConsole = new SimpleConsole(server, port, APP_NAME, outStream, outStream);
simpleConsole.runClient();
} catch (final URISyntaxException uex) {
String message = APP_NAME + ": URI exception, could not create URI from server and port settings";
@@ -207,15 +208,15 @@ public final class WsClientMain {
/**
* Get the help string for the application.
- *
+ *
* @param cli the command line options
* @return the help string
*/
private String getHelpString(final CliParser cli) {
- HelpFormatter formatter = new HelpFormatter();
+ var formatter = new HelpFormatter();
- final StringWriter helpStringWriter = new StringWriter();
- final PrintWriter helpPrintWriter = new PrintWriter(helpStringWriter);
+ final var helpStringWriter = new StringWriter();
+ final var helpPrintWriter = new PrintWriter(helpStringWriter);
formatter.printHelp(helpPrintWriter, 120, APP_NAME, APP_DESCRIPTION, cli.getOptions(), 2, 4, "");
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
index 1b80af3f2..59c3c0e73 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -188,7 +189,7 @@ public final class Console {
return;
}
- final StringBuilder err = new StringBuilder();
+ final var err = new StringBuilder();
if (appName != null) {
err.append(this.getAppName()).append(": ");
}
@@ -217,7 +218,7 @@ public final class Console {
return;
}
- final StringBuilder warn = new StringBuilder();
+ final var warn = new StringBuilder();
if (appName != null) {
warn.append(this.getAppName()).append(": ");
}
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
index 2a20554b5..4b04b4037 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (c) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +30,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;
import java.nio.file.FileSystems;
-import java.nio.file.Path;
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,8 +76,7 @@ public class OutputFile {
* @return a File object for this output file
*/
public File toFile() {
- final Path fp = FileSystems.getDefault().getPath(fileName);
- return fp.toFile();
+ return FileSystems.getDefault().getPath(fileName).toFile();
}
/**
@@ -115,7 +114,7 @@ public class OutputFile {
* @return null on success, an error message on error
*/
public String validate() {
- final File file = toFile();
+ final var file = toFile();
if (file.exists()) {
if (!overwrite) {
return "file already exists";