crystal icon indicating copy to clipboard operation
crystal copied to clipboard

Unused instance and local variable accesses

Open nobodywasishere opened this issue 9 months ago • 4 comments
trafficstars

I've been developing new rules for ameba, and as part of that have been testing them on this repository to verify their functionality. I've found a few issues that could be fixed.

src/compiler/crystal/tools/formatter.cr:

Image

src/compiler/crystal/syntax/parser.cr:

Image

src/compiler/crystal/semantic/filters.cr:

Image

There are several others, but they're mostly having the var on the last line of a method that has a Nil return.

nobodywasishere avatar Feb 12 '25 04:02 nobodywasishere

Happy to accept a patch.

I'm not sure it makes much sense to track such individual linter issues in a ticket. As long as the code works, it's fine. Of course we'd want to improve the quality. But IMO it's not important enough to keep a bookmark for every detail. Especially considering that they should be relatively straightforward to just fix. We could have a meta issue to keep track of linter problems, though.

straight-shoota avatar Feb 12 '25 09:02 straight-shoota

I agree, I'll start working on an initial PR to start fixing these and other issues. The check_end one concerns me though, as it may introduce a breaking change by fixing it. I'm fine turning this into a ticket to keep track of linter issues / discuss them

nobodywasishere avatar Feb 12 '25 09:02 nobodywasishere

Related:

  • #14608

straight-shoota avatar Feb 12 '25 09:02 straight-shoota

Of course, if there's a problematic detail to discuss on a specific linter issue, such a discussion is much appreciated.

It wasn't clear to me that the check_end variable is shadowing a method. So yeah we ought to be careful about that. Apparently the formatter specs are not dense enough to catch that these check_end are not actually checking the end.

straight-shoota avatar Feb 12 '25 09:02 straight-shoota