This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-13
Channels
- # announcements (1)
- # beginners (155)
- # calva (104)
- # cider (7)
- # clj-kondo (55)
- # cljdoc (2)
- # cljs-dev (19)
- # cljsrn (22)
- # clojure (230)
- # clojure-europe (1)
- # clojure-italy (15)
- # clojure-losangeles (8)
- # clojure-nl (11)
- # clojure-spec (20)
- # clojure-uk (30)
- # clojurescript (10)
- # code-reviews (32)
- # cursive (2)
- # data-science (6)
- # datascript (3)
- # datomic (141)
- # fulcro (1)
- # graphql (6)
- # jobs-discuss (19)
- # luminus (8)
- # off-topic (30)
- # pathom (2)
- # protorepl (8)
- # reagent (15)
- # reitit (3)
- # shadow-cljs (11)
- # tools-deps (1)
- # xtdb (8)
@borkdude Just tried the (macOS) binary you posted above. I hope you forgive me for not going through all that has already been reported and I’ll just report my finding here:
(ns metrics-server.gitlab-fetcher
(:require [clj-http.client :as client]
[clojure.string :as str]
[clojure.data.json :as json])
(:import java.time.ZoneId
java.time.format.DateTimeFormatter
java.time.temporal.TemporalAdjusters
java.time.LocalDate
java.time.DayOfWeek))
(def zone-id (. ZoneId systemDefault))
(def formatter (. DateTimeFormatter ISO_OFFSET_DATE_TIME))
(defn date-to-string [date-time]
(-> date-time
(. atStartOfDay)
(. atZone zone-id)
(. format formatter)))
(def last-monday
(-> (. LocalDate now)
(. with (. TemporalAdjusters previousOrSame DayOfWeek/MONDAY))))
(def before-last-monday
(-> last-monday
(. with (. TemporalAdjusters previous DayOfWeek/MONDAY))))
(def before-before-last-monday
(-> before-last-monday
(. with (. TemporalAdjusters previous DayOfWeek/MONDAY))))
gives:
src/metrics_server/gitlab_fetcher.clj:11:17: error: unresolved symbol ZoneId
src/metrics_server/gitlab_fetcher.clj:11:24: error: unresolved symbol systemDefault
src/metrics_server/gitlab_fetcher.clj:12:19: error: unresolved symbol DateTimeFormatter
src/metrics_server/gitlab_fetcher.clj:12:37: error: unresolved symbol ISO_OFFSET_DATE_TIME
src/metrics_server/gitlab_fetcher.clj:15:10: error: unresolved symbol atStartOfDay
src/metrics_server/gitlab_fetcher.clj:16:10: error: unresolved symbol atZone
src/metrics_server/gitlab_fetcher.clj:19:10: error: unresolved symbol LocalDate
src/metrics_server/gitlab_fetcher.clj:19:20: error: unresolved symbol now
src/metrics_server/gitlab_fetcher.clj:20:10: error: unresolved symbol with
src/metrics_server/gitlab_fetcher.clj:20:18: error: unresolved symbol TemporalAdjusters
src/metrics_server/gitlab_fetcher.clj:20:36: error: unresolved symbol previousOrSame
src/metrics_server/gitlab_fetcher.clj:23:36: error: unresolved symbol previous
Also, this code:
(defn extract-relevant-fields [{:keys [key name]
[{:keys [value]}] :measures}]
{:key key
:name name
:value value})
gives:
src/metrics_server/complexity.clj:7:11: error: unresolved symbol value
(Feedback on my code style is appreciated btw as I’m learning Clojure 😉)Similarly:
(defn extract-relevant-fields [{{:keys [additions deletions]} :stats}]
{:additions additions
:deletions deletions})
gives:
src/metrics_server/churn.clj:4:15: error: unresolved symbol additions
src/metrics_server/churn.clj:5:15: error: unresolved symbol deletions
@stefan.van.den.oord Thanks for that. Some of those have already been solved, but there are some unknown ones, so I’ll go through them and let you know.
@stefan.van.den.oord I believe most, if not all, errors are now resolved in this binary: https://3614-176829714-gh.circle-artifacts.com/0/release/clj-kondo-2019.06.08-alpha-SNAPSHOT-macos-amd64.zip Feel free to test and report other issues at: https://github.com/borkdude/clj-kondo/issues/174
In the CLI tool, I’m getting an “Unparsable namespace form” for:
(ns foo
(:require [clojure.string :as str]
#?(:cljs [cljs.reader :as reader])))
I can reproduce this if you lint the code as non-cljc, but as clj. but if you put this code in a .cljc file, it works
clj-kondo could probably report a better error message like: reader conditional not supported in .clj file or something
ok, I had the old custom define-flycheck-checker
instead of using flycheck-clj-kondo package
if you’re using flycheck-clj-kondo, it should trigger this inside a .cljc file: https://github.com/borkdude/flycheck-clj-kondo/blob/master/flycheck-clj-kondo.el#L74
is there (or should there be) a way to mark namespaces that are required for side effects in the source (not config)?
because I think that would be good documentation to be present in the source where the require is placed and could be used for linting purposes
@tatut that’s what we’re trying to achieve in this discussion: https://github.com/borkdude/clj-kondo/issues/241 a convention that all tooling/linters could use
@tatut if there are many similar namespaces you want to capture in one go, you can also use a regex in the config
@tatut another idea: https://github.com/borkdude/clj-kondo/issues/241#issuecomment-501693768
that would be enough from a tooling stand point imo, but I kind of like forcing myself to explicitly state it (for documentation purposes)
but maybe less is more in this case, no need to get everyone to agree on a proper metadata style… just omit :as
and :refer
and it is assumed to be for side effects
@tatut I usually use comments to document why it is required, it can be for various reasons and comments do give you the freedom to explain it how you want
should clj-kondo just go ahead and implement it as per your comment? with optional configuration to set it off (something like :assume-implicit-require
flag)
I think it makes sense as the default behavior (underreporting is better than overreporting) and an option to turn it off
@borkdude regarding that #241 issue, probably a “stupid” question, but does it have to be namespaced? Can’t it be simply ^:implicitly_used
without ns (for example)?
having trouble keeping the underscores out of my code as well 🙂 Maybe a new linter rule? 🤪
good one in Berlin: https://www.angloitalianfollowus.com/who-knew-vegan-kebab-meat-exists-at-voner-berlin
Documentation for an upcoming new unresolved symbols linter: https://github.com/borkdude/clj-kondo/blob/unresolved-symbols/doc/config.md#exclude-unresolved-symbols-from-being-reported If you like to take it for a test run, let me know.