Patch #32296

Ignore rubocop offense

Added by Masahiro IUCHI over 2 years ago. Updated 8 months ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Code cleanup/refactoring
Target version:-

Description

I found a rubocop offense is remaining.

$ rubocop db/migrate/20190510070108_add_unique_id_to_import_items.rb
Inspecting 1 file
C

Offenses:

db/migrate/20190510070108_add_unique_id_to_import_items.rb:3:5: C: Rails/BulkChangeTable: You can combine alter queries using bulk: true options.
    change_table :import_items do |t|
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

Environment information:

$ RAILS_ENV=test bin/about

Environment:
  Redmine version                4.0.4.devel.18732
  Ruby version                   2.5.5-p157 (2019-03-15) [x86_64-darwin19]
  Rails version                  5.2.3
  Environment                    test
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::InlineAdapter
  Mailer delivery                test
SCM:
  Subversion                     1.10.4
  Git                            2.21.0
  Filesystem
Redmine plugins:
  no plugin installed

I have created a patch to ignore it like other migration files.

ignore-rubocop-offense.patch Magnifier (456 Bytes) Masahiro IUCHI, 2019-10-18 08:34

fix-migration-rubocop-offenses.diff Magnifier (2.41 KB) Paolo Lim, 2020-10-13 10:18

History

#1 Updated by Go MAEDA over 2 years ago

I run RuboCop against r18732 but was not able to reproduce the warning.

$ bundle exec rubocop db/migrate/20190510070108_add_unique_id_to_import_items.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

#2 Updated by Masahiro IUCHI over 2 years ago

Reproduced it with BUNDLE_DISABLE_EXEC_LOAD=1 when using bundler.

$ BUNDLE_DISABLE_EXEC_LOAD=1 bundle exec rubocop db/migrate/20190510070108_add_unique_id_to_import_items.rb
Inspecting 1 file
C

Offenses:

db/migrate/20190510070108_add_unique_id_to_import_items.rb:3:5: C: Rails/BulkChangeTable: You can combine alter queries using bulk: true options.
    change_table :import_items do |t|
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

I think this is a rare case written in bundler's documentation.

https://bundler.io/v2.0/man/bundle-exec.1.html#Loading

#3 Updated by Go MAEDA over 2 years ago

Thank you for the feedback. But I still cannot see the warning.

$ ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
$ bundler -v
Bundler version 2.0.2
$ bundle update --quiet
$ BUNDLE_DISABLE_EXEC_LOAD=1 bundle exec rubocop db/migrate/20190510070108_add_unique_id_to_import_items.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

#4 Updated by Masahiro IUCHI over 2 years ago

Sorry, BUNDLE_DISABLE_EXEC_LOAD was not related with this behavior.

Please execute rubocop command with "--cache false" option.

$ bundle exec rubocop --cache false db/migrate/20190510070108_add_unique_id_to_import_items.rb
Inspecting 1 file
C

Offenses:

db/migrate/20190510070108_add_unique_id_to_import_items.rb:3:5: C: Rails/BulkChangeTable: You can combine alter queries using bulk: true options.
    change_table :import_items do |t|
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

#5 Updated by Go MAEDA over 2 years ago

I don't know the cause, but I still cannot reproduce the warning in my environment.

$ svn info --show-item revision
18898
$ bundle exec rubocop --version
0.76.0
$ bundle exec rubocop --cache false db/migrate/20190510070108_add_unique_id_to_import_items.rb
Inspecting 1 file
.

1 file inspected, no offenses detected

#6 Updated by Paolo Lim over 1 year ago

I can replicate this issue

$ rubocop db/migrate/20190510070108_add_unique_id_to_import_items.rb 
Inspecting 1 file
C

Offenses:

db/migrate/20190510070108_add_unique_id_to_import_items.rb:3:5: C: Rails/BulkChangeTable: You can combine alter queries using bulk: true options.
    change_table :import_items do |t|
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected

$ RAILS_ENV=test bin/about

Environment:
  Redmine version                4.1.1.devel
  Ruby version                   2.6.5-p114 (2019-10-01) [x86_64-linux]
  Rails version                  5.2.4.4
  Environment                    test
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::InlineAdapter
  Mailer delivery                sendmail
SCM:
  Subversion                     1.9.7
  Git                            2.17.1
  Filesystem                     
Redmine plugins:
  no plugin installed

#7 Updated by Paolo Lim over 1 year ago

Adding updated patch to fix Rubocop offenses

Also available in: Atom PDF