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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error scanning app/models/application_record.rb: undefined method `type' for nil:NilClass #489

Open
hobbypunk90 opened this issue Feb 7, 2023 · 1 comment

Comments

@hobbypunk90
Copy link

Heyho,

i have a problem with the rails model matcher. At first i need to require it in my config - weird, but okay 馃榿

<% require 'i18n/tasks/scanners/ast_matchers/rails_model_matcher' %>
<% I18n::Tasks.add_ast_matcher('I18n::Tasks::Scanners::AstMatchers::RailsModelMatcher') %>

When i run it now, i get this error:

#<Thread:0x00007f2d4ee278e0 /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/scanner_multiplexer.rb:33 run> terminated with exception (report_on_exception is true):
/home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb:19:in `human_attribute_name_to_key_occurences': Error scanning app/models/application_record.rb: undefined method `type' for nil:NilClass (I18n::Tasks::CommandError)

      return unless method_name == :human_attribute_name && receiver.type == :const
                                                                    ^^^^^
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb:8:in `convert_to_key_occurrences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:106:in `block (2 levels) in ast_to_occurences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:105:in `each'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:105:in `block in ast_to_occurences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:104:in `each'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:104:in `ast_to_occurences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:32:in `scan_file'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/file_scanner.rb:27:in `block in keys'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/files/file_finder.rb:30:in `map'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/files/file_finder.rb:30:in `traverse_files'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/file_scanner.rb:57:in `traverse_files'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/file_scanner.rb:26:in `keys'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/scanner_multiplexer.rb:34:in `block (3 levels) in collect_results'
/home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb:19:in `human_attribute_name_to_key_occurences': undefined method `type' for nil:NilClass (NoMethodError)

      return unless method_name == :human_attribute_name && receiver.type == :const
                                                                    ^^^^^
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ast_matchers/rails_model_matcher.rb:8:in `convert_to_key_occurrences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:106:in `block (2 levels) in ast_to_occurences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:105:in `each'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:105:in `block in ast_to_occurences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:104:in `each'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:104:in `ast_to_occurences'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/ruby_ast_scanner.rb:32:in `scan_file'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/file_scanner.rb:27:in `block in keys'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/files/file_finder.rb:30:in `map'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/files/file_finder.rb:30:in `traverse_files'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/file_scanner.rb:57:in `traverse_files'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/file_scanner.rb:26:in `keys'
        from /home/marcel/.rbenv/versions/3.1.3/lib/ruby/gems/3.1.0/gems/i18n-tasks-1.0.12/lib/i18n/tasks/scanners/scanner_multiplexer.rb:34:in `block (3 levels) in collect_results'
i18n-tasks: Error scanning app/models/application_record.rb: undefined method `type' for nil:NilClass

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

Greets
Marcel

@brad-ellert
Copy link
Contributor

Not sure about this error, but you no longer need to require it like that after #512.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants