Skip to content

Conversation

@koic
Copy link
Member

@koic koic commented Jun 6, 2019

Follow up rubocop/rubocop#7081.

This PR fixes a false negartive for Performance/RegexpMatch when using RuboCop 0.71 or higher.

This causes CI to fail.
https://circleci.com/gh/rubocop-hq/rubocop-performance/588

This is a regression similar to #47. This PR tries to fix it using a node pattern that has been used for a long time.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

Follow up rubocop/rubocop#7081.

This PR fixes a false negartive for `Performance/RegexpMatch` when using
RuboCop 0.71 or higher.

This causes CI to fail.
https://circleci.com/gh/rubocop-hq/rubocop-performance/588

This is a regression similar to rubocop#47. This PR tries to fix it using
a node pattern that has been used for a long time.
@koic koic merged commit 85be960 into rubocop:master Jun 8, 2019
@koic koic deleted the fix_a_false_negative_for_performance_regexp_match branch June 8, 2019 00:55
yahonda added a commit to yahonda/oracle-enhanced that referenced this pull request Sep 9, 2019
* Use RuboCop Performance 1.4.1
* Refer rubocop/rubocop-performance#61 and/or rubocop/rubocop-performance#73

```ruby
$ bundle exec rubocop -a
Inspecting 66 files
..........C..C..C......C.................C........................

Offenses:

lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb:68:21: C: [Corrected] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
          return if sql =~ /FROM all_/
                    ^^^^^^^^^^^^^^^^^^
lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb:241:26: C: [Corrected] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            raise unless e.message =~ /^(Closed Connection|Io exception:|No more data to read from socket|IO Error:)/
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:321:35: C: [Corrected] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
            host = "[#{host}]" if host =~ /^[^\[].*:/  # IPv6
                                  ^^^^^^^^^^^^^^^^^^^
lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb:323:46: C: [Corrected] Performance/RegexpMatch: Use match? instead of match when MatchData is not used.
            database = "/#{database}" unless database.match(/^\//)
                                             ^^^^^^^^^^^^^^^^^^^^^
lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb:650:46: C: [Corrected] Performance/RegexpMatch: Use match? instead of =~ when MatchData is not used.
              field["data_default"] = nil if field["data_default"] =~ /^(null|empty_[bc]lob\(\))$/i
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb:183:58: C: [Corrected] Performance/RegexpMatch: Use match? instead of match when MatchData is not used.
      params[:database] = "/#{params[:database]}" unless params[:database].match(/^\//)
                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

66 files inspected, 6 offenses detected, 6 offenses corrected
$
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant