This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 252381 - Insert code: Logger is inconsistent with templates
Summary: Insert code: Logger is inconsistent with templates
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on: 252708
Blocks:
  Show dependency tree
 
Reported: 2015-05-13 14:33 UTC by cezariusz
Modified: 2015-06-01 10:30 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2015-05-13 14:33:26 UTC
Product Version: NetBeans IDE Dev (Build 201505130001)
Java: 1.8.0_45; Java HotSpot(TM) 64-Bit Server VM 25.45-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_45-b14
System: Windows 7 version 6.1 running on amd64; UTF-8; pl_PL (nb)

When creating a logger from a template (for example "logr") we get:

private static final Logger logger = Logger.getLogger(MyClass.class.getName());

But when creating it using Insert Code -> Logger, we get:

private static final Logger LOG = Logger.getLogger(Initialized.class.getName());

The latter is incorrect, because logger is not a constant, so it shouldn't have uppercase name:
https://google-styleguide.googlecode.com/svn/trunk/javaguide.html#s5.2.4-constant-names

And that leads to inconsistency when some of team members use templates, and others use code generation.
Comment 1 Svata Dedic 2015-05-25 14:51:18 UTC
Hm, I will probably introduce also a hint to check constant names with configurable 'immutable' classes. You're right that (not only) Google standards promote using uppercase just for immutables. 
I think some deviations should be supported, subject to project local conventions, which should be configurable per IDE/project - e.g. Logger is not really immutable, but in more than one project we've established a convention to write loggers in uppecase - mainly to emphasize its usage throughout the source code.
Comment 2 cezariusz 2015-05-31 09:41:04 UTC
The name of the logger variable should be defined in IDE options or project options. See bug 252708.
Comment 3 Svata Dedic 2015-06-01 10:30:08 UTC
Sorry, I've confused this issue (which should go to Java/Editor area) with other ones filed against Java hints regarding logging.Never mind, the 'check constant name' hint is already implemented.