Skip to content

Commit

Permalink
[#156] Document checkstyle use (#157)
Browse files Browse the repository at this point in the history
* Added checkstyle plugin for eclipse and add some documentation on how to use it.

* Attempted to fix invalid values in checkstyle configuration. Added more detailed instructions to setup checkstyle after project import.

* Added localised checkstyle-related files to gitignore.

* Removed eclipse plugin settings files.

* Added tip to click on the text again after selection.
  • Loading branch information
m133225 authored and damithc committed Oct 22, 2016
1 parent 29ab5fd commit d6ade39
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
build/
.gradle/
.checkstyle
.settings/
.idea/
lib/*
*.iml
Expand Down
26 changes: 26 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,35 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
<filteredResources>
<filter>
<id>1476898072165</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-false-false-build</arguments>
</matcher>
</filter>
<filter>
<id>1476898072188</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-projectRelativePath-matches-false-false-.gradle</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
11 changes: 0 additions & 11 deletions .settings/org.eclipse.buildship.core.prefs

This file was deleted.

12 changes: 1 addition & 11 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,8 @@

<module name="LineLength">
<!-- Checks if a line is too long. -->
<property name="max" value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.max}" default="120"/>
<property name="max" value="120"/>
<property name="severity" value="error"/>

<!--
The default ignore pattern exempts the following elements:
- import statements
- long URLs inside comments
-->

<property name="ignorePattern"
value="${com.puppycrawl.tools.checkstyle.checks.sizes.LineLength.ignorePattern}"
default="^(package .*;\s*)|(import .*;\s*)|( *\* *https?://.*)$"/>
</module>

<module name="LeftCurly">
Expand Down
14 changes: 13 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
3. **e(fx)clipse** plugin for Eclipse (Do the steps 2 onwards given in
[this page](http://www.eclipse.org/efxclipse/install.html#for-the-ambitious))
4. **Buildship Gradle Integration** plugin from the Eclipse Marketplace
5. **Checkstyle Plug-in** plugin from the Eclipse Marketplace


#### Importing the project into Eclipse
Expand All @@ -42,6 +43,17 @@
(This is because Gradle downloads library files from servers during the project set up process)
> * If Eclipse auto-changed any settings files during the import process, you can discard those changes.
#### Configuring Checkstyle
1. Click `Project` -> `Properties` -> `Checkstyle` -> `Local Check Configurations` -> `New...`
2. Choose `External Configuration File` under `Type`
3. Enter an arbitrary configuration name e.g. addressbook
4. Import checkstyle configuration file found at `config/checkstyle/checkstyle.xml`
5. Click OK once, go to the `Main` tab, use the newly imported check configuration.
6. Tick and select `files from packages`, click `Change...`, and select the `resources` package
7. Click OK twice. Rebuild project if prompted

> Note to click on the `files from packages` text after ticking in order to enable the `Change...` button
#### Troubleshooting project setup

**Problem: Eclipse reports compile errors after new commits are pulled from Git**
Expand Down Expand Up @@ -255,7 +267,7 @@ Here are the steps to create a new release.

1. Generate a JAR file [using Gradle](UsingGradle.md#creating-the-jar-file).
2. Tag the repo with the version number. e.g. `v0.1`
2. [Crete a new release using GitHub](https://help.github.com/articles/creating-releases/)
2. [Create a new release using GitHub](https://help.github.com/articles/creating-releases/)
and upload the JAR file your created.

### Managing Dependencies
Expand Down
11 changes: 11 additions & 0 deletions docs/UsingGradle.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ If we package only our own class files into the JAR file, it will not work prope
Therefore, we package all dependencies into a single JAR files, creating what is also known as a _fat_ JAR file.
To create a fat JAR fil, we use the Gradle plugin [shadow jar](https://github.com/johnrengelman/shadow).

## Running code style checks

* **`checkstyleMain`**<br>
Runs the code style check for the main code base

* **`checkstyleTest`**<br>
Runs the code style check for the test code base

The set of code style rules implemented can be found in `config/checkstyle/checkstyle.xml`.
To enable _exceptions_ to code styles, add in the comment `//CODESTYLE.OFF: RuleName` at the start of the section and `//CODESTYLE.ON: RuleName` at the end of the section.

## Running Tests

* **`allTests`**<br>
Expand Down

0 comments on commit d6ade39

Please sign in to comment.