teragrep / project-archetype

Teragrep project archetype
GNU Affero General Public License v3.0
0 stars 1 forks source link

Research if linter can handle string concatenation #10

Open StrongestNumber9 opened 5 months ago

StrongestNumber9 commented 5 months ago

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/or StringBuilder is preferred to string concatenation

Related issues

Additional context

StrongestNumber9 commented 1 week ago

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