class RuboCop::Cop::CopStore

Store for all cops with helper functions

def cop_name_with_namespace(name, origin, basename, found_ns)

def cop_name_with_namespace(name, origin, basename, found_ns)
  if name != basename && found_ns != File.dirname(name).to_sym
    warn "#{origin}: #{name} has the wrong namespace - should be " \
         "#{found_ns}"
  end
  "#{found_ns}/#{basename}"
end

def qualified_cop_name(name, origin)

def qualified_cop_name(name, origin)
  @cop_names ||= Set.new(map(&:cop_name))
  basename = File.basename(name)
  found_ns = types.map(&:capitalize).select do |ns|
    @cop_names.include?("#{ns}/#{basename}")
  end
  case found_ns.size
  when 0 then name # No namespace found. Deal with it later in caller.
  when 1 then cop_name_with_namespace(name, origin, basename, found_ns[0])
  else raise AmbiguousCopName,
             "Ambiguous cop name `#{basename}` used in" \
             "#{origin} needs namespace qualifier."
  end
end

def types

Returns:
  • (Array) - list of types for current cops.
def types
  @types ||= map(&:cop_type).uniq!
end

def with_type(type)

Returns:
  • (Array) - Cops for that specific type.
def with_type(type)
  CopStore.new(select { |c| c.cop_type == type })
end

def without_type(type)

Returns:
  • (Array) - Cops not for a specific type.
def without_type(type)
  CopStore.new(reject { |c| c.cop_type == type })
end