konveyor / rulesets

Collections of static code analysis rules
Apache License 2.0
1 stars 25 forks source link

Ensure System property is properly parsed when in Lambda expressions #102

Open brunoborges opened 4 months ago

brunoborges commented 4 months ago

Please ensure all the scenarios below are covered in tests, especially the lambda expression (Example 5).

// Example 1
    private static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
        System.setProperty("org.jboss.logging.provider", "slf4j");
        return builder.sources(SpringInitializer.class);
    }

// Example 2
        List<String> profiles = new ArrayList<>();
        if (Boolean.parseBoolean(System.getProperty("profile.eventScheduler", Boolean.toString(true)))) {
            profiles.add("EventScheduler");
        }
        if (Boolean.parseBoolean(System.getProperty("profile.taskScheduler", Boolean.toString(true)))) {
            profiles.add("TaskScheduler");
        }

// Example 3
    private String getSuffix() {
        String suffix = "";
        String instance = System.getenv("INSTANCE_ID");
        if (StringUtils.isNotEmpty(instance)) {
            String[] split = StringUtils.split(instance, "-");
            if (split.length > 0) {
                suffix = "-" + split[0];
            }
        }
        return suffix;
    }

// Example 4
    static {
        String port;
        if ((port = System.getProperty("test.port")) != null) {
            TEST_PORT = Integer.parseInt(port);
        }
    }

// Example 5
            HttpClient httpClient = HttpClient.create()
                    .proxy(proxy -> proxy
                            .type(ProxyProvider.Proxy.HTTP)
                            .host(System.getProperty("https.proxyHost"))
                            .port(Integer.valueOf(System.getProperty("https.proxyPort")))
                            .nonProxyHosts(createNonProxyPattern(System.getProperty("http.nonProxyHosts")))
                    );
konveyor-ci-bot[bot] commented 4 months ago

This issue is currently awaiting triage. If contributors determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance. The triage/accepted label can be added by org members.