We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
$ rubocop -V 0.36.0 (using Parser 2.3.0.1, running on ruby 2.2.3 x86_64-darwin15)
Example code:
# Setter that parses out array-like syntax from the given `attr` # EXAMPLE: # # foo = {} # foo['derp'] = [ 'hello', 'world' ] # assign(foo, 'derp[1]', 'TheLonelyGhost') # foo['derp'] # # => ['hello', 'TheLonelyGhost'] # def assign(obj, attr, value) key = attr me = obj /^(?<hash_key>.+)\[(?<array_key>[0-9]+)\]$/.match(key) do |m| key = m[:array_key].to_i obj[m[:hash_key]] ||= [] me = obj[m[:hash_key]] end me[key] = value end
Rubocop Errors thrown:
C: Performance/RedundantMatch: Use `=~` in places where the `MatchData` returned by `#match` will not be used.
Problem:
This is incorrect. MatchData is being used here inside of the block, as per the example in Ruby Docs
MatchData
If a block is given, invoke the block with MatchData if match succeed, so that you can write pat.match(str) {|m| ...} instead of
pat.match(str) {|m| ...}
Workaround:
Add the following to .rubocop.yml:
.rubocop.yml
Performance/RedundantMatch: Enabled: false
The text was updated successfully, but these errors were encountered:
81ae272
No branches or pull requests
Example code:
Rubocop Errors thrown:
Problem:
This is incorrect.
MatchData
is being used here inside of the block, as per the example in Ruby DocsWorkaround:
Add the following to
.rubocop.yml
:The text was updated successfully, but these errors were encountered: