You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
clj-kondo appears to ignore #_,,, ignored forms within the body of (do ,,,) forms for the purpose of determining if the (do ,,,) form is redundant.
repro
clj-kondo --lint - <<< '(do #_(println "42") 42)'
<stdin>:1:1: warning: redundant do
linting took 46ms, errors: 0, warnings: 1
expected behavior
Let me start by acknowledging this is an odd case and you could argue that leaving #_,,, ignored forms in the code just isn't good style. For better or worse, we have several instances like this in our codebases, and we are able to disable the linter warning with #_{:clj-kondo/ignore [:redundant-do]}.
I wanted to open a conversation here in case other people encounter the same behavior.
I suspect this may be tough to change in clj-kondo (assuming you even wanted to) because #_,,, is probably ignored/discarded relatively early in the process. Further, it might be necessary to distinguish between #_:clj-kondo/ignore/#_{,,, :clj-kondo/ignore [,,,] ,,,} forms (which probably should be ignored for redundant-do purposes) and other #_,,, forms that should not.
See also #1453 -- I think we have a couple places in our codebase like (doto (Foo.) #_(.doSomething)) that would be flagged redundant-doto without a change in the handling of #_,,, within (doto ,,,) forms.
I'm potentially interested in opening a PR, but I think the next step is to gauge interest and discuss what, if any, clj-kondo changes are desired.
This discussion was converted from issue #1787 on August 24, 2022 21:30.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
version
clj-kondo v2022.06.22
platform
Native clj-kondo on macOS 10.12 (Sierra)
problem
clj-kondo appears to ignore
#_,,,
ignored forms within the body of(do ,,,)
forms for the purpose of determining if the(do ,,,)
form is redundant.repro
expected behavior
Let me start by acknowledging this is an odd case and you could argue that leaving
#_,,,
ignored forms in the code just isn't good style. For better or worse, we have several instances like this in our codebases, and we are able to disable the linter warning with#_{:clj-kondo/ignore [:redundant-do]}
.I wanted to open a conversation here in case other people encounter the same behavior.
I suspect this may be tough to change in clj-kondo (assuming you even wanted to) because
#_,,,
is probably ignored/discarded relatively early in the process. Further, it might be necessary to distinguish between#_:clj-kondo/ignore
/#_{,,, :clj-kondo/ignore [,,,] ,,,}
forms (which probably should be ignored for redundant-do purposes) and other#_,,,
forms that should not.See also #1453 -- I think we have a couple places in our codebase like
(doto (Foo.) #_(.doSomething))
that would be flagged redundant-doto without a change in the handling of#_,,,
within(doto ,,,)
forms.I'm potentially interested in opening a PR, but I think the next step is to gauge interest and discuss what, if any, clj-kondo changes are desired.
Beta Was this translation helpful? Give feedback.
All reactions