Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.0.208 #34

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/lice_comb/impl/matching.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
[spdx.licenses :as sl]
[spdx.exceptions :as se]
[spdx.matching :as sm]
[spdx.expressions :as sexp]
[lice-comb.impl.spdx :as lcis]
[lice-comb.impl.regex-matching :as lcirm]
[lice-comb.impl.expressions-info :as lciei]
Expand Down Expand Up @@ -132,6 +133,7 @@
lic (sm/licenses-within-text s @lcis/license-ids-d)
ids (set/union lic @exc)]
(when ids
; We don't need to sexp/normalise the keys here, as we never detect an expression from a text
(manual-fixes (into {} (map #(hash-map % (list {:id % :type :concluded :confidence :high :strategy :spdx-text-matching})) ids))))))

(defmethod text->expressions java.io.Reader
Expand All @@ -155,6 +157,7 @@
are found."
[uri]
(when-not (s/blank? uri)
; We don't need to sexp/normalise the keys here, as we never detect an expression from a URI
(lciei/prepend-source uri
(manual-fixes
(let [suri (lciu/simplify-uri uri)]
Expand Down Expand Up @@ -304,7 +307,8 @@
(map #(if (keyword? %) % (string->ids-info %)))
flatten
seq
build-expressions-info-map))))))
build-expressions-info-map
(lciu/mapfonk sexp/normalise)))))))

(defn init!
"Initialises this namespace upon first call (and does nothing on subsequent
Expand Down
8 changes: 8 additions & 0 deletions src/lice_comb/impl/utils.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
[clojure.java.io :as io]
[clj-base62.core :as base62]))

(defn mapfonk
"Returns a new map where f has been applied to all of the keys of m."
[f m]
(when m
(into {}
(for [[k v] m]
[(f k) v]))))

(defn mapfonv
"Returns a new map where f has been applied to all of the values of m."
[f m]
Expand Down
2 changes: 1 addition & 1 deletion test/lice_comb/matching_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
(is (valid= #{"MIT" "BSD-4-Clause"} (name->expressions "MIT / BSD")))
(is (valid= #{"Apache-2.0" "GPL-3.0-only"} (name->expressions "Apache License version 2.0 / GNU General Public License version 3")))
(is (valid= #{"Apache-2.0" "GPL-3.0-only WITH Classpath-exception-2.0"} (name->expressions "Apache License version 2.0 / GNU General Public License version 3 with classpath exception")))
(is (valid= #{"EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0 OR MIT OR BSD-3-Clause AND Apache-2.0"} (name->expressions "Eclipse Public License or General Public License 2.0 or (at your discretion) later w/ classpath exception or MIT Licence or three clause bsd and Apache Licence"))))
(is (valid= #{"EPL-2.0 OR (GPL-2.0-or-later WITH Classpath-exception-2.0 AND MIT) OR (BSD-3-Clause AND Apache-2.0)"} (name->expressions "Eclipse Public License or General Public License 2.0 or (at your discretion) later w/ classpath exception aNd MIT Licence or three clause bsd and Apache Licence"))))
(testing "Messed up license expressions"
(is (valid= #{"Apache-2.0" "MIT"} (name->expressions "Apache with MIT"))))
(testing "Names seen in handpicked POMs on Maven Central"
Expand Down