No go:
LOGGER.info("Got code <" + code + ">, status <" + status + ">");throw new Exception("Got code <"+code+">, status <"+status+">");
Better:
LOGGER.info("Got code <{}>, status <{}>", code, status);throw new Exception(String.format("Got code <%>, status <%>", code, status));
Use case or motivation behind the feature request
Research if all string concatenations can be caught, especially for logger statements. Using String.format and/or StringBuilder is preferred to string concatenation
Checkstyle plugin in #20 can handle regexp searches for string concatenation, assuming that we can write good enough regex for it to be generally useful
Description
No go:
LOGGER.info("Got code <" + code + ">, status <" + status + ">");
throw new Exception("Got code <"+code+">, status <"+status+">");
Better:
LOGGER.info("Got code <{}>, status <{}>", code, status);
throw new Exception(String.format("Got code <%>, status <%>", code, status));
Use case or motivation behind the feature request
Research if all string concatenations can be caught, especially for logger statements. Using
String.format
and/orStringBuilder
is preferred to string concatenationRelated issues
Additional context