Skip to content

Commit 89b12ab

Browse files
author
Matt Hughes
committed
added more detailed checkstyle running instructions (unfinished)
fixed broken link on style guide added more blurb to style guide
1 parent e833e80 commit 89b12ab

File tree

2 files changed

+66
-6
lines changed

2 files changed

+66
-6
lines changed

checkstyle.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
layout: default
3+
title: CS 1331 - Running Checkstyle
4+
---
5+
6+
# How To Run Checkstyle on Java Source Files
7+
8+
One runs checkstyle on Java source code using the `java` command:
9+
10+
```bash
11+
java -jar checkstyle-6.2.1.jar MyJavaFile.java
12+
```
13+
This command is not altogether different from the command that we use to run
14+
compiled Java classes we have written. The command creates an instance of the
15+
Java Virtual Machine, and runs a `main(String[])` method defined in some class.
16+
But rather than invoking the `main(String[])` method of a class we have
17+
written, it instead runs that of a class packaged inside of the provided Java
18+
archive (or `.jar`) file.
19+
20+
It is important to note that checkstyle will only give reliable output on
21+
*compiling* Java source code. Source code which contains syntax errors may not
22+
yield meaningful output when run through checkstyle.
23+
24+
One can pass more than one Java source file to Checkstyle. It is recommended
25+
that you always use the command
26+
27+
```bash
28+
java -jar checkstyle-6.2.1.jar *.java
29+
```
30+
to invoke checkstyle on each file in the current working directory with a name
31+
ending in `.java`. This helps to ensure that you do not accidentally submit
32+
`.java` files containing style violations.
33+
34+
## Point Deductions
35+
36+
For assignments submitted in this class, style counts in a very real sense.
37+
Grades on assignments will be reduced by up to one point per error reported. It
38+
is very important to correct style errors as you encounter them. As such, it is
39+
recommended that you run checkstyle on your code several times as you are
40+
writing it.
41+
42+
## Advanced Options
43+
44+
Checkstyle can also be used to check formatting of Javadoc comments written
45+
alongside your source code.

cs1331-style-guide.html

+21-6
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,33 @@
55

66
<h1>CS 1331 Java Style Guide</h1>
77

8-
<p>This document summarizes and in some cases clarifies Sun/Oracle's
9-
<a href="http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html">Java Code Conventions</a>
10-
(and in some places copies it directly) and the Checkstyle checks specified in
11-
<a href="resources/cs1331-checkstyle.xml">cs1331-checkstyle.xml</a>.
12-
The Checkstyle web site also documents each of its standard checks here: <a href="http://checkstyle.sourceforge.net/availablechecks.html">http://checkstyle.sourceforge.net/availablechecks.html</a></p>
8+
<p>Style is very important when writing code. Often code is not judged simply
9+
base on how effectively it performs a specific function, but also how easily it
10+
can be understood by a human reader. While rules of style vary, it is important
11+
to be able to learn to write code which conforms to a given standard.</p>
12+
13+
<p>In this class, the style rules that you are asked to follow are crystallized
14+
into an automated tool, called
15+
<a href="http://checkstyle.sourceforge.net">Checkstyle</a>. This tool is
16+
configurable to check for a large number of different stylistic errors.
17+
Additional details about how to run checkstyle on your code can be found <a href="checkstyle.html">here.</a></p>
18+
1319
<p>The file you need to run Checkstyle:</p>
1420
<ul class="simple">
1521
<li><a href="resources/checkstyle-6.2.1.jar">checkstyle-6.2.1.jar</a></li>
1622
<!--<li>New Version: <a href="resources/checkstyle1331v2.jar">checkstyle1331v2.jar</a></li>-->
1723
</ul>
18-
Run checkstyle on your Java files like so:
24+
<p>In the simplest case, run checkstyle on your Java files like so:
1925
<pre>java -jar checkstyle-6.2.1.jar MyJavaFile.java</pre>
26+
For more advanced options (which will be necessary in later portions of the
27+
semester), check out the <a href="checkstyle.html">options available</a> for
28+
running checkstyle.</p>
29+
30+
<p>The rest of this document summarizes and in some cases clarifies Sun/Oracle's
31+
<a href="http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html">Java Code Conventions</a>
32+
(and in some places copies it directly) and the Checkstyle checks specified in
33+
<a href="resources/cs1331-checkstyle.xml">cs1331-checkstyle.xml</a>.
34+
The Checkstyle web site also documents each of its standard checks here: <a href="http://checkstyle.sourceforge.net/checks.html">http://checkstyle.sourceforge.net/checks.html</a></p>
2035
<div class="section" id="names">
2136
<h1>Names</h1>
2237
<ul>

0 commit comments

Comments
 (0)