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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore the links between tokens after arrow_on_right_operand_line#fix #684

Merged
merged 1 commit into from
Mar 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/puppet-lint/plugins/check_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,25 @@ def check
def fix(problem)
token = problem[:token]
tokens.delete(token)

# remove any excessive whitespace on the line
temp_token = token.prev_code_token
while (temp_token = temp_token.next_token)
tokens.delete(temp_token) if whitespace?(temp_token)
break if temp_token.type == :NEWLINE
end

temp_token.next_token = token
token.prev_token = temp_token
index = tokens.index(token.next_code_token)
tokens.insert(index, token)
tokens.insert(index + 1, PuppetLint::Lexer::Token.new(:WHITESPACE, ' ', 0, 0))

whitespace_token = PuppetLint::Lexer::Token.new(:WHITESPACE, ' ', temp_token.line + 1, 3)
whitespace_token.prev_token = token
token.next_token = whitespace_token
whitespace_token.next_token = tokens[index + 1]
tokens[index + 1].prev_token = whitespace_token
tokens.insert(index + 1, whitespace_token)
end

def whitespace?(token)
Expand Down