Skip to content

Commit 692030b

Browse files
rm spaces
1 parent ea0241e commit 692030b

10 files changed

Lines changed: 67 additions & 67 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,56 +9,56 @@ on:
99
jobs:
1010
build-and-test:
1111
runs-on: ubuntu-latest
12-
12+
1313
steps:
1414
- uses: actions/checkout@v4
15-
15+
1616
- name: Setup Java
1717
uses: actions/setup-java@v4
1818
with:
1919
distribution: 'temurin'
2020
java-version: '17'
21-
21+
2222
- name: Install Leiningen
2323
uses: DeLaGuardo/setup-clojure@12.1
2424
with:
2525
lein: 2.10.0
26-
26+
2727
- name: Install dependencies
2828
run: lein deps
29-
29+
3030
- name: Run tests
3131
run: lein test
32-
32+
3333
- name: Run architectural fitness checks
3434
run: ./bin/check-architecture.sh
35-
35+
3636
- name: Build uberjar
3737
run: lein uberjar
38-
38+
3939
- name: Upload uberjar artifact
4040
uses: actions/upload-artifact@v4
4141
with:
4242
name: walue-uberjar
4343
path: target/uberjar/walue-*-standalone.jar
44-
44+
4545
docker-build:
4646
needs: build-and-test
4747
runs-on: ubuntu-latest
4848
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
49-
49+
5050
steps:
5151
- uses: actions/checkout@v4
52-
52+
5353
- name: Set up Docker Buildx
5454
uses: docker/setup-buildx-action@v3
55-
55+
5656
- name: Login to DockerHub
5757
uses: docker/login-action@v3
5858
with:
5959
username: ${{ secrets.DOCKERHUB_USERNAME }}
6060
password: ${{ secrets.DOCKERHUB_TOKEN }}
61-
61+
6262
- name: Build and push
6363
uses: docker/build-push-action@v5
6464
with:

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Walue - Portfolio Evaluation Service
22

3-
[![CI/CD Pipeline](https://github.com/yourusername/walue/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/yourusername/walue/actions/workflows/ci-cd.yml)
4-
[![Architectural Fitness](https://img.shields.io/badge/Architectural%20Fitness-Checked-brightgreen.svg)](https://github.com/yourusername/walue/blob/main/src/walue/infra/fitness.clj)
3+
[![CI/CD Pipeline](https://github.com/wagnerdevocelot/walue/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/wagnerdevocelot/walue/actions/workflows/ci-cd.yml)
4+
[![Architectural Fitness](https://img.shields.io/badge/Architectural%20Fitness-Checked-brightgreen.svg)](https://github.com/wagnerdevocelot/walue/blob/main/src/walue/infra/fitness.clj)
55

66
A Clojure web service that implements a portfolio evaluation system using Domain-Driven Design (DDD) and Hexagonal Architecture.
77

src/walue/adapter/http_adapter.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
(cond
3434
(and (= uri "/api/evaluate") (= method :post))
3535
(handle-evaluate-portfolio request evaluation-service logging-service)
36-
36+
3737
(and (= uri "/health") (= method :get))
3838
(handle-health-check request)
39-
39+
4040
:else
4141
{:status 404
4242
:body {:error "Not found"}}))))
@@ -46,7 +46,7 @@
4646
(let [start (System/currentTimeMillis)
4747
response (handler request)
4848
duration (- (System/currentTimeMillis) start)]
49-
(logging-port/log-info logging-service
49+
(logging-port/log-info logging-service
5050
(str "Request completed in " duration " ms with status " (:status response)))
5151
response)))
5252

src/walue/core.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
(Integer/parseInt port-str)
3838
(catch NumberFormatException _
3939
(let [logging-service (logging-port/->LoggingService)]
40-
(logging-port/log-warn logging-service
40+
(logging-port/log-warn logging-service
4141
(str "Invalid PORT environment variable value: " port-str " - using default 8080")))
4242
8080))))
4343

src/walue/domain/evaluation.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
(defn calculate-asset-score
4848
"Calculate score for a single asset based on all criteria"
4949
[asset criteria]
50-
(reduce
50+
(reduce
5151
(fn [score criterion]
5252
(if (evaluate-criterion asset criterion)
5353
(+ score (or (:peso criterion) (get criterion "peso")))
@@ -58,7 +58,7 @@
5858
(defn evaluate-portfolio
5959
"Main domain function that evaluates a portfolio based on criteria"
6060
[portfolio criteria]
61-
(let [evaluated-assets (map
61+
(let [evaluated-assets (map
6262
(fn [asset]
6363
{:ticker (or (:ticker asset) (get asset "ticker"))
6464
:score (calculate-asset-score asset criteria)})

src/walue/infra/fitness.clj

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
files (get-clj-files src-dir)
5151
ns-deps (keep extract-namespace-and-deps files)
5252
violations (atom [])]
53-
53+
5454
(doseq [[ns-name deps] ns-deps]
5555
(let [src-layer (ns-to-layer ns-name)]
5656
(when src-layer
@@ -59,12 +59,12 @@
5959
(when (and dep-layer
6060
(not (contains? (get allowed-deps src-layer) dep-layer))
6161
(not= src-layer dep-layer))
62-
(swap! violations conj
62+
(swap! violations conj
6363
{:source ns-name
6464
:source-layer src-layer
6565
:dependency dep
6666
:dependency-layer dep-layer})))))))
67-
67+
6868
{:valid? (empty? @violations)
6969
:violations @violations}))
7070

@@ -75,16 +75,16 @@
7575
files (get-clj-files src-dir)
7676
ns-deps (keep extract-namespace-and-deps files)
7777
violations (atom [])]
78-
78+
7979
(doseq [[ns-name deps] ns-deps]
8080
(doseq [dep deps]
8181
(let [dep-str (str dep)]
8282
(when-not (or (str/starts-with? dep-str "clojure.")
8383
(str/starts-with? dep-str "walue.domain"))
84-
(swap! violations conj
84+
(swap! violations conj
8585
{:namespace ns-name
8686
:external-dependency dep})))))
87-
87+
8888
{:valid? (empty? @violations)
8989
:violations @violations}))
9090

@@ -97,12 +97,12 @@
9797
visited (atom #{})
9898
path (atom [])
9999
cycles (atom [])]
100-
100+
101101
(letfn [(dfs [ns]
102102
(when-not (contains? @visited ns)
103103
(swap! visited conj ns)
104104
(swap! path conj ns)
105-
105+
106106
(doseq [dep (get ns-deps ns)]
107107
(if (some #{dep} @path)
108108
;; Encontrou um ciclo
@@ -111,13 +111,13 @@
111111
(swap! cycles conj cycle))
112112
;; Continue DFS
113113
(dfs dep)))
114-
114+
115115
(swap! path pop)))]
116-
116+
117117
(doseq [ns (keys ns-deps)]
118118
(reset! path [])
119119
(dfs ns)))
120-
120+
121121
{:valid? (empty? @cycles)
122122
:cycles @cycles}))
123123

@@ -127,15 +127,15 @@
127127
(let [src-dir "src/walue/port"
128128
files (get-clj-files src-dir)
129129
violations (atom [])]
130-
130+
131131
(doseq [file files]
132132
(let [content (slurp file)
133133
file-name (.getName file)]
134134
(when-not (re-find #"defprotocol" content)
135-
(swap! violations conj
135+
(swap! violations conj
136136
{:file file-name
137137
:reason "Port file should define at least one protocol"}))))
138-
138+
139139
{:valid? (empty? @violations)
140140
:violations @violations}))
141141

@@ -145,18 +145,18 @@
145145
(let [src-dir "src/walue/adapter"
146146
files (get-clj-files src-dir)
147147
violations (atom [])]
148-
148+
149149
(doseq [file files]
150150
(let [content (slurp file)
151151
file-name (.getName file)
152-
has-port-dependency (or
152+
has-port-dependency (or
153153
(re-find #"require.*\[walue\.port" content)
154154
(re-find #"walue\.port\.[a-z-]+\s+:as" content))]
155155
(when-not has-port-dependency
156-
(swap! violations conj
156+
(swap! violations conj
157157
{:file file-name
158158
:reason "Adapter should depend on at least one port"}))))
159-
159+
160160
{:valid? (empty? @violations)
161161
:violations @violations}))
162162

@@ -173,7 +173,7 @@
173173
(:valid? circular-deps-result)
174174
(:valid? interface-result)
175175
(:valid? adapter-result))]
176-
176+
177177
{:all-valid? all-valid?
178178
:layer-dependencies layer-deps-result
179179
:domain-purity domain-purity-result
@@ -186,9 +186,9 @@
186186
[& args]
187187
(let [results (run-fitness-checks)
188188
all-valid? (:all-valid? results)]
189-
189+
190190
(println "\n=== Architectural Fitness Check Results ===\n")
191-
191+
192192
;; Verifica dependências entre camadas
193193
(let [{:keys [valid? violations]} (:layer-dependencies results)]
194194
(println "Layer Dependencies Check:" (if valid? "PASSED ✓" "FAILED ✗"))
@@ -197,39 +197,39 @@
197197
(doseq [v violations]
198198
(println (str " - " (:source v) " (" (name (:source-layer v)) ") depends on "
199199
(:dependency v) " (" (name (:dependency-layer v)) ")")))))
200-
200+
201201
;; Verifica pureza do domínio
202202
(let [{:keys [valid? violations]} (:domain-purity results)]
203203
(println "\nDomain Purity Check:" (if valid? "PASSED ✓" "FAILED ✗"))
204204
(when-not valid?
205205
(println " Violations:")
206206
(doseq [v violations]
207207
(println (str " - " (:namespace v) " depends on external " (:external-dependency v))))))
208-
208+
209209
;; Verifica dependências circulares
210210
(let [{:keys [valid? cycles]} (:circular-dependencies results)]
211211
(println "\nCircular Dependencies Check:" (if valid? "PASSED ✓" "FAILED ✗"))
212212
(when-not valid?
213213
(println " Cycles detected:")
214214
(doseq [cycle cycles]
215215
(println (str " - " (str/join " -> " cycle))))))
216-
216+
217217
;; Verifica isolamento de interfaces
218218
(let [{:keys [valid? violations]} (:interface-isolation results)]
219219
(println "\nInterface Isolation Check:" (if valid? "PASSED ✓" "FAILED ✗"))
220220
(when-not valid?
221221
(println " Violations:")
222222
(doseq [v violations]
223223
(println (str " - " (:file v) ": " (:reason v))))))
224-
224+
225225
;; Verifica implementação de adaptadores
226226
(let [{:keys [valid? violations]} (:adapter-implementation results)]
227227
(println "\nAdapter Implementation Check:" (if valid? "PASSED ✓" "FAILED ✗"))
228228
(when-not valid?
229229
(println " Violations:")
230230
(doseq [v violations]
231231
(println (str " - " (:file v) ": " (:reason v))))))
232-
232+
233233
(println "\nOverall Result:" (if all-valid? "PASSED ✓" "FAILED ✗"))
234-
234+
235235
(System/exit (if all-valid? 0 1))))

src/walue/infra/metrics.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
value-fn)
2828

2929
(defn get-all-metrics []
30-
(reduce-kv
30+
(reduce-kv
3131
(fn [acc k v]
3232
(let [value (cond
3333
(= (:type v) :counter) (get-counter-value (:value v))

src/walue/port/logging_port.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
(defrecord LoggingService []
1111
LoggingPort
12-
(log-info [_ message]
12+
(log-info [_ message]
1313
(println (str "{\"level\":\"info\",\"message\":\"" message "\"}")))
1414
(log-warn [_ message]
1515
(println (str "{\"level\":\"warn\",\"message\":\"" message "\"}")))

test/walue/adapter/http_adapter_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
(mock/json-body request-body))
4545
response (app request)
4646
body (parse-json-body response)]
47-
47+
4848
(is (= 200 (:status response)))
4949
(is (vector? (:resultado body)))
5050
(is (= 2 (count (:resultado body))))
@@ -60,7 +60,7 @@
6060
request (mock/request :get "/health")
6161
response (app request)
6262
body (parse-json-body response)]
63-
63+
6464
(is (= 200 (:status response)))
6565
(is (= "UP" (:status body)))))
6666

@@ -72,6 +72,6 @@
7272
(mock/json-body {:invalid "request"}))
7373
response (app request)
7474
body (parse-json-body response)]
75-
75+
7676
(is (= 400 (:status response)))
7777
(is (contains? body :error))))))

0 commit comments

Comments
 (0)