Skip to content

Commit 310d3d4

Browse files
authored
Merge pull request #99 from SpringNoobs/98-reformular-e-reaplicar-lógica-de-formatação-de-código-com-o-spotless
Reformular e reaplicar lógica de formatação de código com o spotless
2 parents 8a31288 + 01b37cc commit 310d3d4

3 files changed

Lines changed: 47 additions & 35 deletions

File tree

.github/workflows/pipeline.yml

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,36 +48,4 @@ jobs:
4848
uses: actions/upload-artifact@v5.0.0
4949
with:
5050
name: jacoco-report
51-
path: target/site/jacoco
52-
53-
format:
54-
name: Format Code
55-
permissions:
56-
contents: write
57-
runs-on: ubuntu-latest
58-
59-
steps:
60-
- uses: actions/checkout@v5.0.0
61-
with:
62-
ref: ${{ github.event.pull_request.head.ref}}
63-
fetch-depth: 0
64-
65-
- name: Instalar Java 25
66-
uses: actions/setup-java@v5.0.0
67-
with:
68-
distribution: "temurin"
69-
java-version: 25
70-
- name: Formatar código com Spotless
71-
run: ./mvnw spotless:apply
72-
73-
- name: Faz um commit e push das mudanças
74-
run: |
75-
git config user.name "github-actions[bot]"
76-
git config user.email "github-actions[bot]@users.noreply.github.com"
77-
git add .
78-
if ! git diff --staged --quiet; then
79-
git commit -m "Aplica formatação do spotless"
80-
git push
81-
else
82-
echo "Nenhuma mudança de formatação necessária."
83-
fi
51+
path: target/site/jacoco

.github/workflows/spotless.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Format Code
2+
3+
on:
4+
pull_request_review:
5+
types: [submitted]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
format:
13+
if: github.event.review.state == 'approved'
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout na branch do Pull Request
18+
uses: actions/checkout@v5
19+
with:
20+
ref: ${{ github.event.pull_request.head.ref }}
21+
repository: ${{ github.event.pull_request.head.repo.full_name }}
22+
fetch-depth: 0
23+
24+
- name: Instalar Java 25
25+
uses: actions/setup-java@v5
26+
with:
27+
distribution: temurin
28+
java-version: 25
29+
30+
- name: Aplicar Spotless
31+
run: ./mvnw spotless:apply
32+
33+
- name: Commit e push se houver mudanças
34+
run: |
35+
if [[ -n "$(git status --porcelain)" ]]; then
36+
git config user.name "github-actions[bot]"
37+
git config user.email "github-actions[bot]@users.noreply.github.com"
38+
git add .
39+
git commit -m "chore: apply spotless formatting"
40+
git push
41+
else
42+
echo "Nenhuma mudança de formatação."
43+
fi

src/main/java/br/com/springnoobs/reminderapi/reminder/controller/ReminderController.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ public ResponseEntity<ReminderResponseDTO> findById(@PathVariable Long id) {
3535
return ResponseEntity.ok(reminderService.findById(id));
3636
}
3737

38-
@PostMapping()
38+
@PostMapping
3939
public ResponseEntity<ReminderResponseDTO> create(@RequestBody @Valid CreateReminderRequestDTO dto) {
4040
return ResponseEntity.status(HttpStatus.CREATED).body(reminderService.create(dto));
4141
}
4242

4343
@PutMapping("/{id}")
4444
public ResponseEntity<ReminderResponseDTO> update(
45-
@PathVariable Long id, @RequestBody @Valid UpdateReminderRequestDTO dto) {
45+
@PathVariable Long id, @RequestBody @Valid UpdateReminderRequestDTO dto)
46+
{
4647
return ResponseEntity.ok(reminderService.update(id, dto));
4748
}
4849

0 commit comments

Comments
 (0)