Skip to content

Commit 1e05029

Browse files
authored
Merge pull request #22 from DataDog/chore/award-static-analysis
chore: add static analysis to award service
2 parents dcf4d56 + df793e9 commit 1e05029

48 files changed

Lines changed: 1808 additions & 903 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docker-compose.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ services:
237237
KAFKA__BOOTSTRAPSERVERS: "redpanda:9092"
238238
KAFKA__SCHEMAREGISTRY: "http://redpanda:8082"
239239
KAFKA__GROUPID: "stickerlandia-user-management"
240+
healthcheck:
241+
test: ["CMD", "curl", "-f", "http://localhost:8080/api/users/v1/health"]
242+
interval: 10s
243+
timeout: 5s
244+
retries: 5
240245
labels:
241246
- "traefik.enable=true"
242247
- "traefik.http.routers.user-management.rule=PathPrefix(`/api/users`)"

sticker-award/README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,86 @@ The API returns standard HTTP status codes and follows the RFC 7807 Problem Deta
6060
Full API documentation is available in OpenAPI format:
6161
- Synchronous API: [api.yaml](./docs/api.yaml)
6262
- Asynchronous API: [async_api.json](./docs/async_api.json)
63+
64+
## Building and Running
65+
66+
### Prerequisites
67+
- Java 21+
68+
- Maven 3.8+
69+
70+
### Development
71+
72+
Run in development mode:
73+
```bash
74+
./mvnw compile quarkus:dev
75+
```
76+
77+
### Testing
78+
79+
Run tests:
80+
```bash
81+
./mvnw test
82+
```
83+
84+
Run integration tests:
85+
```bash
86+
./mvnw verify
87+
```
88+
89+
## Code Quality
90+
91+
This project enforces high code quality through multiple static analysis tools:
92+
93+
### Error Prone
94+
95+
This project uses Error Prone to catch common Java programming mistakes at compile time.
96+
97+
**Error Prone Integration:**
98+
- Runs automatically during compilation (`./mvnw compile`)
99+
- Catches bugs like incorrect Date usage, unused variables, and charset issues
100+
- Configured in the Maven compiler plugin
101+
- Uses Error Prone version 2.38.0
102+
103+
**Common Error Prone checks include:**
104+
- `JavaUtilDate` - Flags usage of legacy `java.util.Date` API
105+
- `UnusedVariable` - Detects unused fields and variables
106+
- `DefaultCharset` - Warns about implicit charset usage in string operations
107+
108+
### Checkstyle
109+
110+
This project uses Checkstyle to enforce coding standards based on the Google Java Style Guide.
111+
112+
**Run Checkstyle validation:**
113+
```bash
114+
# Check code style (runs automatically during build)
115+
./mvnw validate
116+
117+
# Run only Checkstyle check
118+
./mvnw checkstyle:check
119+
120+
# Generate Checkstyle report (creates HTML report at target/reports/checkstyle.html)
121+
./mvnw checkstyle:checkstyle
122+
```
123+
124+
### Spotless (Code Formatting)
125+
126+
This project uses Spotless with Google Java Format to automatically fix code style issues.
127+
128+
**Format your code:**
129+
```bash
130+
# Check if code formatting is correct
131+
./mvnw spotless:check
132+
133+
# Automatically fix code formatting issues
134+
./mvnw spotless:apply
135+
136+
# Format and then validate with Checkstyle
137+
./mvnw spotless:apply validate
138+
```
139+
140+
**Checkstyle Configuration:**
141+
- Configuration file: `checkstyle.xml`
142+
- Suppressions file: `checkstyle-suppressions.xml`
143+
- Based on Google Java Style Guide (modified for 4-space indentation)
144+
- Enforces 4-space indentation, 100-character line limit
145+
- Checks import ordering, Javadoc completeness, and naming conventions
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
5+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
6+
7+
<!--
8+
Checkstyle suppressions file for Sticker Award application.
9+
10+
This file allows you to suppress specific Checkstyle violations for certain files or patterns.
11+
Use this sparingly and only when necessary.
12+
13+
Examples:
14+
- Generated code that you don't control
15+
- Third-party code
16+
- Specific patterns that are acceptable in your codebase
17+
-->
18+
19+
<suppressions>
20+
<!-- Suppress all checks for generated files -->
21+
<suppress files=".*[\\/]generated[\\/].*\.java" checks=".*"/>
22+
23+
<!-- Suppress line length checks for test files with long URLs or test data -->
24+
<suppress files=".*Test\.java" checks="LineLength" lines="1-999999"/>
25+
26+
<!-- Allow missing Javadoc for test methods -->
27+
<suppress files=".*Test\.java" checks="MissingJavadocMethod"/>
28+
<suppress files=".*Test\.java" checks="JavadocMethod"/>
29+
30+
<!-- Allow missing Javadoc for test classes -->
31+
<suppress files=".*Test\.java" checks="MissingJavadocType"/>
32+
33+
<!-- Suppress abbreviation checks for common patterns like DTO, API, etc. -->
34+
<suppress files=".*DTO\.java" checks="AbbreviationAsWordInName"/>
35+
<suppress files=".*API\.java" checks="AbbreviationAsWordInName"/>
36+
37+
<!-- Allow longer lines in configuration classes -->
38+
<suppress files=".*Config\.java" checks="LineLength"/>
39+
40+
<!-- Suppress checks for application main classes -->
41+
<suppress files=".*Application\.java" checks="HideUtilityClassConstructor"/>
42+
</suppressions>

0 commit comments

Comments
 (0)