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

False positive: reports definterface methods as unused #1762

Closed
mrkam2 opened this issue Jan 30, 2024 · 3 comments
Closed

False positive: reports definterface methods as unused #1762

mrkam2 opened this issue Jan 30, 2024 · 3 comments
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor

Comments

@mrkam2
Copy link

mrkam2 commented Jan 30, 2024

Describe the bug
clojure-lsp incorrectly identifies definterface methods as unused.

To Reproduce
Steps to reproduce the behavior:

Create foo_test.clj:

(ns foo-test)

(definterface Foo
  (bar [x]))

(let [f (reify Foo (bar [_ x] x))]
  (.bar f 5))

It can be evaluated to verify that bar was defined and used in the snippet.
clojure-lsp diagnostics would show that (bar [x]) is unused.

Expected behavior
It should not report these methods as unused.

@mrkam2 mrkam2 added API Related to API / CLI bug Something isn't working labels Jan 30, 2024
@ericdallo ericdallo added editor Related to clojure-lsp on a text editor and removed API Related to API / CLI labels Jan 31, 2024
@ericdallo
Copy link
Member

@borkdude do you see anything that clj-kondo could help here? the problem is that the only analysis for .bar is a instance-invocation:

   {:method-name "bar",
    :uri "...",
    :bucket :instance-invocations}

So I can't find a way to relate that bar with the bar from the definterface 🤔

@borkdude
Copy link
Contributor

I don't think it makes sense to flag foo as an unused var even when .foo is not called since reify uses the whole interface.

@ericdallo
Copy link
Member

hum, good point, I think it makes sense to ignore all methods in the unused-public-var linter and consider only the Foo if it's being used or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working editor Related to clojure-lsp on a text editor
Projects
Status: Done
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy