Skip to content

RemoveRedundantTypeCast removes too much #221

@koppor

Description

@koppor

We have a code base soon 20 years old - and not all code was modernized.

When from 6.4.0 to 6.5.4 and BOM to 2.5.0 - JabRef/jabref#10650, OpenRewrite changed too much:

        private static final List<Character> DISALLOWED_CHARACTERS = Arrays.asList('{', '}', '(', ')', ',', '=', '\\', '"', '#', '%', '~', '\'');

        String newKey = key.chars()
                           .filter(c -> unwantedCharacters.indexOf(c) == -1)
-                           .filter(c -> !DISALLOWED_CHARACTERS.contains((char) c))
+                           .filter(c -> !DISALLOWED_CHARACTERS.contains(c))
                           .collect(StringBuilder::new,
                                   StringBuilder::appendCodePoint, StringBuilder::append)
                           .toString();
         private final Deque<Object> stack;

-        stack.push((int) s.charAt(0));
+        stack.push(s.charAt(0));

Tests fail after this improvement. Not sure whether it's just a hint to modernize the code also at these places. I just wanted to report it to make it more googable. No need to resolve it.

My workaround is to disable the recipe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions