Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7351
| From | Stanimir Stamenkov <s7an10@netscape.net> |
|---|---|
| Newsgroups | comp.lang.ruby |
| Subject | Static analysis – Unused method return value and method!() return values |
| Date | 2017-05-14 15:38 +0300 |
| Organization | A noiseless patient Spider |
| Message-ID | <of9it5$5g8$1@dont-email.me> (permalink) |
Is there a static analysis tool (a.k.a. linter) which would flag
warnings for the following usages:
some_hash[:a_key].strip.gsub!(/^0+/, '')
...
and then:
some_collection.map do |foo|
foo[:bar] == 'baz' && foo[:qux].strip.gsub!(/^0+/, '')
end
In the first instance the result of the gsub!() method is
effectively thrown away resulting in no-op.
The second case is ambiguous as many of the core Ruby method!()s
return false, instead of "value" when they haven't actually
performed a modification. So I would like to have a warning when
such core ! methods get used in a bigger expressions incl. assignments.
I've tried RuboCop and RubyCritic but they don't seem to flag the
given usages as problems. Is there another tool to help with this,
or is there specific configuration to any of the two mentioned which
would trigger the intended warnings?
https://github.com/bbatsov/rubocop
https://github.com/whitesmith/rubycritic
--
Stanimir
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar
Static analysis – Unused method return value and method!() return values Stanimir Stamenkov <s7an10@netscape.net> - 2017-05-14 15:38 +0300
Re: Static analysis – Unused method return value and method!() return values Robert Klemme <shortcutter@googlemail.com> - 2017-05-15 08:19 +0200
Re: Static analysis – Unused method return value and method!() return values Stanimir Stamenkov <s7an10@netscape.net> - 2017-07-15 18:14 +0300
Re: Static analysis – Unused method return value and method!() return values Robert Klemme <shortcutter@googlemail.com> - 2017-07-15 18:29 +0200
Re: Static analysis – Unused method return value and method!() return values Stanimir Stamenkov <s7an10@netscape.net> - 2017-07-15 23:20 +0300
csiph-web