solven-eu / cleanthat

Github App opening automatically cleaning PR
56 stars 16 forks source link

Bug with StreamWrappedIfToFilter #841

Open blacelle opened 3 weeks ago

blacelle commented 3 weeks ago
    private static Map<String, String> loadCountryToCcy() {
        Map<String, String> countryToCcy = new TreeMap<>();

        Stream.of(Locale.getISOCountries()).forEach(countryCode -> {
            // BEWARE we may prefer ISO3. Through, we're consistent here with LocaleHelpers
            if (!Strings.isNullOrEmpty(countryCode)) {
                Currency ccy = Currency.getInstance(Locale.of("fr", countryCode));

                if (ccy != null) {
                    String currencyCode = ccy.getCurrencyCode();
                    countryToCcy.put(countryCode, currencyCode);
                }
            }
        });

        return ImmutableMap.copyOf(countryToCcy);
    }

leads to improper code like .filter(countryCode -> !Strings.isNullOrEmpty(countryCode)).filter(countryCode -> !Strings.isNullOrEmpty(countryCode)).