A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/2427 below:

[java] ConsecutiveLiteralAppend false-positive with builder inside lambda · Issue #2427 · pmd/pmd · GitHub

Affects PMD Version:
6.22.0
Description:
ConsecutiveLiteralAppends
https://pmd.github.io/latest/pmd_rules_java_performance.html#consecutiveliteralappends

        consumerMap.put(Collection.class, o ->
        {
            builder.append('[');
            Collection<?> collection = (Collection<?>) o;
            if (isNotEmpty(collection))
            {
                collection.forEach(t -> buildValue(builder, t));
                builder.delete(builder.lastIndexOf(", "), builder.length());
            }
            builder.append(']'); // here reported
        });

        consumerMap.put(Map.class, o ->
        {
            builder.append('{');
            Map<?, ?> map = (Map<?, ?>) o;
            if (isNotEmpty(map))
            {
                map.forEach((key, value) ->
                {
                    builder.append(key).append('=');
                    buildValue(builder, value);
                });
                builder.delete(builder.lastIndexOf(", "), builder.length());
            }
            builder.append('}'); // but here is ok
        });

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4