Skip to content

Commit

Permalink
RailsModelMatcher: Handles calls without model
Browse files Browse the repository at this point in the history
- `human_attribute_name` would cause errors
- Fixes #489
  • Loading branch information
davidwessman authored and glebm committed Oct 20, 2024
1 parent d045392 commit 592c86b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def human_attribute_name_to_key_occurences(send_node:, location:)
receiver = children[0]
method_name = children[1]

return unless method_name == :human_attribute_name && receiver.type == :const
return unless method_name == :human_attribute_name && receiver&.type == :const

value = children[2]

Expand Down
3 changes: 3 additions & 0 deletions spec/fixtures/used_keys/a.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def self.whot
translate('activerecord.attributes.absolute.attribute')
Archive.human_attribute_name(:name)
User.model_name.human(count: 2)
# Cannot infer the type
human_attribute_name(:name)
model_name.human(count: 2)
end

SCOPE_CONSTANT = 'path.in.translation.file'.freeze
Expand Down

0 comments on commit 592c86b

Please sign in to comment.