class RuboCop::Cop::GitHub::RailsViewRenderPathsExist
Public Instance Methods
on_send(node)
click to toggle source
# File lib/rubocop/cop/github/rails_view_render_paths_exist.rb, line 25 def on_send(node) return unless cop_config["ViewPath"] if args = render_str?(node) node, path = args unless resolve_partial(path.to_s) add_offense(node, location: :expression, message: "Partial template could not be found") end elsif pairs = render_options?(node) if pair = pairs.detect { |p| partial_key?(p) } node, path = partial_key?(pair) unless resolve_partial(path.to_s) add_offense(node, location: :expression, message: "Partial template could not be found") end end end end
resolve_partial(path)
click to toggle source
# File lib/rubocop/cop/github/rails_view_render_paths_exist.rb, line 44 def resolve_partial(path) parts = path.split(File::SEPARATOR) parts << "_#{parts.pop}" path = parts.join(File::SEPARATOR) cop_config["ViewPath"].each do |view_path| if m = Dir[File.join(config.path_relative_to_config(view_path), path) + "*"].first return m end end nil end