Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 120

[*.java]
indent_size = 4
ij_continuation_indent_size = 4
ij_java_align_multiline_parameters = true
ij_java_align_multiline_parameters_in_calls = true
ij_java_call_parameters_new_line_after_left_paren = true
ij_java_call_parameters_right_paren_on_new_line = true
ij_java_call_parameters_wrap = on_every_item
25 changes: 25 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build & Quality Checks

on:
pull_request:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'

- name: Make gradlew executable
run: chmod +x ./gradlew

- name: Run Gradle checks
run: ./gradlew clean check
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
HELP.md
.gradle
build/
**/build/
*.class
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
bin/main/application.yaml
**/target


### STS ###
Expand All @@ -26,6 +30,12 @@ bin/
out/
!**/src/main/**/out/
!**/src/test/**/out/
.mirrord
.DS_Store

# node_modules
package-lock.json
node_modules/

### NetBeans ###
/nbproject/private/
Expand Down Expand Up @@ -53,4 +63,5 @@ out/
*.pem

# Environment variables
.env
.env

190 changes: 189 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,189 @@
# S_BookAPIJAVA
# S_BookAPIJAVA

# Code Quality & Static Analysis

This project follows HMCTS engineering standards for formatting, style, static analysis, and code coverage.
The following tools are configured and integrated with Gradle:

- Checkstyle – HMCTS Java code conventions

- SpotBugs – static analysis for potential defects

- JaCoCo – code coverage reporting

- EditorConfig – consistent whitespace and formatting rules


----------

## Checkstyle (HMCTS rules)

Checkstyle uses the HMCTS `checkstyle.xml`, enforcing naming, formatting, Javadoc, and structural rules.

### Run Checkstyle

`./gradlew checkstyleMain
./gradlew checkstyleTest`

### Run all Checkstyle tasks

`./gradlew checkstyle`

### Checkstyle reports

Reports are generated at:

`build/reports/checkstyle/`

----------

## SpotBugs (static analysis)

SpotBugs analyses compiled bytecode and flags potential null pointer issues, performance problems, and common Java defects.

### List SpotBugs tasks

`./gradlew tasks --all | grep spotbugs`

### Run SpotBugs on main code

`./gradlew spotbugsMain`

### Run SpotBugs on test code

`./gradlew spotbugsTest`

### Run all SpotBugs tasks

`./gradlew spotbugs`

### SpotBugs reports

`build/reports/spotbugs/`

----------

## JaCoCo (test coverage)

JaCoCo generates unit test and integration test coverage reports in XML and HTML.

### Run tests and generate JaCoCo reports

`./gradlew test jacocoTestReport`

### Coverage report location

`build/reports/jacoco/test/jacocoTestReport.html`

----------

## EditorConfig (formatting and whitespace)

The project uses HMCTS `.editorconfig` rules, enforcing:

- 2-space indentation for most files

- 4-space indentation for `.java` files

- `LF` line endings

- UTF-8 charset

- No trailing whitespace

- A newline at the end of every file


Most IDEs (including IntelliJ) apply these rules automatically.

----------

## Running all verification tasks

To verify everything before committing:

`./gradlew clean build`

This runs:

- Checkstyle

- SpotBugs

- Tests

- JaCoCo

- Compilation

- Packaging

----------

### Gradle Daemon: Stop the Daemon and Force a Clean Run

**Step 1: Forcefully stop all running Gradle daemons.**
Forcefully stop all running Gradle daemons.
This command tells Gradle to find any background processes it has running and terminate them.
```Bash
./gradlew --stop
```

**Step 2: Run a clean build.**
The clean task deletes the entire build directory. This removes any old, compiled artifacts and cached results, ensuring nothing stale is left over. We will combine it with the checkstyleMain task.
```Bash
./gradlew clean <checkstyleMain>
```

----------

## IntelliJ Setup

### Enable Checkstyle in IntelliJ

1. Install the **Checkstyle-IDEA** plugin

2. Open IntelliJ settings:

`Settings → Tools → Checkstyle`

3. Add the configuration file:

`config/checkstyle/checkstyle.xml`

4. Set it as the default configuration

5. (Optional) Enable “Scan before check-in”


----------

### Enable EditorConfig support

Verify the following setting is enabled:

`Settings → Editor → Code Style → Enable EditorConfig support`

----------

### Reformat code according to project rules

Use IntelliJ’s reformat command:

`Windows/Linux: Ctrl + Alt + L macOS: Cmd + Option + L`

----------

## Summary

This project aligns with HMCTS engineering standards:

- HMCTS Checkstyle enforcement

- SpotBugs static analysis

- JaCoCo coverage reports

- HMCTS EditorConfig formatting

- Spotless removed (not used by HMCTS)
Loading
Loading