Skip to content

Commit

Permalink
More brace fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Jo Vandeginste <Jo.Vandeginste@kuleuven.be>
  • Loading branch information
jovandeginste committed Jun 26, 2020
1 parent 9a54c06 commit bddc195
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
Expand Up @@ -25,7 +25,7 @@ def check

notify(
:error,
message: 'there should be a bracket or a single newline before a closing brace',
message: 'there should be a single space or newline before a closing brace',
line: prev_code_token.next_token.line,
column: prev_code_token.next_token.column,
token: prev_code_token.next_token,
Expand All @@ -51,7 +51,7 @@ def fix(problem)
next_token = next_token.next_token
end

if next_token.type == :RBRACE && !%i[LBRACE RBRACE RBRACK NEWLINE INDENT].include?(next_token.prev_token.type)
if next_token.type == :RBRACE && !%i[LBRACE NEWLINE INDENT].include?(next_token.prev_token.type)
add_token(tokens.index(next_token), new_single_space)
end
end
Expand Down
2 changes: 1 addition & 1 deletion puppet-lint-manifest_whitespace-check.gemspec
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = 'puppet-lint-manifest_whitespace-check'
spec.version = '0.1.13'
spec.version = '0.1.14'
spec.homepage = 'https://github.com/kuleuven/puppet-lint-manifest_whitespace-check'
spec.license = 'MIT'
spec.author = 'Jo Vandeginste'
Expand Down
Expand Up @@ -3,7 +3,37 @@
require 'spec_helper'

describe 'manifest_whitespace_closing_brace_before' do
let(:closing_brace_msg) { 'there should be a bracket or a single newline before a closing brace' }
let(:closing_brace_msg) { 'there should be a single space or newline before a closing brace' }

context 'with plus' do
let(:code) do
<<~EOF
$my_images = { 'default' => {}}
EOF
end

context 'with fix enabled' do
before do
PuppetLint.configuration.fix = true
end

after do
PuppetLint.configuration.fix = false
end

it 'should fix a error' do
expect(problems).to contain_fixed(closing_brace_msg)
end

it 'should add spaces' do
expect(manifest).to eq(
<<~EOF,
$my_images = { 'default' => {} }
EOF
)
end
end
end

context 'with nested hash' do
let(:code) do
Expand Down

0 comments on commit bddc195

Please sign in to comment.