module RuboCop::Cop::SpaceAfterPunctuation
def allowed_type?(token)
def allowed_type?(token) %i[tRPAREN tRBRACK tPIPE].include?(token.type) end
def each_missing_space(tokens)
def each_missing_space(tokens) tokens.each_cons(2) do |token1, token2| next unless kind(token1) next unless space_missing?(token1, token2) next unless space_required_before?(token2) yield token1 end end
def investigate(processed_source)
def investigate(processed_source) each_missing_space(processed_source.tokens) do |token| add_offense(token, location: token.pos, message: format(MSG, token: kind(token))) end end
def offset
The normal offset, i.e., the distance from the punctuation
def offset 1 end
def space_forbidden_before_rcurly?
def space_forbidden_before_rcurly? style = space_style_before_rcurly style == 'no_space' end
def space_missing?(token1, token2)
def space_missing?(token1, token2) token1.line == token2.line && token2.column == token1.column + offset end
def space_required_before?(token)
def space_required_before?(token) !(allowed_type?(token) || (token.right_curly_brace? && space_forbidden_before_rcurly?)) end