diff --git a/cmd/analyze.go b/cmd/analyze.go index ecfd6bc..d5ab293 100644 --- a/cmd/analyze.go +++ b/cmd/analyze.go @@ -20,6 +20,7 @@ import ( "github.com/konveyor/analyzer-lsp/engine" outputv1 "github.com/konveyor/analyzer-lsp/output/v1/konveyor" "github.com/konveyor/analyzer-lsp/provider" + "go.lsp.dev/uri" "gopkg.in/yaml.v2" "github.com/spf13/cobra" @@ -678,6 +679,9 @@ func (a *analyzeCommand) GenerateStaticReport(ctx context.Context) error { if err != nil { return err } + uri := uri.File(filepath.Join(a.output, "static-report", "index.html")) + cleanedURI := filepath.Clean(string(uri)) + a.log.Info("Static report created. Access it at this URL:", "URL", cleanedURI) return nil } diff --git a/cmd/shimconvert.go b/cmd/shimconvert.go index e752987..9f7f5bb 100644 --- a/cmd/shimconvert.go +++ b/cmd/shimconvert.go @@ -77,6 +77,11 @@ func (w *windupShimCommand) Validate() error { if w.input == nil || len(w.input) == 0 { return fmt.Errorf("input for rule file or directory must not be empty") } + for _, r := range w.input { + if filepath.Clean(r) == filepath.Clean(w.output) { + return fmt.Errorf("input rule directory and output directory must be different") + } + } // try to get abs path, if not, continue with relative path if absPath, err := filepath.Abs(w.output); err == nil { w.output = absPath diff --git a/test-data/analysis-output.yaml b/test-data/analysis-output.yaml index bd23f9f..34d2be7 100644 --- a/test-data/analysis-output.yaml +++ b/test-data/analysis-output.yaml @@ -1450,7 +1450,7 @@ - uri: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java message: Java native libraries might not run in a cloud or container environment.. Recommendations. * Review the purpose of the native library in your application.. * Check whether the native library is compatible with a cloud environment.. * Reuse or embed the native library or application in a cloud environment, for example, in a JBoss module.. * Replace, remove, or rewrite the native library or application using a cloud-compatible equivalent. codeSnip: " 1 package io.konveyor.demo.config;\n 2 \n 3 import java.io.FileInputStream;\n 4 import java.io.InputStream;\n 5 import java.util.Properties;\n 6 \n 7 public class ApplicationConfiguration {\n 8 \n 9 \tprivate Properties config;\n 10 \n 11 \tpublic ApplicationConfiguration() {\n 12 \t\tsuper();\n 13 \t\tthis.config = loadProperties();\n 14 \n 15 \t}\n 16 \n 17 \tprivate Properties loadProperties() {\n 18 \t\tProperties properties = new Properties();\n 19 \n 20 \t\ttry (InputStream inputStream = new FileInputStream(\"/opt/config/persistence.properties\")) {\n 21 \n 22 \t\t\tproperties.load(inputStream);\n 23 \n 24 \t\t} catch (Exception e) {\n 25 \t\t\tSystem.out.println(\"Exception: \" + e);\n 26 \t\t}\n 27 \n 28 \t\treturn properties;\n 29 \t}\n 30 \n 31 \tpublic String getProperty (String name) {\n 32 \t\treturn config.getProperty(name);\n 33 \t}\n 34 \n 35 \n 36 \n 37 }\n" - lineNumber: 12 + lineNumber: 13 variables: file: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java kind: Constructor @@ -1458,7 +1458,7 @@ - uri: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java message: Java native libraries might not run in a cloud or container environment.. Recommendations. * Review the purpose of the native library in your application.. * Check whether the native library is compatible with a cloud environment.. * Reuse or embed the native library or application in a cloud environment, for example, in a JBoss module.. * Replace, remove, or rewrite the native library or application using a cloud-compatible equivalent. codeSnip: " 1 package io.konveyor.demo.config;\n 2 \n 3 import java.io.FileInputStream;\n 4 import java.io.InputStream;\n 5 import java.util.Properties;\n 6 \n 7 public class ApplicationConfiguration {\n 8 \n 9 \tprivate Properties config;\n 10 \n 11 \tpublic ApplicationConfiguration() {\n 12 \t\tsuper();\n 13 \t\tthis.config = loadProperties();\n 14 \n 15 \t}\n 16 \n 17 \tprivate Properties loadProperties() {\n 18 \t\tProperties properties = new Properties();\n 19 \n 20 \t\ttry (InputStream inputStream = new FileInputStream(\"/opt/config/persistence.properties\")) {\n 21 \n 22 \t\t\tproperties.load(inputStream);\n 23 \n 24 \t\t} catch (Exception e) {\n 25 \t\t\tSystem.out.println(\"Exception: \" + e);\n 26 \t\t}\n 27 \n 28 \t\treturn properties;\n 29 \t}\n 30 \n 31 \tpublic String getProperty (String name) {\n 32 \t\treturn config.getProperty(name);\n 33 \t}\n 34 \n 35 \n 36 \n 37 }\n" - lineNumber: 21 + lineNumber: 22 variables: file: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java kind: Method @@ -1482,7 +1482,7 @@ - uri: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java message: 'An application running inside a container could lose access to a file in local storage.. Recommendations. The following recommendations depend on the function of the file in local storage:. * Logging: Log to standard output and use a centralized log collector to analyze the logs.. * Caching: Use a cache backing service.. * Configuration: Store configuration settings in environment variables so that they can be updated without code changes.. * Data storage: Use a database backing service for relational data or use a persistent data storage system.. * Temporary data storage: Use the file system of a running container as a brief, single-transaction cache.' codeSnip: " 1 package io.konveyor.demo.config;\n 2 \n 3 import java.io.FileInputStream;\n 4 import java.io.InputStream;\n 5 import java.util.Properties;\n 6 \n 7 public class ApplicationConfiguration {\n 8 \n 9 \tprivate Properties config;\n 10 \n 11 \tpublic ApplicationConfiguration() {\n 12 \t\tsuper();\n 13 \t\tthis.config = loadProperties();\n 14 \n 15 \t}\n 16 \n 17 \tprivate Properties loadProperties() {\n 18 \t\tProperties properties = new Properties();\n 19 \n 20 \t\ttry (InputStream inputStream = new FileInputStream(\"/opt/config/persistence.properties\")) {\n 21 \n 22 \t\t\tproperties.load(inputStream);\n 23 \n 24 \t\t} catch (Exception e) {\n 25 \t\t\tSystem.out.println(\"Exception: \" + e);\n 26 \t\t}\n 27 \n 28 \t\treturn properties;\n 29 \t}\n 30 \n 31 \tpublic String getProperty (String name) {\n 32 \t\treturn config.getProperty(name);\n 33 \t}\n 34 \n 35 \n 36 \n 37 }\n" - lineNumber: 19 + lineNumber: 20 variables: file: file:///root/.m2/repository/io/konveyor/demo/config-utils/1.0.0/io/konveyor/demo/config/ApplicationConfiguration.java kind: Constructor