mgechev / revive

🔥 ~6x faster, stricter, configurable, extensible, and beautiful drop-in replacement for golint
https://revive.run
MIT License
4.73k stars 276 forks source link

Add unchecked-type-assertion #889

Closed Dirk007 closed 11 months ago

Dirk007 commented 11 months ago

Closes #888

Unchecked type assertions results can (and will) result in an unexpected panic and should be a lint. This new rule covers this with configurable non-default option to ignore foo, _ := bar.(Baz) - cases where the ok value is ignored.

See tests.

chavacava commented 11 months ago

@denisvmedia You can checkout @Dirk007 's branch and check how the linter behaves with your examples

denisvmedia commented 11 months ago

@chavacava I can, but I think this should be a part of the tests ;)

Dirk007 commented 11 months ago

@chavacava I can, but I think this should be a part of the tests ;)

I totally agree! Unfortunately I am a bit short of time this week but will work on the suggested ideas ASAP.

denisvmedia commented 11 months ago

Just one thing came to my mind now, probably this is still left out (sorry, can't check it now): channel <- v.(int).

Dirk007 commented 11 months ago

Just one thing came to my mind now, probably this is still left out (sorry, can't check it now): channel <- v.(int).

good idea.. let me write a test 👍