Skip to content

Commit 74c13e6

Browse files
pavetokPaula Gearon
authored andcommitted
fix all kibit issues
1 parent cf25e69 commit 74c13e6

File tree

5 files changed

+31
-34
lines changed

5 files changed

+31
-34
lines changed

src/naga/cli.clj

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@
3333

3434
(defn usage
3535
[{summary :summary}]
36-
(->> ["Executes Naga on a program."
37-
""
38-
"Usage: naga [filename]"
39-
""
40-
summary
41-
(str "Store types: " (into [] stores))
42-
""]
43-
(string/join \newline)))
36+
(string/join
37+
\newline
38+
["Executes Naga on a program."
39+
""
40+
"Usage: naga [filename]"
41+
""
42+
summary
43+
(str "Store types: " (vec stores))
44+
""]))
4445

4546
(defn run-all
4647
"Runs a program, and returns the data processed, the results, and the stats.
@@ -74,7 +75,6 @@
7475
:output (remove (set axioms) data)
7576
:stats stats}))
7677

77-
7878
(defn- nm
7979
"Returns a string version of a keyword. These are not being represented
8080
as Clojure keywords, so namespaces (when they exist) are separated by
@@ -84,7 +84,6 @@
8484
(str n ":" (name k))
8585
(name k)))
8686

87-
8887
(defn- predicate-string
8988
"Convert a predicate triplet into a string."
9089
[[e p v]]
@@ -95,7 +94,7 @@
9594
(defn logic-program
9695
[in-stream]
9796
(let [{:keys [input output stats]} (run-all in-stream)]
98-
(println "INPUT DATA")
97+
(println "INPUT DATA")
9998
(doseq [a input] (println (predicate-string a)))
10099
(println "\nNEW DATA")
101100
(doseq [a output] (println (predicate-string a)))))

src/naga/data.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@
103103
"Converts parsed JSON into a sequence of triples for a provided storage."
104104
[storage j]
105105
(binding [*current-storage* storage]
106-
(doall (apply concat
107-
(map ident-map->triples j)))))
106+
(doall (mapcat ident-map->triples j))))
108107

109108

110109
(s/defn stream->triples :- [Triple]
@@ -184,11 +183,12 @@
184183
"Uses a set of property-value pairs to load up a nested data structure from the graph"
185184
[store :- Storage
186185
prop-vals :- [[s/Keyword s/Any]]]
187-
(->
186+
(dissoc
188187
(->> prop-vals
189188
(map (partial recurse-node store))
190189
(into {}))
191-
(dissoc :db/id :db/ident)))
190+
:db/id
191+
:db/ident))
192192

193193

194194
(s/defn id->json :- {s/Keyword s/Any}

src/naga/engine.clj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@
9393
;; the rule was run
9494
[storage
9595
(u/mapmap :name (comp deref :execution-count) (vals rules))]
96-
96+
9797

9898
;; find if any patterns have updated
9999
(if-let [dirty-patterns (seq (keep extract-dirty-pattern
100100
status))]
101101
;; rule needs to be run
102102
(let [counted-patterns (keep (partial resolve-count storage status)
103-
dirty-patterns)
103+
dirty-patterns)
104104

105-
counted-set (into #{} counted-patterns)
105+
counted-set (set counted-patterns)
106106

107107
hinted-patterns (map #(get counted-set % %) body)]
108108

@@ -142,7 +142,6 @@
142142
{:keys [rules axioms]} :- Program]
143143
(let [storage (store/get-storage-handle config)
144144
storage' (store/start-tx storage)
145-
[output-storage stats] (->> (store/assert-data storage' axioms)
146-
(execute rules))
145+
[output-storage stats] (execute rules (store/assert-data storage' axioms))
147146
result-storage (store/commit-tx output-storage)]
148147
[result-storage stats]))

src/naga/lang/basic.clj

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[the.parsatron :refer :all]
77
[naga.schema.structs :as st]))
88

9-
(defn choice*
9+
(defn choice*
1010
"choice with backtracking."
1111
[& args]
1212
(apply choice (map attempt args)))
@@ -73,32 +73,32 @@
7373

7474
(defparser integer []
7575
(let->> [i (either digits (signed-digits))]
76-
(always (Long/parseLong (apply str i)))))
76+
(always (Long/parseLong (str/join i)))))
7777

7878
(defparser floating-point []
7979
(let->> [i (either digits (signed-digits))
8080
f (>> (char \.) (many1 (digit)))]
81-
(always (Double/parseDouble (apply str (apply str i) \. f)))))
81+
(always (Double/parseDouble (apply str (str/join i) \. f)))))
8282

8383
(def number (either* (floating-point) (integer)))
8484

8585
;; parses strings of the form: 'it''s a string!'
8686
(defparser pstring1 []
87-
(let->> [s (many1 (between (char \') (char \') (many non-squote))) ]
88-
(always (apply str (flatten (interpose \' s))))))
87+
(let->> [s (many1 (between (char \') (char \') (many non-squote)))]
88+
(always (str/join (flatten (interpose \' s))))))
8989

9090
;; parses strings of the form: "She said, ""Hello,"" to me."
9191
(defparser pstring2 []
9292
(let->> [s (many1 (between (char \") (char \") (many non-dquote)))]
93-
(always (apply str (flatten (interpose \" s))))))
93+
(always (str/join (flatten (interpose \" s))))))
9494

9595
(def pstring (either (pstring1) (pstring2)))
9696

9797
;; variables start with a capital. Internally they start with ?
9898
(defparser variable []
9999
(let->> [f (upper-case-letter)
100100
r (many (letter))]
101-
(always (symbol (apply str "?" (Character/toLowerCase f) r) ))))
101+
(always (symbol (apply str "?" (Character/toLowerCase f) r)))))
102102

103103
(defn build-keyword
104104
"Creates a keyword from a parsed word token"
@@ -114,7 +114,7 @@
114114
;; atomic values, like a predicate, are represented as a keyword
115115
(defparser kw []
116116
(let->> [r ns-word]
117-
(let [wrd (apply str r)]
117+
(let [wrd (str/join r)]
118118
(if-let [k (build-keyword wrd)]
119119
(always k)
120120
(throw (fail (str "Invalid identifier: " wrd)))))))

src/naga/storage/memory/core.clj

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
([patterns :- [EPVPattern]]
3232
(let [all-paths (paths #{} patterns)]
3333
(assert (every? (partial = (count patterns)) (map count all-paths))
34-
(str "No valid paths through: " (into [] patterns)))
34+
(str "No valid paths through: " (vec patterns)))
3535
all-paths))
3636
([bound :- #{Symbol}
3737
patterns :- [EPVPattern]]
@@ -97,7 +97,7 @@
9797
(s/defn select-planner
9898
"Selects a query planner function"
9999
[options]
100-
(let [opt (into #{} options)]
100+
(let [opt (set options)]
101101
(case (get opt :planner)
102102
:user user-plan
103103
:min min-join-path
@@ -171,7 +171,7 @@
171171
(extend-protocol Constraint
172172
;; EPVPatterns are implemented in vectors
173173
IPersistentVector
174-
(get-vars [p] (into #{} (st/vars p)))
174+
(get-vars [p] (set (st/vars p)))
175175

176176
(left-join [p results graph] (pattern-left-join graph results p))
177177

@@ -276,7 +276,7 @@
276276
(and (keyword? value)
277277
(= "mem" (namespace value))
278278
(str/starts-with? (name value) "node-")))
279-
279+
280280
(data-property [_ data]
281281
:naga/first)
282282

@@ -292,8 +292,7 @@
292292
(count (mem/resolve-pattern graph pattern))))
293293

294294
(query [_ output-pattern patterns]
295-
(->> (join-patterns graph patterns)
296-
(project output-pattern)))
295+
(project output-pattern (join-patterns graph patterns)))
297296

298297
(assert-data [_ data]
299298
(->MemoryStore (add-to-graph graph data)))

0 commit comments

Comments
 (0)