伊士活短绒未禁用过时警告 [英] Eastwood linter not disabling deprecation warnings

查看:61
本文介绍了伊士活短绒未禁用过时警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Eastwood ,我试图在掉毛时为特定的包装禁用弃用警告给定的Clojure名称空间.在这种情况下,不推荐使用Eastwood的Google API调用失败.

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.

根据文档,我尝试为该软件包禁用linter.

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.

编辑

A)我可以加载 src/main/resources/my-eastwood-config.clj .但是 com.google.api.core.ApiFutures.* 仍然不会被忽略.

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)这两种格式都给我以下错误.

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)

推荐答案

Eastwood 未获取您的配置文件.您可以使用以下命令进行调试:

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:

您可以在选项中指定键:builtin-config-files映射到覆盖读取的内置配置文件.默认为["clojure.clj""clojure-contrib.clj""third-party-libs.clj"].所有此类文件名均为仅在Eastwood的内置配置文件中查找.

类似地,您可以在选项映射中指定:config-files来给出要读取的其他文件.这些是文件名,可以在您的文件系统(指定为字符串),或者是否从中调用EastwoodREPL,任何可以传递给clojure.java.io/reader的东西.

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.

来源: https://github.com/jonase/eastwood#eastwood-config-文件

不是很具体,但这意味着将它们视为资源在/eastwood/config/...下.

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
...

还请注意您的正则表达式.我认为您想要:"^#'com \ .google \ .api \ .core \ .. *'" (请注意在 *之前的其他.);否则 \.重复.

Also watch out with your regexp. I think you want: "^#'com\.google\.api\.core\..*'" (note the additional . before the *); otherwise the \. repeats.

这篇关于伊士活短绒未禁用过时警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆