Skip to content

Commit

Permalink
Merge pull request #151 from vStone/feature/150_class_inherits_from_p…
Browse files Browse the repository at this point in the history
…arams_class_exception

Fixes #150 class inherits from params class exception
  • Loading branch information
timtim123456 committed Sep 26, 2012
2 parents a8cb2d1 + 886f05b commit 836a148
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/puppet-lint/plugins/check_classes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PuppetLint::Plugins::CheckClasses < PuppetLint::CheckPlugin
class_tokens = tokens[class_idx[:start]..class_idx[:end]]
inherits_idx = class_tokens.index { |r| r.type == :INHERITS }
unless inherits_idx.nil?
inherited_class_token = tokens[inherits_idx].next_code_token
inherited_class_token = class_tokens[inherits_idx].next_code_token
if inherited_class_token.value.end_with? '::params'
notify :warning, {
:message => 'class inheriting from params class',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

describe 'class_inherits_from_params_class' do
describe 'parameterised class that inherits from a params class' do
let(:code) { "class foo($bar = $name) inherits foo::params { }" }
let(:code) { "
# commented
class foo($bar = $name) inherits foo::params { }"
}

its(:problems) {
should have_problem({
:kind => :warning,
:message => "class inheriting from params class",
:linenumber => 1,
:column => 34,
:linenumber => 3,
:column => 40,
})
should_not have_problem :kind => :error
}
Expand Down

0 comments on commit 836a148

Please sign in to comment.