eastwood

All things realted to eastwood - the Clojure linter
kirill.salykin 2019-10-09T10:03:13.001500Z

Hello, I am a bit confused, please help Is it possible to disable some linters for one function only? I tried this: https://github.com/jonase/eastwood/blob/master/doc/README-clojure-annotations.md, but it doesnt seem to work…

slipset 2019-10-09T11:00:48.002800Z

Hi @kirill.salykin it's a bit tricky, and not always possible. Could you please tell me which linters you'd want to disable (and for which functions?)

kirill.salykin 2019-10-09T11:17:41.003500Z

basically I want to avoid wrong-arity check of amazonica functions `

kirill.salykin 2019-10-09T11:17:48.003800Z

(get-value [_ key]
    ;; eastwood: {:suppress-warnings [:wrong-arity]}
    (-> (s3/get-object {:access-key aws-access-key-id
                        :secret-key aws-secret-access-key-id
                        :endpoint region}
                       :bucket-name bucket :key key)
        :input-stream
        slurp))

kirill.salykin 2019-10-09T11:18:11.004300Z

and same for put-object

kirill.salykin 2019-10-09T11:18:33.005Z

is there a way I can exclude all amazonica.* things?

slipset 2019-10-09T12:12:27.005500Z

https://github.com/jonase/eastwood#wrong-arity should explain how to do it.

slipset 2019-10-09T12:12:42.006Z

Problem is that it seems to be done pr symbol and not pr package.

slipset 2019-10-09T12:13:20.006700Z

Which means you need to write a disable-warning for each fn you want ignored.

kirill.salykin 2019-10-09T12:14:47.006900Z

k, thanks

kirill.salykin 2019-10-09T13:32:34.007500Z

I’ve added the file ./resources/eastwood/config.clj:

(disable-warning
 {:linter :wrong-arity
  :function-symbol 'amazonica.aws.s3/get-object})

(disable-warning
 {:linter :wrong-arity
  :function-symbol 'amazonica.aws.s3/put-object})

kirill.salykin 2019-10-09T13:32:52.008Z

but it doesnt seem to work… what I am doing wrong?

kirill.salykin 2019-10-09T14:37:12.008400Z

also, seems :exclude-namespaces also do not work

2019-10-09T14:52:16.009100Z

Regarding your custom disable-warning configurations, did you specify the name of the file that contains those disable-warning expressions in the Eastwood options map with a key :config-files ?

2019-10-09T14:53:05.009900Z

There are several config files like that included with Eastwood, which are read by default, but any that you write will not be read by default -- you must tell Eastwood which ones to read.

2019-10-09T14:54:50.010700Z

Regarding that doc/README-clojure-annotations.md file you found, that is a kind of design/brainstorming document of something that I think would be nice to implement, but it has not been implemented.

2019-10-09T14:55:21.011100Z

I guess it might be nice to say that in the first sentence or two of that file, to avoid misleading folks.

2019-10-09T14:57:47.011300Z

warning added.

kirill.salykin 2019-10-09T15:06:14.011600Z

yes `

kirill.salykin 2019-10-09T15:06:18.011800Z

{:extra-deps {jonase/eastwood {:mvn/version "RELEASE"}}
   :main-opts  ["-m" "eastwood.lint" "{:source-paths,[\"src\"],:exclude-linters,[:wrong-arity],:config-files,#{\"eastwood.clj\"}}"]}

kirill.salykin 2019-10-09T15:09:21.013Z

core/IStore
  (get-value [_ key]
             (-> (s3/get-object {:access-key aws-access-key-id
                                 :secret-key aws-secret-access-key-id
                                 :endpoint region}
                                :bucket-name bucket :key key)
                 :input-stream
                 slurp))
so, basically get-value is protocol implementation wrong-arity linter complaints about s3/get-object arity thus, which function I should exclude? can I exclude all amazonica functions? Shall it be added to default configs? (similar to what now done to clojure and other 3rd parties?

2019-10-09T15:23:54.013700Z

It would be good to test it in your application before adding it to the default Eastwood configs, I think, to ensure that it works as you hope.

2019-10-09T15:25:08.014400Z

Looking at the examples of configuring the wrong-arity linter that exist in the Eastwood source code, all of them have a key :arglists-for-linting, like for this example: https://github.com/jonase/eastwood/blob/master/resource/eastwood/config/clojure.clj#L66-L70

2019-10-09T15:25:57.015400Z

Can you try adding a key like that to your config, with a list of vectors, one for each acceptable arity of s3/get-object that you think is correct?

kirill.salykin 2019-10-09T15:26:16.015700Z

will do

2019-10-09T15:26:48.016400Z

Using the one above like ([& args]) should I think disable warnings for that function entirely, because it will allow any number of args

2019-10-09T15:27:13.016700Z

but you can make it do some checking, if you would find that helpful.

kirill.salykin 2019-10-09T15:29:18.017200Z

worked, thanks a lot! arglists-for-linting - thats what I was missing

2019-10-09T15:29:59.017900Z

Yeah, the examples of those configurations could stand a comment or so mentioning that. Looking at it for the first time in a few years, that wasn't obvious to me, either, and I wrote it 🙂

2019-10-09T15:31:11.018500Z

In this case, the use of disable-warning is definitely misleading. it is more like configure-linter

kirill.salykin 2019-10-09T15:32:31.018800Z

indeed