Reputation: 3207
Is there an option for Eclipse to issue a warning when code formatting does not match the current settings?
Also, how to can I find the best standards for formatting Java code?
Upvotes: 1
Views: 1923
Reputation: 2786
You can also setup eclipse to automatically format your code when saving files:
Window > Preferences > Java > Editor > Save Actions
Check Perform the selected actions on save, then check Format source code and choose to format all lines, or edited lines
Upvotes: 1
Reputation: 5070
Something like Checkstyle should suit your needs - you can configure the rules if required.
Upvotes: 1
Reputation: 234857
You might take a look at the HTML Tidy Plug-in. Normally, Eclipse only displays compiler warnings and errors, and the compiler couldn't care less about style. However, you can set certain style warnings under Windows -> Preferences -> Java -> Compiler -> Errors/Warnings.
As far as guidelines go, there's this fairly comprehensive one published many years ago by Sun.
Upvotes: 0
Reputation: 481
http://geosoft.no/development/javastyle.html#Layout%20of%20the%20Recommendations
Upvotes: 0
Reputation: 845
I'm not sure that it'll show a warning. However, Eclipse can automatically format your code for you. You can select all using Ctrl+A, then hit Ctrl+Shift+F to auto-format your code.
Also, to see the Java conventions, you can go to Window, Preferences, Java, Code Style, Formatter. Then, under Active Profile, select "Java Conventions," which I think is the same as "Eclipse (built-in)". You can see a short example of what properly-formatted code should look like.
You can also see the document in its full gory detail at: http://www.oracle.com/technetwork/java/codeconv-138413.html
Upvotes: 1
Reputation: 32014
View: “Window” -> “Show View” -> “Problems”
Configuration: “Preferences” -> “Java” -> “Compiler” -> “Errors/Warnings”
Upvotes: 0