Reputation: 2738
Using Eastwood, I'm trying to disable deprecation warnings, for a specific package, when linting a given Clojure namespace. In this case, eastwood is failing when making a Google API call which is deprecated.
As per the documentation, I tried to disable the linter for that package.
λ cat src/main/resources/third-party-libs.clj
(disable-warning
{:linter :deprecations
:symbol-matches #{"^#'com\.google\.api\.core\.*'"}})
But no dice. How can I turn off deprecation for specific classes or packages?
my/namespace.clj:13:5: deprecations: Static method 'public static void com.google.api.core.ApiFutures.addCallback(com.google.api.core.ApiFuture,com.google.api.core.ApiFutureCallback)' is deprecated.
EDIT
A) I'm able to load src/main/resources/my-eastwood-config.clj
. But com.google.api.core.ApiFutures.*
still isn't ignored.
(disable-warning
{:linter :deprecations
:symbol-matches #{#"com\.google\.api\.core\.ApiFutures.*"}})
B) Either of these formats gives me the error below.
i)
(disable-warning
{:linter :deprecations
:symbol-matches #{"^#'com\.google\.api\.core\..*'"}})
(disable-warning
{:linter :deprecations
:symbol-matches #{"^#'com\\.google\\.api\\.core\\..*'"}})
ii)
CompilerException java.lang.RuntimeException: Unsupported escape character: \., compiling:(null:4:31)
clojure.lang.Compiler.load (Compiler.java:7521)
clojure.lang.Compiler.load (Compiler.java:7461)
clojure.core/load-reader (core.clj:4053)
clojure.core/load-reader (core.clj:4048)
eastwood.util/init-warning-enable-config/fn--40733 (util.clj:916)
eastwood.util/init-warning-enable-config (util.clj:914)
eastwood.util/init-warning-enable-config (util.clj:907)
eastwood.lint/last-options-map-adjustments (lint.clj:467)
eastwood.lint/last-options-map-adjustments (lint.clj:456)
eastwood.lint/eastwood (lint.clj:511)
eastwood.lint/eastwood (lint.clj:501)
eastwood.lint/eastwood (lint.clj:502)
eastwood.lint/eastwood (lint.clj:501)
eastwood.lint/eastwood-from-cmdline (lint.clj:529)
eastwood.lint/eastwood-from-cmdline (lint.clj:528)
clojure.lang.Var.invoke (Var.java:381)
eastwood.versioncheck/run-eastwood (versioncheck.clj:15)
eastwood.versioncheck/run-eastwood (versioncheck.clj:9)
user/eval39298 (form-init6182731209880131993.clj:1)
user/eval39298 (form-init6182731209880131993.clj:1)
clojure.lang.Compiler.eval (Compiler.java:7062)
clojure.lang.Compiler.eval (Compiler.java:7052)
clojure.lang.Compiler.load (Compiler.java:7514)
clojure.lang.Compiler.loadFile (Compiler.java:7452)
clojure.main/load-script (main.clj:278)
clojure.main/init-opt (main.clj:280)
clojure.main/init-opt (main.clj:280)
clojure.main/initialize (main.clj:311)
clojure.main/null-opt (main.clj:345)
clojure.main/null-opt (main.clj:342)
clojure.main/main (main.clj:424)
clojure.main/main (main.clj:387)
clojure.lang.Var.applyTo (Var.java:702)
clojure.main.main (main.java:37)
Upvotes: 1
Views: 411
Reputation: 37063
Eastwood is not picking up your config file. You can debug this with:
lein eastwood '{:debug [:config]}'
== Eastwood 0.3.7 Clojure 1.10.1 JVM 1.8.0_242 ==
Loading config file: jar:file:$HOME/.m2/repository/jonase/eastwood/0.3.7/eastwood-0.3.7.jar!/eastwood/config/clojure.clj
Loading config file: jar:file:$HOME/.m2/repository/jonase/eastwood/0.3.7/eastwood-0.3.7.jar!/eastwood/config/clojure-contrib.clj
Loading config file: jar:file:$HOME/.m2/repository/jonase/eastwood/0.3.7/eastwood-0.3.7.jar!/eastwood/config/third-party-libs.clj
...
The reason, why a similar named file is not picked up:
You can specify the key :builtin-config-files in the options map to override the built-in config files read. It defaults to ["clojure.clj" "clojure-contrib.clj" "third-party-libs.clj"]. All such file names are only looked for in Eastwood's built-in config files.
Similarly you can specify :config-files in the options map to give additional files to read. These are file names that can be anywhere in your file system, specified as strings, or if Eastwood is invoked from the REPL, anything that can be passed to clojure.java.io/reader.
Source: https://github.com/jonase/eastwood#eastwood-config-files
Not very specific, but that would imply they are looked up as resources
under /eastwood/config/...
.
If you would put a file under that same location with the same name you may or may not win against the default configs (e.g. one wins). So the way out is to specify the config just yourself. E.g.
lein eastwood '{:config-files ["eastwood-config.clj"] :debug [:config]}'
== Eastwood 0.3.7 Clojure 1.10.1 JVM 1.8.0_242 ==
Loading config file: jar://...
...
Loading config file: eastwood-config.clj
...
Also watch out with your regexp. I think you want: "^#'com\.google\.api\.core\..*'"
(note the additional .
before the *
); otherwise the \.
repeats.
Upvotes: 1