[an error occurred while processing this directive]
Frequently Checked Styles(FCS)
This page contains a list of some frequent checkstyle errors for CS149 and what in the Style Guide lab they refer to and how to correct them. Press the Green PLUS button (+) to see how to fix the error.
FCS# / ERROR
STYLE GUIDE ITEM
HOW TO FIX
1) [ERROR] file.java:0: File
does not end with a newline.
[NewlineAtEndOfFile]
F. Whitespace
The very last line of the file cannot have any spaces;
delete everything after the last brace
(the one that ends the class), and then press the Enter
key once to add the final newline.
If you are using a Windows machine to do this make sure you save with UNIX
newline characters. In JGrasp you can do this by Save As and check the
radio button for Binary/UNIX.
2) [ERROR] file.java:2:
Missing a Javadoc comment.
[JavadocType]
A1 Comments
Every class must contain a
Javadoc comment with the
following three elements.
Every method must contain
a Javadoc comment
Make sure you have a Javadoc comment above
the class name or the method name and that there is a newline
betweeen the javadoc end */ and the class or method header.
ie.
/**
* Some Javadoc.
* @author Me
* @version 1-17-17
*/
public class MyClass {
/**
* Main method.
* @param args - command line arguments or arguments
* not used goes here
* @return or nothing if void
*/
public static void main(String[] args) {
}
}
3) [ERROR] file.java:6:
'method def' child have incorrect
indentation level 0, expected level
should be 8. [Indentation]
E1. Indentation
Subsections of code
should be indented
consistently with four spaces.
Make sure you indent with spaces not tabs and make
sure they are at column 4 or a multiple of 4 for each
level of indentation.
public class Demo { //level 0 no indentation
public static void main(String[] args) {
//this is at level 4 and is 4 spaces in
//this is at level 8
4) [ERROR] file.java:15:22:
Name 'bonus' must match pattern
'^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.
[LocalFinalVariableName]
B5. Names
5. Constant names should be all
caps with an underscore separator. PI or INTEREST_RATE)
Make sure constants are named like this:
final int MY_CONSTANT_NUMBER = 5;
using all CAPS with underscore between words.
5) [ERROR] file.java:41:
'Line is longer than 80
characters (found 127).
[LineLength]
E3. Indentation
3. Statements too long for one
line should be indented on
subsequent lines.
Make sure if you have lines longer than 80 characters and move
to the next line that you indent to the next level the start of that
next line. See example below:
40 System.out.printf("If I had $1M for every"
+" degree, I'd have $%,.2f!\n", fTemp * 1e6);