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.

1) [ERROR] File
does not end with a newline.

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.

End line screenshot

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]
Missing a Javadoc comment.

A1 Comments
  1. Every class must contain a
    Javadoc comment with the
    following three elements.
  2. 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.


 * 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]
'method def' child have incorrect
indentation level 0, expected level
should be 8. [Indentation]


E1. Indentation
  1. 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]
Name 'bonus' must match pattern

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]
'Line is longer than 80
characters (found 127).

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);  

Back to Top