From 9d8894092ced589c0bdc5b9e85ee1bf1c85d3e36 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 27 Aug 2021 14:49:41 -0400 Subject: 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 --- .../src/main/java/org/onap/policy/apex/tools/common/Console.java | 5 +++-- .../main/java/org/onap/policy/apex/tools/common/OutputFile.java | 7 +++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'tools/tools-common/src') 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"; -- cgit 1.2.3-korg