Skip to content

Commit 527e538

Browse files
committed
Update READme.md
1 parent 8ab98d6 commit 527e538

File tree

1 file changed

+176
-3
lines changed

1 file changed

+176
-3
lines changed

README.md

Lines changed: 176 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,128 @@
11
# S_BookAPIJAVA
22

3+
# Code Quality & Static Analysis
4+
5+
This project follows HMCTS engineering standards for formatting, style, static analysis, and code coverage.
6+
The following tools are configured and integrated with Gradle:
7+
8+
- Checkstyle – HMCTS Java code conventions
9+
10+
- SpotBugs – static analysis for potential defects
11+
12+
- JaCoCo – code coverage reporting
13+
14+
- EditorConfig – consistent whitespace and formatting rules
15+
16+
17+
----------
18+
19+
## Checkstyle (HMCTS rules)
20+
21+
Checkstyle uses the HMCTS `checkstyle.xml`, enforcing naming, formatting, Javadoc, and structural rules.
22+
23+
### Run Checkstyle
24+
25+
`./gradlew checkstyleMain
26+
./gradlew checkstyleTest`
27+
28+
### Run all Checkstyle tasks
29+
30+
`./gradlew checkstyle`
31+
32+
### Checkstyle reports
33+
34+
Reports are generated at:
35+
36+
`build/reports/checkstyle/`
37+
38+
----------
39+
40+
## SpotBugs (static analysis)
41+
42+
SpotBugs analyses compiled bytecode and flags potential null pointer issues, performance problems, and common Java defects.
43+
44+
### List SpotBugs tasks
45+
46+
`./gradlew tasks --all | grep spotbugs`
47+
48+
### Run SpotBugs on main code
49+
50+
`./gradlew spotbugsMain`
51+
52+
### Run SpotBugs on test code
53+
54+
`./gradlew spotbugsTest`
55+
56+
### Run all SpotBugs tasks
57+
58+
`./gradlew spotbugs`
59+
60+
### SpotBugs reports
61+
62+
`build/reports/spotbugs/`
63+
64+
----------
65+
66+
## JaCoCo (test coverage)
67+
68+
JaCoCo generates unit test and integration test coverage reports in XML and HTML.
69+
70+
### Run tests and generate JaCoCo reports
71+
72+
`./gradlew test jacocoTestReport`
73+
74+
### Coverage report location
75+
76+
`build/reports/jacoco/test/jacocoTestReport.html`
77+
78+
----------
79+
80+
## EditorConfig (formatting and whitespace)
81+
82+
The project uses HMCTS `.editorconfig` rules, enforcing:
83+
84+
- 2-space indentation for most files
85+
86+
- 4-space indentation for `.java` files
87+
88+
- `LF` line endings
89+
90+
- UTF-8 charset
91+
92+
- No trailing whitespace
93+
94+
- A newline at the end of every file
95+
96+
97+
Most IDEs (including IntelliJ) apply these rules automatically.
98+
99+
----------
100+
101+
## Running all verification tasks
102+
103+
To verify everything before committing:
104+
105+
`./gradlew clean build`
106+
107+
This runs:
108+
109+
- Checkstyle
110+
111+
- SpotBugs
112+
113+
- Tests
114+
115+
- JaCoCo
116+
117+
- Compilation
118+
119+
- Packaging
120+
121+
----------
122+
3123
### Gradle Daemon: Stop the Daemon and Force a Clean Run
4124

5-
**Step 1: Forcefully stop all running Gradle daemons.**
125+
**Step 1: Forcefully stop all running Gradle daemons.**
6126
Forcefully stop all running Gradle daemons.
7127
This command tells Gradle to find any background processes it has running and terminate them.
8128
```Bash
@@ -12,5 +132,58 @@ This command tells Gradle to find any background processes it has running and te
12132
**Step 2: Run a clean build.**
13133
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.
14134
```Bash
15-
./gradlew clean checkstyleMain
16-
```
135+
./gradlew clean <checkstyleMain>
136+
```
137+
138+
----------
139+
140+
## IntelliJ Setup
141+
142+
### Enable Checkstyle in IntelliJ
143+
144+
1. Install the **Checkstyle-IDEA** plugin
145+
146+
2. Open IntelliJ settings:
147+
148+
`Settings → Tools → Checkstyle`
149+
150+
3. Add the configuration file:
151+
152+
`config/checkstyle/checkstyle.xml`
153+
154+
4. Set it as the default configuration
155+
156+
5. (Optional) Enable “Scan before check-in”
157+
158+
159+
----------
160+
161+
### Enable EditorConfig support
162+
163+
Verify the following setting is enabled:
164+
165+
`Settings → Editor → Code Style → Enable EditorConfig support`
166+
167+
----------
168+
169+
### Reformat code according to project rules
170+
171+
Use IntelliJ’s reformat command:
172+
173+
`Windows/Linux: Ctrl + Alt + L macOS: Cmd + Option + L`
174+
175+
----------
176+
177+
## Summary
178+
179+
This project aligns with HMCTS engineering standards:
180+
181+
- HMCTS Checkstyle enforcement
182+
183+
- SpotBugs static analysis
184+
185+
- JaCoCo coverage reports
186+
187+
- HMCTS EditorConfig formatting
188+
189+
- Spotless removed (not used by HMCTS)

0 commit comments

Comments
 (0)