-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add cop for checking duplicate assingments to ignored_columns
#514
Conversation
I think the following should be technically permitted. expect_no_offenses(<<~RUBY)
class User < ActiveRecord::Base
if condition
self.ignored_columns = [:one]
else
self.ignored_columns = [:two]
end
end
RUBY |
Oh, good point. Indeed it should. Any hints on how to approach that? A cop that does something similar to |
822c438
to
ca0781c
Compare
I'm not sure, but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I believe we can make it stricter with no negative impact.
ca0781c
to
e2912eb
Compare
I couldn't make it work with conditional branches :(. Will that be a blocker? |
e2912eb
to
6897bb0
Compare
Setting `ignored_columns` may overwrite previous assignments, and that is problematic because it can un-ignore a previously set column list. Since it is not a problem to have a duplicate column in the list, simply recommend always appending.
6897bb0
to
58602b3
Compare
Setting may overwrite previous assignments and that is almost always a mistake. See also rubocop/rubocop-rails#514
I added a PR for rails style guide rubocop/rails-style-guide#301 |
Setting may overwrite previous assignments and that is almost always a mistake. See also rubocop/rubocop-rails#514
Setting may overwrite previous assignments and that is almost always a mistake. See also rubocop/rubocop-rails#514
Setting may overwrite previous assignments and that is almost always a mistake. See also rubocop/rubocop-rails#514
@fsateler @koic @pirj Waiting for this PR to be merged. What's Blocker? (Though I think #514 (comment) is related) |
Can you please force-push to trigger CI, @kkitadate ? |
Sure. I will open another PR as I can't push to this branch. |
@koic thanks for the kind words. I'm glad someone else made it work faster. As long as it happened I'm happy :) Thank you for maintaining rubocop-rails! |
Setting may overwrite previous assignments and that is almost always a mistake. See also rubocop/rubocop-rails#514
Overwriting previous assignments is usually a mistake, since it will
un-ignore the first set of columns
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.