Method: RuboCop::Cop::Rails::RootPathnameMethods#on_send

Defined in:
lib/rubocop/cop/rails/root_pathname_methods.rb

#on_send(node) ⇒ Object



163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/rubocop/cop/rails/root_pathname_methods.rb', line 163

def on_send(node)
  evidence(node) do |method, path, args, rails_root|
    add_offense(node, message: format(MSG, method: method, rails_root: rails_root.source)) do |corrector|
      replacement = if dir_glob?(node)
                      build_path_glob_replacement(path, method)
                    else
                      build_path_replacement(path, method, args)
                    end

      corrector.replace(node, replacement)
    end
  end
end