Bug 552733

Summary: [quick assist] Add "Use SLF4J for string concatentation"
Product: [Eclipse Project] JDT Reporter: Juergen Baier <baier>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3    
Version: 4.12   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Juergen Baier CLA 2019-11-06 06:51:40 EST
I often have code like:

String b = "b";
log.info("a" + b + "c");

I can then use "Use MessageFormat for string concatenation" and I get

log.info(MessageFormat.format("a{0}c", b));

But for log statements I would also like to have a quick assist feature which works for slf4j so I get

log.info("a{}c", b);
Comment 1 Juergen Baier CLA 2021-03-08 02:03:38 EST
I just wanted to note that basically all static code analysis tools (e.g. Sonar) will issue a warning when I write

log.info("a" + b + "c");

And the quickfix for Eclipse only allows me to get

log.info(MessageFormat.format("a{0}c", b));

So I have to edit that manually to

log.info("a{}c", b);

which is very error prone because in MessageFormat I use {number} but in the logging methods only {} is used.

This might not seem like a big issue but I guess this is something which probably annoys every single Eclipse user who uses Sonar or similar tools.