Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Suppress CheckStyle Warning

 
sdeepa redd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using an IDE?
 
sdeepa redd
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using eclipse. Sorry abt the "userName". It is "UserName" with capital U.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic