File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Suppress CheckStyle Warning Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Suppress CheckStyle Warning" Watch "Suppress CheckStyle Warning" New topic
Author

Suppress CheckStyle Warning

sdeepa redd
Greenhorn

Joined: Jun 16, 2009
Posts: 5
Hi,

I have a checkstyle warning

Member Names: Name 'userName' must match pattern '^[a-z][a-zA-Z0-9]*$'.

I want to supress this warning.

What argument should I pass to @SuppressWarnings annotation?

Thanks
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19790
    
  20

Please read your private messages regarding an important announcement.

Thank you,

Rob


That said, something tells me you're not posting everything; userName already matches that regular expression. Where did you get this warning from?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Are you using an IDE?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
sdeepa redd
Greenhorn

Joined: Jun 16, 2009
Posts: 5
I am using eclipse. Sorry abt the "userName". It is "UserName" with capital U.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31079
    
163

sdeepa redd wrote:I am using eclipse. Sorry abt the "userName". It is "UserName" with capital U.

Why not change the code? It's convention to use a lowercase letter to begin a variable name.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm with Jeanne on this one--unless you have a compelling reason for not following one of the most common code conventions it's probably best to follow it.

That said, you can change the regex used for Checkstyle's naming rules in its config file. For instance, some places I've worked use leading and trailing underscores for members and parameters respectively, and we've configured Checkstyle appropriately.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Suppress CheckStyle Warning