History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-3524
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Unassigned
Reporter: Graham Lea
Votes: 7
Watchers: 6
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

'Hard Coded Strings' inspection needs to be able to ignore logger

Created: 15 Sep 05 07:26   Updated: 17 Jan 06 15:39
Component/s: Code Analysis. Inspection
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown
Issue Links:
Duplicate
 
This issue is duplicated by:
IDEA-4249 Inspection "Hard coded String literal... Resolved

Build: 3,461
Severity: Medium


 Description  « Hide
It would be great for the 'Hard Coded Strings' inspection to have an option to 'Ignore literals passed to methods on a logger.'

 All   Comments   Work Log   Change History      Sort Order:
Dmitry Jemerov - 15 Sep 05 13:32
You can annotate the methods of the logger with the @NonNls annotation.

(The annotation lets us avoid creating dozens of options for the inspection, for every possible case of string literals that someone somewhere wants to ignore for some reason.)


Sascha Weinreuter - 15 Sep 05 15:28
How should someone annotate a logging library, let's say log4j, with IDEA's annotation? Of course it's not impossible, but it creates an unjustifiable maintenance effort. And don't forget that currently Java 5 is quite far from being the widely used development platform. I'm happy that since just a few months I can rely on Java 1.4 and don't have to be 1.3 compatible any more in many projects.

I can't currently think of a more obvious example (at least amongst most of the currently available options) of non-nls strings than Logger.getLogger("something"). Even logging methods themselves are probably very rarely i18n'ed. Logging is such a fundamental aspect that I'd not say it is to be ignored "for some reason".

There is however the problem of the different available logging toolkits, which might make it hard to configure. Because of this, and the general problem that annotating library methods is potentially impossible, there should be a generic configuration to specify which methods (which parameter) of a class should be ignored, maybe pre-configured for the most popular logging toolkits.

Requiring to extract such literals passed to library methods into a variable/constant (IDEA-4818) and annotating it with NonNls, just because the tool (IDEA) can't deal with it otherwise, doesn't seem right to me.


Maxim Shafirov - 15 Sep 05 17:06
For what it worth we've created in-project log4j Logger wrapper with all proper annotations. As the matter of fact there are so many places one could take the advantage of using @NonNls it's very hard to resist Anyway we understant 1.4 compatibility issue so feel free to apply votes.

Sascha Weinreuter - 22 Sep 05 15:20
So, here's my vote for a generic solution

Dmitry Jemerov - 22 Sep 05 15:30
The generic solution we've been thinking of is something called "external annotations" - the possibility to put annotations for some source code you don't control (JDK itself is the prime example, log4j may be another) in an external file. (The specific details on the format of the file and the way it should be edited are completely undecided.)

As this external file will not be a pure Java source file, there is no reason not to use it in 1.4 projects.


Graham Lea - 22 Sep 05 16:07
I just want to chime in and ask that, in the search for a generic solution, the requirement to easily exclude logger methods from the hard coded strings inspetion doesn't get lost.
Emphasis on "easily". : )

Dmitry Jemerov - 22 Sep 05 17:30
We already have a very nice solution for the easiness problem - all the complexity of external annotations will be taken care of by the quickfix for the inspection.

Sascha Weinreuter - 17 Jan 06 15:39
Any news on whether those "external annotations" will appear in Demetra?