Bug 552733 - [quick assist] Add "Use SLF4J for string concatentation"
Summary: [quick assist] Add "Use SLF4J for string concatentation"
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.12   Edit
Hardware: PC Mac OS X
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-06 06:51 EST by Juergen Baier CLA
Modified: 2021-03-08 02:03 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.