Skip to content

Commit

Permalink
Merge pull request #492 from rnelson0/arrowalignmessage
Browse files Browse the repository at this point in the history
Add better description of the problem in arrow_alignment check
  • Loading branch information
binford2k authored Aug 18, 2016
2 parents 9401f3f + 8a4e8da commit 2544db8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/check_whitespace.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def check
unless arrow_tok.column == indent_depth[indent_depth_idx] || level_tokens[indent_depth_idx].size == 1
arrows_on_line = level_tokens[indent_depth_idx].select { |t| t.line == arrow_tok.line }
notify :warning, {
:message => 'indentation of => is not properly aligned',
:message => "indentation of => is not properly aligned (expected in column #{indent_depth[indent_depth_idx]}, but found it in column #{arrow_tok.column})",
:line => arrow_tok.line,
:column => arrow_tok.column,
:token => arrow_tok,
Expand Down
74 changes: 37 additions & 37 deletions spec/puppet-lint/plugins/check_whitespace/arrow_alignment_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe 'arrow_alignment' do
let(:msg) { 'indentation of => is not properly aligned' }
let(:msg) { 'indentation of => is not properly aligned (expected in column %d, but found it in column %d)' }

context 'with fix disabled' do
context 'selectors inside a resource' do
Expand Down Expand Up @@ -119,10 +119,10 @@ class { 'lvs::base':
end

it 'should create four warnings' do
expect(problems).to contain_warning(msg).on_line(3).in_column(15)
expect(problems).to contain_warning(msg).on_line(4).in_column(15)
expect(problems).to contain_warning(msg).on_line(6).in_column(16)
expect(problems).to contain_warning(msg).on_line(7).in_column(15)
expect(problems).to contain_warning(sprintf(msg,17,15)).on_line(3).in_column(15)
expect(problems).to contain_warning(sprintf(msg,17,15)).on_line(4).in_column(15)
expect(problems).to contain_warning(sprintf(msg,17,16)).on_line(6).in_column(16)
expect(problems).to contain_warning(sprintf(msg,17,15)).on_line(7).in_column(15)
end
end

Expand All @@ -142,10 +142,10 @@ class { 'lvs::base':
end

it 'should create four warnings' do
expect(problems).to contain_warning(msg).on_line(3).in_column(15)
expect(problems).to contain_warning(msg).on_line(4).in_column(15)
expect(problems).to contain_warning(msg).on_line(6).in_column(16)
expect(problems).to contain_warning(msg).on_line(7).in_column(15)
expect(problems).to contain_warning(sprintf(msg,17,15)).on_line(3).in_column(15)
expect(problems).to contain_warning(sprintf(msg,17,15)).on_line(4).in_column(15)
expect(problems).to contain_warning(sprintf(msg,17,16)).on_line(6).in_column(16)
expect(problems).to contain_warning(sprintf(msg,17,15)).on_line(7).in_column(15)
end
end
context 'complex resource with a misaligned =>' do
Expand All @@ -166,9 +166,9 @@ class { 'lvs::base':
end

it 'should create three warnings' do
expect(problems).to contain_warning(msg).on_line(3).in_column(15)
expect(problems).to contain_warning(msg).on_line(6).in_column(17)
expect(problems).to contain_warning(msg).on_line(9).in_column(15)
expect(problems).to contain_warning(sprintf(msg,16,15)).on_line(3).in_column(15)
expect(problems).to contain_warning(sprintf(msg,19,17)).on_line(6).in_column(17)
expect(problems).to contain_warning(sprintf(msg,16,15)).on_line(9).in_column(15)
end
end

Expand All @@ -189,7 +189,7 @@ class { 'lvs::base':
end

it 'should create a warning' do
expect(problems).to contain_warning(msg).on_line(8).in_column(17)
expect(problems).to contain_warning(sprintf(msg,19,17)).on_line(8).in_column(17)
end
end

Expand All @@ -214,10 +214,10 @@ class { 'lvs::base':
end

it 'should create a warning' do
expect(problems).to contain_warning(msg).on_line(5).in_column(19)
expect(problems).to contain_warning(msg).on_line(6).in_column(18)
expect(problems).to contain_warning(msg).on_line(11).in_column(19)
expect(problems).to contain_warning(msg).on_line(12).in_column(18)
expect(problems).to contain_warning(sprintf(msg,20,19)).on_line(5).in_column(19)
expect(problems).to contain_warning(sprintf(msg,20,18)).on_line(6).in_column(18)
expect(problems).to contain_warning(sprintf(msg,20,19)).on_line(11).in_column(19)
expect(problems).to contain_warning(sprintf(msg,20,18)).on_line(12).in_column(18)
end
end

Expand Down Expand Up @@ -282,8 +282,8 @@ class { 'lvs::base':
end

it 'should create 2 warnings' do
expect(problems).to contain_warning(msg).on_line(3).in_column(19)
expect(problems).to contain_warning(msg).on_line(4).in_column(19)
expect(problems).to contain_warning(sprintf(msg,18,19)).on_line(3).in_column(19)
expect(problems).to contain_warning(sprintf(msg,18,19)).on_line(4).in_column(19)
end
end

Expand Down Expand Up @@ -314,8 +314,8 @@ class { 'lvs::base':
end

it 'should create 2 warnings' do
expect(problems).to contain_warning(msg).on_line(3).in_column(13)
expect(problems).to contain_warning(msg).on_line(3).in_column(26)
expect(problems).to contain_warning(sprintf(msg,15,13)).on_line(3).in_column(13)
expect(problems).to contain_warning(sprintf(msg,15,26)).on_line(3).in_column(26)
end
end

Expand Down Expand Up @@ -368,10 +368,10 @@ class { 'lvs::base':
end

it 'should fix the manifest' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(15)
expect(problems).to contain_fixed(msg).on_line(4).in_column(15)
expect(problems).to contain_fixed(msg).on_line(6).in_column(16)
expect(problems).to contain_fixed(msg).on_line(7).in_column(15)
expect(problems).to contain_fixed(sprintf(msg,17,15)).on_line(3).in_column(15)
expect(problems).to contain_fixed(sprintf(msg,17,15)).on_line(4).in_column(15)
expect(problems).to contain_fixed(sprintf(msg,17,16)).on_line(6).in_column(16)
expect(problems).to contain_fixed(sprintf(msg,17,15)).on_line(7).in_column(15)
end

it 'should align the arrows' do
Expand Down Expand Up @@ -408,9 +408,9 @@ class { 'lvs::base':
end

it 'should fix the manifest' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(15)
expect(problems).to contain_fixed(msg).on_line(6).in_column(17)
expect(problems).to contain_fixed(msg).on_line(9).in_column(15)
expect(problems).to contain_fixed(sprintf(msg,16,15)).on_line(3).in_column(15)
expect(problems).to contain_fixed(sprintf(msg,19,17)).on_line(6).in_column(17)
expect(problems).to contain_fixed(sprintf(msg,16,15)).on_line(9).in_column(15)
end

it 'should align the arrows' do
Expand Down Expand Up @@ -445,7 +445,7 @@ class { 'lvs::base':
end

it 'should fix the manifest' do
expect(problems).to contain_fixed(msg).on_line(8).in_column(17)
expect(problems).to contain_fixed(sprintf(msg,19,17)).on_line(8).in_column(17)
end

it 'should align the arrows' do
Expand Down Expand Up @@ -473,8 +473,8 @@ class { 'lvs::base':
end

it 'should create 2 warnings' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(19)
expect(problems).to contain_fixed(msg).on_line(4).in_column(19)
expect(problems).to contain_fixed(sprintf(msg,18,19)).on_line(3).in_column(19)
expect(problems).to contain_fixed(sprintf(msg,18,19)).on_line(4).in_column(19)
end

it 'should realign the arrows with the minimum whitespace' do
Expand Down Expand Up @@ -502,7 +502,7 @@ class { 'lvs::base':
end

it 'should fix the problem' do
expect(problems).to contain_fixed(msg).on_line(4).in_column(17)
expect(problems).to contain_fixed(sprintf(msg,18,17)).on_line(4).in_column(17)
end

it 'should add whitespace between the param and the arrow' do
Expand Down Expand Up @@ -531,8 +531,8 @@ class { 'lvs::base':
end

it 'should fix 2 problems' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(13)
expect(problems).to contain_fixed(msg).on_line(3).in_column(26)
expect(problems).to contain_fixed(sprintf(msg,15,13)).on_line(3).in_column(13)
expect(problems).to contain_fixed(sprintf(msg,15,26)).on_line(3).in_column(26)
end

it 'should move the extra param onto its own line and realign' do
Expand Down Expand Up @@ -561,9 +561,9 @@ class { 'lvs::base':
end

it 'should fix 2 problems' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(13)
expect(problems).to contain_fixed(msg).on_line(3).in_column(29)
expect(problems).to contain_fixed(msg).on_line(4).in_column(15)
expect(problems).to contain_fixed(sprintf(msg,17,13)).on_line(3).in_column(13)
expect(problems).to contain_fixed(sprintf(msg,17,29)).on_line(3).in_column(29)
expect(problems).to contain_fixed(sprintf(msg,17,15)).on_line(4).in_column(15)
end

it 'should move the extra param onto its own line and realign' do
Expand Down

0 comments on commit 2544db8

Please sign in to comment.