Skip to content
New issue

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

Rails/CreateTableWithTimestamps false positive #5503

Closed
mockdeep opened this issue Jan 24, 2018 · 1 comment
Closed

Rails/CreateTableWithTimestamps false positive #5503

mockdeep opened this issue Jan 24, 2018 · 1 comment
Labels

Comments

@mockdeep
Copy link
Contributor

When using to_proc syntax, the Rails/CreateTableWithTimestamps rule gives a false positive:

db/migrate/20130718144328_create_guest_accounts.rb:4:5: C: Rails/CreateTableWithTimestamps: Add timestamps when creating a new table.
    create_table(:guest_accounts, &:timestamps)

Expected behavior

There should be no violation reported

Actual behavior

There is a violation reported

Steps to reproduce the problem

Run against a migration that looks like:

class CreateGuestAccounts < ActiveRecord::Migration
  def change
    create_table(:guest_accounts, &:timestamps)
  end
end

RuboCop version

Include the output of rubocop -V. Here's an example:

$ rubocop -V
0.52.1 (using Parser 2.4.0.2, running on ruby 2.3.3 x86_64-linux)
wata727 added a commit to wata727/rubocop that referenced this issue Jan 25, 2018
Fixes rubocop#5503

When using `to_proc` syntax, `Rails/CreateTableWithTimestamps` cop
doesn't report offenses even if specifying timestamps.
@pocke pocke added the bug label Jan 26, 2018
bbatsov pushed a commit that referenced this issue Jan 27, 2018
Fixes #5503

When using `to_proc` syntax, `Rails/CreateTableWithTimestamps` cop
doesn't report offenses even if specifying timestamps.
malikolivier added a commit to malikolivier/lmml-on-rails that referenced this issue Feb 28, 2018
This is a false positive, a bug in rubocop. Will be fixed in the next
release: rubocop/rubocop#5503
@nilocoelhojunior
Copy link

Hi, I have 0.55.0 (using Parser 2.5.1.0, running on ruby 2.5.1 x86_64-linux) and get the same error:

Rails/CreateTableWithTimestamps: Add timestamps when creating a new table.

My file:

class CreateAttachments < ActiveRecord::Migration[5.1]
  def  change
    create_table :attachments, id: :string, limit: 42, &:timestamps
  end
end

wata727 added a commit to wata727/rubocop that referenced this issue May 9, 2018
See also:
rubocop#5503 (comment)
When using `create_table` with hash options, this Cop reports
false positives.
bbatsov pushed a commit that referenced this issue May 14, 2018
See also:
#5503 (comment)
When using `create_table` with hash options, this Cop reports
false positives.
koic pushed a commit to rubocop/rubocop-rails that referenced this issue Oct 26, 2018
See also:
rubocop/rubocop#5503 (comment)
When using `create_table` with hash options, this Cop reports
false positives.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants