Find places where I good use varargs instead of array creation

24 views
Skip to first unread message

Lars Vogel

unread,
May 17, 2018, 4:33:44 AM5/17/18
to SonarLint
Friends of Sonar,

I'm currently trying to identify places in which we could remove the
array creation because we adjusted the method declaration to use
varargs.

Wrong
----------------
NLS.bind(WorkbenchNavigatorMessages.ProjectExplorer_toolTip,
new String[] { workingSetLabel });
-----------------

Correct:
-----------------
NLS.bind(WorkbenchNavigatorMessages.ProjectExplorer_toolTip, workingSetLabel);
-----------------

Does Sonar support this?

I currently do not see related messages, e.g.,
https://sonar.eclipse.org/dashboard/index/53383

Best regards, Lars

--
Eclipse Platform project co-lead
CEO vogella GmbH

Haindaalwisch 17a, 22395 Hamburg
Amtsgericht Hamburg: HRB 127058
Geschäftsführer: Lars Vogel, Jennifer Nerlich de Vogel
USt-IdNr.: DE284122352
Fax (040) 5247 6322, Email: lars....@vogella.com, Web: http://www.vogella.com

janos....@sonarsource.com

unread,
May 17, 2018, 5:20:46 AM5/17/18
to SonarLint
Hi Lars,

We do have a rule for that:

This is part of the default quality profile of the Java analyzer, since version 4.15. Maybe time to update your Java analyzer? (Or even your SonarQube ;-) Just kidding, not necessary for this, but the linked SonarQube is an ancient dinosaur.)

Cheers,
Janos
Reply all
Reply to author
Forward
0 new messages