プロジェクト

全般

プロフィール

Vote #80411

未完了

Ignore rubocop offense

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
-
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
30
version_id:
0
issue_org_id:
32296
author_id:
411898
assigned_to_id:
0
comments:
7
status_id:
1
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

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.


journals

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

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

1 file inspected, no offenses detected
</pre>
--------------------------------------------------------------------------------
Reproduced it with BUNDLE_DISABLE_EXEC_LOAD=1 when using bundler.

<pre>
$ 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
</pre>

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

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

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

<pre>
$ 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
</pre>
--------------------------------------------------------------------------------
Sorry, BUNDLE_DISABLE_EXEC_LOAD was not related with this behavior.

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

<pre>
$ 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
</pre>

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

<pre>
$ 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
</pre>
--------------------------------------------------------------------------------
I can replicate this issue
<pre>
$ 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
</pre>

<pre>
$ 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
</pre>
--------------------------------------------------------------------------------
Adding updated patch to fix Rubocop offenses
--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリCode cleanup/refactoring_30 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0