diff options
Diffstat (limited to 'lib/puppet/parser/ast')
-rw-r--r-- | lib/puppet/parser/ast/arithmetic_operator.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/boolean_operator.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/branch.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/caseopt.rb | 12 | ||||
-rw-r--r-- | lib/puppet/parser/ast/collexpr.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/comparison_operator.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/function.rb | 8 | ||||
-rw-r--r-- | lib/puppet/parser/ast/in_operator.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/leaf.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/match_operator.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/resource.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/selector.rb | 4 |
12 files changed, 15 insertions, 45 deletions
diff --git a/lib/puppet/parser/ast/arithmetic_operator.rb b/lib/puppet/parser/ast/arithmetic_operator.rb index b4c0215cc..6b9a6018c 100644 --- a/lib/puppet/parser/ast/arithmetic_operator.rb +++ b/lib/puppet/parser/ast/arithmetic_operator.rb @@ -33,9 +33,7 @@ class Puppet::Parser::AST def initialize(hash) super - unless %w{+ - * / << >>}.include?(@operator) - raise ArgumentError, "Invalid arithmetic operator #{@operator}" - end + raise ArgumentError, "Invalid arithmetic operator #{@operator}" unless %w{+ - * / << >>}.include?(@operator) end end end diff --git a/lib/puppet/parser/ast/boolean_operator.rb b/lib/puppet/parser/ast/boolean_operator.rb index 9214afbd5..0f7e21d2c 100644 --- a/lib/puppet/parser/ast/boolean_operator.rb +++ b/lib/puppet/parser/ast/boolean_operator.rb @@ -40,9 +40,7 @@ class Puppet::Parser::AST def initialize(hash) super - unless %w{and or}.include?(@operator) - raise ArgumentError, "Invalid boolean operator #{@operator}" - end + raise ArgumentError, "Invalid boolean operator #{@operator}" unless %w{and or}.include?(@operator) end end end diff --git a/lib/puppet/parser/ast/branch.rb b/lib/puppet/parser/ast/branch.rb index c0fa0da30..0be6ca018 100644 --- a/lib/puppet/parser/ast/branch.rb +++ b/lib/puppet/parser/ast/branch.rb @@ -23,9 +23,7 @@ class Puppet::Parser::AST super(arghash) # Create the hash, if it was not set at initialization time. - unless defined?(@children) - @children = [] - end + @children = [] unless defined?(@children) # Verify that we only got valid AST nodes. @children.each { |child| diff --git a/lib/puppet/parser/ast/caseopt.rb b/lib/puppet/parser/ast/caseopt.rb index 51a82c5c0..1268aa7b9 100644 --- a/lib/puppet/parser/ast/caseopt.rb +++ b/lib/puppet/parser/ast/caseopt.rb @@ -16,9 +16,7 @@ class Puppet::Parser::AST # Are we the default option? def default? # Cache the @default value. - if defined?(@default) - return @default - end + return @default if defined?(@default) if @value.is_a?(AST::ASTArray) @value.each { |subval| @@ -28,14 +26,10 @@ class Puppet::Parser::AST end } else - if @value.is_a?(AST::Default) - @default = true - end + @default = true if @value.is_a?(AST::Default) end - unless defined?(@default) - @default = false - end + @default = false unless defined?(@default) return @default end diff --git a/lib/puppet/parser/ast/collexpr.rb b/lib/puppet/parser/ast/collexpr.rb index 95fb5a94f..f71b53d46 100644 --- a/lib/puppet/parser/ast/collexpr.rb +++ b/lib/puppet/parser/ast/collexpr.rb @@ -80,9 +80,7 @@ class CollExpr < AST::Branch def initialize(hash = {}) super - unless %w{== != and or}.include?(@oper) - raise ArgumentError, "Invalid operator #{@oper}" - end + raise ArgumentError, "Invalid operator #{@oper}" unless %w{== != and or}.include?(@oper) end end end diff --git a/lib/puppet/parser/ast/comparison_operator.rb b/lib/puppet/parser/ast/comparison_operator.rb index 85903ec31..e8b21d45f 100644 --- a/lib/puppet/parser/ast/comparison_operator.rb +++ b/lib/puppet/parser/ast/comparison_operator.rb @@ -33,9 +33,7 @@ class Puppet::Parser::AST def initialize(hash) super - unless %w{== != < > <= >=}.include?(@operator) - raise ArgumentError, "Invalid comparison operator #{@operator}" - end + raise ArgumentError, "Invalid comparison operator #{@operator}" unless %w{== != < > <= >=}.include?(@operator) end end end diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb index c3769cbd4..79d3d95ed 100644 --- a/lib/puppet/parser/ast/function.rb +++ b/lib/puppet/parser/ast/function.rb @@ -13,16 +13,12 @@ class Puppet::Parser::AST def evaluate(scope) # Make sure it's a defined function - unless Puppet::Parser::Functions.function(@name) - raise Puppet::ParseError, "Unknown function #{@name}" - end + raise Puppet::ParseError, "Unknown function #{@name}" unless Puppet::Parser::Functions.function(@name) # Now check that it's been used correctly case @ftype when :rvalue - unless Puppet::Parser::Functions.rvalue?(@name) - raise Puppet::ParseError, "Function '#{@name}' does not return a value" - end + raise Puppet::ParseError, "Function '#{@name}' does not return a value" unless Puppet::Parser::Functions.rvalue?(@name) when :statement if Puppet::Parser::Functions.rvalue?(@name) raise Puppet::ParseError, diff --git a/lib/puppet/parser/ast/in_operator.rb b/lib/puppet/parser/ast/in_operator.rb index 0f543af9b..05f864edc 100644 --- a/lib/puppet/parser/ast/in_operator.rb +++ b/lib/puppet/parser/ast/in_operator.rb @@ -12,9 +12,7 @@ class Puppet::Parser::AST # evaluate the operands, should return a boolean value lval = @lval.safeevaluate(scope) - unless lval.is_a?(::String) - raise ArgumentError, "'#{lval}' from left operand of 'in' expression is not a string" - end + raise ArgumentError, "'#{lval}' from left operand of 'in' expression is not a string" unless lval.is_a?(::String) rval = @rval.safeevaluate(scope) unless rval.respond_to?(:include?) diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index 6ef346123..666edd66a 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -162,9 +162,7 @@ class Puppet::Parser::AST def evaluate(scope) object = evaluate_container(scope) - unless object.is_a?(Hash) or object.is_a?(Array) - raise Puppet::ParseError, "#{variable} is not an hash or array when accessing it with #{accesskey}" - end + raise Puppet::ParseError, "#{variable} is not an hash or array when accessing it with #{accesskey}" unless object.is_a?(Hash) or object.is_a?(Array) return object[evaluate_key(scope)] end diff --git a/lib/puppet/parser/ast/match_operator.rb b/lib/puppet/parser/ast/match_operator.rb index c528a90e5..9a12351b9 100644 --- a/lib/puppet/parser/ast/match_operator.rb +++ b/lib/puppet/parser/ast/match_operator.rb @@ -23,9 +23,7 @@ class Puppet::Parser::AST def initialize(hash) super - unless %w{!~ =~}.include?(@operator) - raise ArgumentError, "Invalid regexp operator #{@operator}" - end + raise ArgumentError, "Invalid regexp operator #{@operator}" unless %w{!~ =~}.include?(@operator) end end end diff --git a/lib/puppet/parser/ast/resource.rb b/lib/puppet/parser/ast/resource.rb index 5aa11129a..01b9370ff 100644 --- a/lib/puppet/parser/ast/resource.rb +++ b/lib/puppet/parser/ast/resource.rb @@ -21,9 +21,7 @@ class Resource < AST::ResourceReference resource_titles = @title.safeevaluate(scope) # it's easier to always use an array, even for only one name - unless resource_titles.is_a?(Array) - resource_titles = [resource_titles] - end + resource_titles = [resource_titles] unless resource_titles.is_a?(Array) # We want virtual to be true if exported is true. We can't # just set :virtual => self.virtual in the initialization, diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb index 8eb930cc4..cf6b8ac19 100644 --- a/lib/puppet/parser/ast/selector.rb +++ b/lib/puppet/parser/ast/selector.rb @@ -18,9 +18,7 @@ class Puppet::Parser::AST default = nil - unless @values.instance_of? AST::ASTArray or @values.instance_of? Array - @values = [@values] - end + @values = [@values] unless @values.instance_of? AST::ASTArray or @values.instance_of? Array # Then look for a match in the options. @values.each do |obj| |