Skip to content

Commit

Permalink
fixed code style in all files, used clojure-lsp
Browse files Browse the repository at this point in the history
Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
  • Loading branch information
avelino committed Apr 26, 2024
1 parent bd1d96a commit 3448b06
Show file tree
Hide file tree
Showing 28 changed files with 166 additions and 138 deletions.
9 changes: 5 additions & 4 deletions dev/com/moclojer/build.clj
@@ -1,9 +1,10 @@
(ns com.moclojer.build
(:refer-clojure :exclude [test])
(:require [clojure.string :as string]
[clojure.tools.build.api :as b]
[com.moclojer.config :as config]
[com.moclojer.native-image :as native-image]))
(:require
[clojure.string :as string]
[clojure.tools.build.api :as b]
[com.moclojer.config :as config]
[com.moclojer.native-image :as native-image]))

(def class-dir "target/classes")
(def jar-file "target/moclojer.jar")
Expand Down
8 changes: 4 additions & 4 deletions dev/com/moclojer/native_image.clj
@@ -1,8 +1,8 @@
(ns com.moclojer.native-image
(:require [clojure.data.json :as json]
[clojure.java.io :as io]
[clojure.string :as string]))

(:require
[clojure.data.json :as json]
[clojure.java.io :as io]
[clojure.string :as string]))

(def initialize-at-build-time
"list of classes to initialize at build time"
Expand Down
5 changes: 3 additions & 2 deletions src/com/moclojer/adapters.clj
@@ -1,6 +1,7 @@
(ns com.moclojer.adapters
(:require [com.moclojer.io-utils :refer [open-file]]
[com.moclojer.router :as router]))
(:require
[com.moclojer.io-utils :refer [open-file]]
[com.moclojer.router :as router]))

(defn inputs->config
[{:keys [args opts]} envs]
Expand Down
3 changes: 2 additions & 1 deletion src/com/moclojer/config.clj
@@ -1,5 +1,6 @@
(ns com.moclojer.config
(:require [babashka.cli :as cli]))
(:require
[babashka.cli :as cli]))

(def version
"get version from pom properties"
Expand Down
11 changes: 6 additions & 5 deletions src/com/moclojer/core.clj
@@ -1,9 +1,10 @@
(ns com.moclojer.core
(:require [babashka.cli :as cli]
[com.moclojer.adapters :as adapters]
[com.moclojer.config :as config]
[com.moclojer.log :as log]
[com.moclojer.server :as server])
(:require
[babashka.cli :as cli]
[com.moclojer.adapters :as adapters]
[com.moclojer.config :as config]
[com.moclojer.log :as log]
[com.moclojer.server :as server])
(:gen-class))

(defn -main
Expand Down
5 changes: 3 additions & 2 deletions src/com/moclojer/external_body/core.clj
@@ -1,6 +1,7 @@
(ns com.moclojer.external-body.core
(:require [cheshire.core :as cheshire]
[com.moclojer.external-body.excel :as xlsx]))
(:require
[cheshire.core :as cheshire]
[com.moclojer.external-body.excel :as xlsx]))

(defn ->str
"convert body to string, if it is edn it will be converted to json->str"
Expand Down
3 changes: 2 additions & 1 deletion src/com/moclojer/external_body/excel.clj
@@ -1,5 +1,6 @@
(ns com.moclojer.external-body.excel
(:require [bb-excel.core :as excel]))
(:require
[bb-excel.core :as excel]))

(defn ->map
"converts excel (xlsx and xls) tab/sheet name to map"
Expand Down
12 changes: 7 additions & 5 deletions src/com/moclojer/io_utils.clj
@@ -1,9 +1,11 @@
(ns com.moclojer.io-utils
(:require [clojure.edn :as edn]
[clojure.string :as string]
[com.moclojer.log :as log]
[yaml.core :as yaml])
(:import [java.io FileNotFoundException]))
(:require
[clojure.edn :as edn]
[clojure.string :as string]
[com.moclojer.log :as log]
[yaml.core :as yaml])
(:import
[java.io FileNotFoundException]))

(defn open-file [path]
(if (empty? path)
Expand Down
32 changes: 17 additions & 15 deletions src/com/moclojer/log.clj
@@ -1,16 +1,18 @@
(ns com.moclojer.log
(:require [clojure.string :as string]
[io.pedestal.interceptor.helpers :as interceptor]
[taoensso.timbre :as timbre]
[taoensso.timbre.appenders.core :as core-appenders]
[taoensso.timbre.appenders.community.sentry :as sentry]
[timbre-json-appender.core :as tas])
(:import (java.util.logging
Filter
Formatter
Handler
LogRecord
Logger)))
(:require
[clojure.string :as string]
[io.pedestal.interceptor.helpers :as interceptor]
[taoensso.timbre :as timbre]
[taoensso.timbre.appenders.community.sentry :as sentry]
[taoensso.timbre.appenders.core :as core-appenders]
[timbre-json-appender.core :as tas])
(:import
(java.util.logging
Filter
Formatter
Handler
LogRecord
Logger)))

(set! *warn-on-reflection* true)

Expand Down Expand Up @@ -55,9 +57,9 @@
(clean-timbre-appenders)
(global-setup (.getParent (Logger/getGlobal))) ;; disable `org.eclipse.jetty` logs
(let [config (merge
{:min-level level
:ns-filter {:allow #{"com.moclojer.*"}}}
(log-format->mergeable-cfg fmt))
{:min-level level
:ns-filter {:allow #{"com.moclojer.*"}}}
(log-format->mergeable-cfg fmt))
sentry-dsn (or (System/getenv "SENTRY_DSN") nil)]
(timbre/merge-config! config)
(when sentry-dsn
Expand Down
9 changes: 5 additions & 4 deletions src/com/moclojer/router.clj
@@ -1,8 +1,9 @@
(ns com.moclojer.router
(:require [clojure.data.json :as json]
[com.moclojer.log :as log]
[com.moclojer.specs.moclojer :as spec]
[com.moclojer.specs.openapi :as openapi]))
(:require
[clojure.data.json :as json]
[com.moclojer.log :as log]
[com.moclojer.specs.moclojer :as spec]
[com.moclojer.specs.openapi :as openapi]))

(def home-endpoint
"initial/home endpoint URL: /"
Expand Down
26 changes: 14 additions & 12 deletions src/com/moclojer/server.clj
@@ -1,16 +1,18 @@
(ns com.moclojer.server
(:require [clojure.data.json :as json]
[com.moclojer.adapters :as adapters]
[com.moclojer.config :as config]
[com.moclojer.io-utils :refer [open-file]]
[com.moclojer.log :as log]
[com.moclojer.watcher :refer [start-watch]]
[io.pedestal.http :as http]
[io.pedestal.http.body-params :as body-params]
[io.pedestal.http.jetty]
[io.pedestal.interceptor.error :refer [error-dispatch]])
(:import (org.eclipse.jetty.server.handler.gzip GzipHandler)
(org.eclipse.jetty.servlet ServletContextHandler)))
(:require
[clojure.data.json :as json]
[com.moclojer.adapters :as adapters]
[com.moclojer.config :as config]
[com.moclojer.io-utils :refer [open-file]]
[com.moclojer.log :as log]
[com.moclojer.watcher :refer [start-watch]]
[io.pedestal.http :as http]
[io.pedestal.http.body-params :as body-params]
[io.pedestal.http.jetty]
[io.pedestal.interceptor.error :refer [error-dispatch]])
(:import
(org.eclipse.jetty.server.handler.gzip GzipHandler)
(org.eclipse.jetty.servlet ServletContextHandler)))

(defn context-configurator
"http container options, active gzip"
Expand Down
11 changes: 6 additions & 5 deletions src/com/moclojer/specs/moclojer.clj
@@ -1,9 +1,10 @@
(ns com.moclojer.specs.moclojer
(:require [clojure.string :as string]
[io.pedestal.http.route :as route]
[com.moclojer.external-body.core :as ext-body]
[com.moclojer.webhook :as webhook]
[selmer.parser :as selmer]))
(:require
[clojure.string :as string]
[com.moclojer.external-body.core :as ext-body]
[com.moclojer.webhook :as webhook]
[io.pedestal.http.route :as route]
[selmer.parser :as selmer]))

(defn render-template
[template request]
Expand Down
3 changes: 2 additions & 1 deletion src/com/moclojer/specs/openapi.clj
@@ -1,5 +1,6 @@
(ns com.moclojer.specs.openapi
(:require [clojure.string :as str]))
(:require
[clojure.string :as str]))

(defn convert-path
"converts OpenAPI path to moclojer path
Expand Down
7 changes: 4 additions & 3 deletions src/com/moclojer/webhook.clj
@@ -1,7 +1,8 @@
(ns com.moclojer.webhook
(:require [clj-http.client :as client]
[clojure.core.async :as a]
[com.moclojer.log :as log]))
(:require
[clj-http.client :as client]
[clojure.core.async :as a]
[com.moclojer.log :as log]))

(defn request-after-delay
"after a delay call http-request, return body"
Expand Down
5 changes: 3 additions & 2 deletions test/com/moclojer/adapters_test.clj
@@ -1,6 +1,7 @@
(ns com.moclojer.adapters-test
(:require [clojure.test :refer [are deftest testing]]
[com.moclojer.adapters :as adapters]))
(:require
[clojure.test :refer [are deftest testing]]
[com.moclojer.adapters :as adapters]))

(deftest inputs-config-test
(testing "inputs->config can read data from all data sources"
Expand Down
10 changes: 5 additions & 5 deletions test/com/moclojer/aux/samples.clj
@@ -1,8 +1,9 @@
(ns com.moclojer.aux.samples
(:require [io.pedestal.http :as http]
[io.pedestal.http.ring-middlewares :as middlewares]
[ring.util.mime-type :as mime]
[yaml.core :as yaml]))
(:require
[io.pedestal.http :as http]
[io.pedestal.http.ring-middlewares :as middlewares]
[ring.util.mime-type :as mime]
[yaml.core :as yaml]))

(def yaml-sample
(yaml/parse-string "
Expand All @@ -28,7 +29,6 @@
:body {:id 1 :name "chico"}}
:router-name :get-pet-by-id}}])


(defonce *http-state (atom nil))

(defn sample-upload-server
Expand Down
5 changes: 3 additions & 2 deletions test/com/moclojer/config_test.clj
@@ -1,6 +1,7 @@
(ns com.moclojer.config-test
(:require [clojure.test :refer [deftest is testing]]
[com.moclojer.config :as config]))
(:require
[clojure.test :refer [deftest is testing]]
[com.moclojer.config :as config]))

(deftest with-xdg-test
(testing "It generates an rc name as expected."
Expand Down
12 changes: 6 additions & 6 deletions test/com/moclojer/edn_test.clj
@@ -1,10 +1,10 @@
(ns com.moclojer.edn-test
(:require [cheshire.core :as json]
[clojure.edn :as edn]
[clojure.test :refer [deftest is testing]]
[com.moclojer.helpers-test :as helpers]
[io.pedestal.test :refer [response-for]]))

(:require
[cheshire.core :as json]
[clojure.edn :as edn]
[clojure.test :refer [deftest is testing]]
[com.moclojer.helpers-test :as helpers]
[io.pedestal.test :refer [response-for]]))

(deftest dynamic-endpoint-edn
(let [service-fn (helpers/service-fn (edn/read-string (str "[" (slurp "test/com/moclojer/resources/moclojer.edn") "]")))]
Expand Down
13 changes: 7 additions & 6 deletions test/com/moclojer/external_body/core_test.clj
@@ -1,10 +1,11 @@
(ns com.moclojer.external-body.core-test
(:require [clojure.data.json :as jsond]
[clojure.test :refer [deftest is testing]]
[com.moclojer.external-body.core :as core]
[com.moclojer.helpers-test :as helpers]
[io.pedestal.test :refer [response-for]]
[yaml.core :as yaml]))
(:require
[clojure.data.json :as jsond]
[clojure.test :refer [deftest is testing]]
[com.moclojer.external-body.core :as core]
[com.moclojer.helpers-test :as helpers]
[io.pedestal.test :refer [response-for]]
[yaml.core :as yaml]))

(def data-text
{:provider "json"
Expand Down
11 changes: 6 additions & 5 deletions test/com/moclojer/external_body/excel_test.clj
@@ -1,9 +1,10 @@
(ns com.moclojer.external-body.excel-test
(:require [cheshire.core :as json]
[clojure.test :refer [deftest is]]
[com.moclojer.helpers-test :as helpers]
[io.pedestal.test :refer [response-for]]
[yaml.core :as yaml]))
(:require
[cheshire.core :as json]
[clojure.test :refer [deftest is]]
[com.moclojer.helpers-test :as helpers]
[io.pedestal.test :refer [response-for]]
[yaml.core :as yaml]))

(deftest xlsx-config-test
(is (= [{:name "avelino", :langs "golang"}
Expand Down
11 changes: 6 additions & 5 deletions test/com/moclojer/framework_test.clj
@@ -1,9 +1,10 @@
(ns com.moclojer.framework-test
(:require [cheshire.core :as json]
[clojure.test :refer [deftest is]]
[com.moclojer.adapters :as adapters]
[com.moclojer.server :as server]
[io.pedestal.test :refer [response-for]]))
(:require
[cheshire.core :as json]
[clojure.test :refer [deftest is]]
[com.moclojer.adapters :as adapters]
[com.moclojer.server :as server]
[io.pedestal.test :refer [response-for]]))

(def *router
"create a router from a config map"
Expand Down
7 changes: 4 additions & 3 deletions test/com/moclojer/helpers_test.clj
@@ -1,7 +1,8 @@
(ns com.moclojer.helpers-test
(:require [com.moclojer.router :as router]
[com.moclojer.server :as server]
[io.pedestal.http :as http]))
(:require
[com.moclojer.router :as router]
[com.moclojer.server :as server]
[io.pedestal.http :as http]))

(defn service-fn
"create a service function of pedestal from a config map"
Expand Down
12 changes: 7 additions & 5 deletions test/com/moclojer/io_aux.clj
@@ -1,10 +1,12 @@
(ns com.moclojer.io-aux
(:refer-clojure :exclude [load])
(:require [clojure.string :as string]
[yaml.core :as yaml])
(:import (java.io File)
(java.nio.file Files)
(java.nio.file.attribute FileAttribute)))
(:require
[clojure.string :as string]
[yaml.core :as yaml])
(:import
(java.io File)
(java.nio.file Files)
(java.nio.file.attribute FileAttribute)))

(defn write-config
"write configuration file with receiving data type (yaml or edn) and structure"
Expand Down
17 changes: 9 additions & 8 deletions test/com/moclojer/log_test.clj
@@ -1,8 +1,9 @@
(ns com.moclojer.log-test
(:require [clojure.test :refer [deftest is testing]]
[com.moclojer.log :as log]
[clojure.data.json :as json]
[clojure.string :as str]))
(:require
[clojure.data.json :as json]
[clojure.string :as str]
[clojure.test :refer [deftest is testing]]
[com.moclojer.log :as log]))

(deftest json-format-logging-test
(testing "stdout content is formatted as json"
Expand All @@ -11,10 +12,10 @@
:msg "testing"
:hello "moclojer"}
(select-keys
(-> (log/log :info :testing :hello :moclojer)
with-out-str
(json/read-str :key-fn keyword))
[:msg :hello :level])))))
(-> (log/log :info :testing :hello :moclojer)
with-out-str
(json/read-str :key-fn keyword))
[:msg :hello :level])))))

(deftest default-format-logging-test
(testing "stdout content is formatted as default (println)"
Expand Down

0 comments on commit 3448b06

Please sign in to comment.