-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support multiple superclasses #98
Changes from 3 commits
c6f70a9
5c94d86
50c2ddb
9b2c386
c427705
9498048
93ee910
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,17 +36,16 @@ def on_class(node) | |
end | ||
|
||
def model?(node) | ||
return unless (superclass = node.children[1]) | ||
|
||
superclass.const_name == model_superclass_name | ||
superclass = node.children[1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you consider looking for all leaf nodes that include There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So unfortunately it's not this straightforward because this is not a Ruby object, it's an AST node. As far as we could see this only has the context of the current file, so you'd have to do a bunch of finnagling to be able to look at the class hierarchy outside of that context. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 , happy to have another look into some ways around this if blocking though :~) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's probably fine. I guess we could potentially add a spec in payments-service to ensure all classes that inherit from ApplicationRecord and have children of their own are included in the Maybe something that can be looked into another time. "Good enough" is better than not improving things because they're not yet perfect after all :) |
||
model_superclass_name.include? superclass&.const_name | ||
end | ||
|
||
def class_name(node) | ||
node.children[0].const_name | ||
end | ||
|
||
def model_superclass_name | ||
cop_config["ModelSuperclass"] || "ApplicationRecord" | ||
Array.wrap(cop_config["ModelSuperclass"] || "ApplicationRecord") | ||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Anony | ||
VERSION = "1.1.0" | ||
VERSION = "1.2.0" | ||
end |
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.
I hope UmbrellaCorp get a high risk rating XD