aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Checkstyle code formatting import and pattern errors. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Checkstyle code formatting import and pattern errors." Watch "Checkstyle code formatting import and pattern errors." New topic
Author

Checkstyle code formatting import and pattern errors.

Ger Loughnane
Greenhorn

Joined: Jan 18, 2010
Posts: 2
Hi All,

I'm just about to submit my assignment to Sun. (I haven't had to ask any questions up to now due to the quality of responses already posted to the forum ) and I'm getting a lot of errors when I run checkstyle. I've been able to resolve the vast majority of these. However, I am getting the following 2 errors and I would be very grateful if somebody could let me know if they can be ignored or not.

1. "Using the '.*' form of import should be avoided - java.awt.*." I know that I'm getting this message because I'm importing a package using the *. However, the reason I'm doing this is that in some of my source code files, I'm using more than 3 classes from the relevant package. Does it sound reasonable to just explain this in my choices.txt?

2. "Name 'magicCookieLocation' must match pattern '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'." . The code been complained about here is the following:
Even if I change the name magicCookieLocation to magiccookielocation, it still doesn't work

Any suggestions would be very much appreciated. While these are just minor issues, I need to get them resolved. This is because of the high percentage required to pass and because projects submitted are subject to some form of automatic validation before an examiner even looks at them.

Best Regards,
Ger Loughnane.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4914
    
  10

Hi Ger,

Welcome to the JavaRanch!

I'm just about to submit my assignment to Sun. (I haven't had to ask any questions up to now due to the quality of responses already posted to the forum)
Great job!

1/ I used Eclipse as IDE to develop my assignment and I always used the "Organize Imports" function. Result: every import is being listed in the source file, no shortcut notation like java.awt.* is used. I don't know if there are any "rules" about this issue, but I think you should use one or the other consistently throughout all your code files

2/ magicCookieLocation is a constant and constants should be declared in upper case, different parts seperated by an underscore. So if you rename to MAGIC_COOKIE_LOCATION the warning will disappear.

I didn't use any of these tools to check my code style. When you use a decent IDE (like Eclipse) and you are familiar with the most code conventions you are good to go. Afterwards I used some of these tools to check my code and my experiences can be read here.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Ger Loughnane
Greenhorn

Joined: Jan 18, 2010
Posts: 2
Hi Roel,

Thanks for the response. Its been very useful.

Best Regards,
Ger.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Checkstyle code formatting import and pattern errors.
 
Similar Threads
Email Address using java regular expression
Validation using Regular Expressions??
regexp on email address
Seemingly simple regex making my head hurt
Suppress CheckStyle Warning