diff options
Diffstat (limited to 'lib/puppet/parser')
26 files changed, 59 insertions, 175 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| diff --git a/lib/puppet/parser/collector.rb b/lib/puppet/parser/collector.rb index 3f1432af2..d2b993017 100644 --- a/lib/puppet/parser/collector.rb +++ b/lib/puppet/parser/collector.rb @@ -24,9 +24,7 @@ class Puppet::Parser::Collector objects = send(method).each do |obj| obj.virtual = false end - if objects.empty? - return false - end + return false if objects.empty? end # we have an override for the collected resources @@ -86,9 +84,7 @@ class Puppet::Parser::Collector # add a resource override to the soon to be exported/realized resources def add_override(hash) - unless hash[:parameters] - raise ArgumentError, "Exported resource try to override without parameters" - end + raise ArgumentError, "Exported resource try to override without parameters" unless hash[:parameters] # schedule an override for an upcoming collection @overrides = hash @@ -160,9 +156,7 @@ class Puppet::Parser::Collector end def collect_resources - unless @resources.is_a?(Array) - @resources = [@resources] - end + @resources = [@resources] unless @resources.is_a?(Array) method = "collect_#{form.to_s}_resources" send(method) end @@ -186,9 +180,7 @@ class Puppet::Parser::Collector # If there are no more resources to find, delete this from the list # of collections. - if @resources.empty? - @scope.compiler.delete_collection(self) - end + @scope.compiler.delete_collection(self) if @resources.empty? return result end diff --git a/lib/puppet/parser/compiler.rb b/lib/puppet/parser/compiler.rb index a2186b2c9..121dae1b1 100644 --- a/lib/puppet/parser/compiler.rb +++ b/lib/puppet/parser/compiler.rb @@ -61,9 +61,7 @@ class Puppet::Parser::Compiler return if resource.type.to_s.downcase == "stage" if resource.type.to_s.downcase != "class" - if resource[:stage] - raise ArgumentError, "Only classes can set 'stage'; normal resources like #{resource} cannot change run stage" - end + raise ArgumentError, "Only classes can set 'stage'; normal resources like #{resource} cannot change run stage" if resource[:stage] return @catalog.add_edge(scope.resource, resource) end @@ -142,9 +140,7 @@ class Puppet::Parser::Compiler # creates resource objects that point back to the classes, and then the # resources are themselves evaluated later in the process. def evaluate_classes(classes, scope, lazy_evaluate = true) - unless scope.source - raise Puppet::DevError, "No source for scope passed to evaluate_classes" - end + raise Puppet::DevError, "No source for scope passed to evaluate_classes" unless scope.source found = [] classes.each do |name| # If we can find the class, then make a resource that will evaluate it. @@ -354,9 +350,7 @@ class Puppet::Parser::Compiler end end - unless remaining.empty? - raise Puppet::ParseError, "Failed to realize virtual resources #{remaining.join(', ')}" - end + raise Puppet::ParseError, "Failed to realize virtual resources #{remaining.join(', ')}" unless remaining.empty? end # Make sure all of our resources and such have done any last work diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb index 5b07a9c09..c86548bfb 100644 --- a/lib/puppet/parser/functions.rb +++ b/lib/puppet/parser/functions.rb @@ -40,9 +40,7 @@ module Puppet::Parser::Functions def self.newfunction(name, options = {}, &block) name = symbolize(name) - if functions.include?(name) - raise Puppet::DevError, "Function #{name} already defined" - end + raise Puppet::DevError, "Function #{name} already defined" if functions.include?(name) ftype = options[:type] || :statement @@ -56,18 +54,14 @@ module Puppet::Parser::Functions # Someday we'll support specifying an arity, but for now, nope #functions[name] = {:arity => arity, :type => ftype} functions[name] = {:type => ftype, :name => fname} - if options[:doc] - functions[name][:doc] = options[:doc] - end + functions[name][:doc] = options[:doc] if options[:doc] end # Remove a function added by newfunction def self.rmfunction(name) name = symbolize(name) - unless functions.include? name - raise Puppet::DevError, "Function #{name} is not defined" - end + raise Puppet::DevError, "Function #{name} is not defined" unless functions.include? name functions.delete name diff --git a/lib/puppet/parser/functions/generate.rb b/lib/puppet/parser/functions/generate.rb index cf46775ab..8430f03a6 100644 --- a/lib/puppet/parser/functions/generate.rb +++ b/lib/puppet/parser/functions/generate.rb @@ -11,9 +11,7 @@ Puppet::Parser::Functions::newfunction(:generate, :type => :rvalue, generators, so all shell metacharacters are passed directly to the generator.") do |args| - unless args[0] =~ /^#{File::SEPARATOR}/ - raise Puppet::ParseError, "Generators must be fully qualified" - end + raise Puppet::ParseError, "Generators must be fully qualified" unless args[0] =~ /^#{File::SEPARATOR}/ unless args[0] =~ /^[-#{File::SEPARATOR}\w.]+$/ raise Puppet::ParseError, diff --git a/lib/puppet/parser/functions/include.rb b/lib/puppet/parser/functions/include.rb index a8b6f175b..d1bafa54a 100644 --- a/lib/puppet/parser/functions/include.rb +++ b/lib/puppet/parser/functions/include.rb @@ -12,9 +12,7 @@ Puppet::Parser::Functions::newfunction(:include, :doc => "Evaluate one or more c unless missing.empty? # Throw an error if we didn't evaluate all of the classes. str = "Could not find class" - if missing.length > 1 - str += "es" - end + str += "es" if missing.length > 1 str += " " + missing.join(", ") diff --git a/lib/puppet/parser/functions/shellquote.rb b/lib/puppet/parser/functions/shellquote.rb index 0a7ae5958..96feaa1ee 100644 --- a/lib/puppet/parser/functions/shellquote.rb +++ b/lib/puppet/parser/functions/shellquote.rb @@ -26,9 +26,7 @@ module Puppet::Parser::Functions else r = '"' word.each_byte() do |c| - if Dangerous.include?(c) - r += "\\" - end + r += "\\" if Dangerous.include?(c) r += c.chr() end r += '"' diff --git a/lib/puppet/parser/functions/split.rb b/lib/puppet/parser/functions/split.rb index c3466ba4a..09caa18aa 100644 --- a/lib/puppet/parser/functions/split.rb +++ b/lib/puppet/parser/functions/split.rb @@ -22,9 +22,7 @@ a regexp meta-character (.), and that needs protection. A simple way to do that for a single character is to enclose it in square brackets.") do |args| - if args.length != 2 - raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") - end + raise Puppet::ParseError, ("split(): wrong number of arguments (#{args.length}; must be 2)") if args.length != 2 return args[0].split(Regexp.compile(args[1])) end diff --git a/lib/puppet/parser/functions/sprintf.rb b/lib/puppet/parser/functions/sprintf.rb index 4a53a9736..4a3916c89 100644 --- a/lib/puppet/parser/functions/sprintf.rb +++ b/lib/puppet/parser/functions/sprintf.rb @@ -6,9 +6,7 @@ module Puppet::Parser::Functions :doc => "Perform printf-style formatting of text. The first parameter is format string describing how the rest of the parameters should be formatted. See the documentation for the ``Kernel::sprintf()`` function in Ruby for all the details.") do |args| - if args.length < 1 - raise Puppet::ParseError, 'sprintf() needs at least one argument' - end + raise Puppet::ParseError, 'sprintf() needs at least one argument' if args.length < 1 fmt = args.shift() return sprintf(fmt, *args) end diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index c08b1a31a..9fa8f5069 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -153,16 +153,12 @@ namestring: name resource: classname LBRACE resourceinstances endsemi RBRACE { @lexer.commentpop array = val[2] - if array.instance_of?(AST::ResourceInstance) - array = [array] - end + array = [array] if array.instance_of?(AST::ResourceInstance) result = ast AST::ASTArray # this iterates across each specified resourceinstance array.each { |instance| - unless instance.instance_of?(AST::ResourceInstance) - raise Puppet::Dev, "Got something that isn't an instance" - end + raise Puppet::Dev, "Got something that isn't an instance" unless instance.instance_of?(AST::ResourceInstance) # now, i need to somehow differentiate between those things with # arrays in their names, and normal things @@ -197,9 +193,7 @@ virtualresource: at resource { Puppet.warning addcontext("You cannot collect without storeconfigs being set") end - if val[1].is_a? AST::ResourceDefaults - error "Defaults are not virtualizable" - end + error "Defaults are not virtualizable" if val[1].is_a? AST::ResourceDefaults method = type.to_s + "=" @@ -222,9 +216,7 @@ at: AT { result = :virtual } # will, I assume. collection: classref collectrhand LBRACE anyparams endcomma RBRACE { @lexer.commentpop - if val[0] =~ /^[a-z]/ - Puppet.warning addcontext("Collection names must now be capitalized") - end + Puppet.warning addcontext("Collection names must now be capitalized") if val[0] =~ /^[a-z]/ type = val[0].downcase args = {:type => type} @@ -348,9 +340,7 @@ resourcename: quotedtext | hasharrayaccesses assignment: VARIABLE EQUALS expression { - if val[0][:value] =~ /::/ - raise Puppet::ParseError, "Cannot assign to variables in other namespaces" - end + raise Puppet::ParseError, "Cannot assign to variables in other namespaces" if val[0][:value] =~ /::/ # this is distinct from referencing a variable variable = ast AST::Name, :value => val[0][:value], :line => val[0][:line] result = ast AST::VarDef, :name => variable, :value => val[2], :line => val[0][:line] @@ -477,9 +467,7 @@ ifstatement: expression LBRACE statements RBRACE else { :statements => val[2] } - if val[4] - args[:else] = val[4] - end + args[:else] = val[4] if val[4] result = ast AST::IfStatement, args } @@ -490,9 +478,7 @@ ifstatement: expression LBRACE statements RBRACE else { :statements => ast(AST::Nop) } - if val[3] - args[:else] = val[3] - end + args[:else] = val[3] if val[3] result = ast AST::IfStatement, args } @@ -587,9 +573,7 @@ expression: rvalue casestatement: CASE rvalue LBRACE caseopts RBRACE { @lexer.commentpop options = val[3] - unless options.instance_of?(AST::ASTArray) - options = ast AST::ASTArray, :children => [val[3]] - end + options = ast AST::ASTArray, :children => [val[3]] unless options.instance_of?(AST::ASTArray) result = ast AST::CaseStatement, :test => val[1], :options => options } diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index f2fd710cf..e63483050 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -74,9 +74,7 @@ class Puppet::Parser::Parser end except = Puppet::ParseError.new(message) except.line = @lexer.line - if @lexer.file - except.file = @lexer.file - end + except.file = @lexer.file if @lexer.file raise except end @@ -90,9 +88,7 @@ class Puppet::Parser::Parser unless file =~ /\.pp$/ file = file + ".pp" end - unless FileTest.exist?(file) - raise Puppet::Error, "Could not find file #{file}" - end + raise Puppet::Error, "Could not find file #{file}" unless FileTest.exist?(file) end raise Puppet::AlreadyImportedError, "Import loop detected" if known_resource_types.watching_file?(file) @@ -171,9 +167,7 @@ class Puppet::Parser::Parser except = Puppet::ParseError.new(error) except.line = @lexer.line - if @lexer.file - except.file = @lexer.file - end + except.file = @lexer.file if @lexer.file raise except end @@ -181,9 +175,7 @@ class Puppet::Parser::Parser # how should I do error handling here? def parse(string = nil) return parse_ruby_file if self.file =~ /\.rb$/ - if string - self.string = string - end + self.string = string if string begin @yydebug = false main = yyparse(@lexer,:scan) diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb index 257440ab4..e29beeb95 100644 --- a/lib/puppet/parser/resource.rb +++ b/lib/puppet/parser/resource.rb @@ -27,9 +27,7 @@ class Puppet::Parser::Resource < Puppet::Resource # Determine whether the provided parameter name is a relationship parameter. def self.relationship_parameter?(name) - unless defined?(@relationship_names) - @relationship_names = Puppet::Type.relationship_params.collect { |p| p.name } - end + @relationship_names = Puppet::Type.relationship_params.collect { |p| p.name } unless defined?(@relationship_names) @relationship_names.include?(name) end @@ -110,9 +108,7 @@ class Puppet::Parser::Resource < Puppet::Resource def initialize(*args) super - unless scope - raise ArgumentError, "Resources require a scope" - end + raise ArgumentError, "Resources require a scope" unless scope @source ||= scope.source end @@ -179,9 +175,7 @@ class Puppet::Parser::Resource < Puppet::Resource @parameters.inject({}) do |hash, ary| param = ary[1] # Skip "undef" values. - if param.value != :undef - hash[param.name] = param.value - end + hash[param.name] = param.value if param.value != :undef hash end end @@ -198,13 +192,9 @@ class Puppet::Parser::Resource < Puppet::Resource v = Puppet::Resource.new(v.type, v.title) elsif v.is_a?(Array) # flatten resource references arrays - if v.flatten.find { |av| av.is_a?(Puppet::Resource) } - v = v.flatten - end + v = v.flatten if v.flatten.find { |av| av.is_a?(Puppet::Resource) } v = v.collect do |av| - if av.is_a?(Puppet::Resource) - av = Puppet::Resource.new(av.type, av.title) - end + av = Puppet::Resource.new(av.type, av.title) if av.is_a?(Puppet::Resource) av end end @@ -287,9 +277,7 @@ class Puppet::Parser::Resource < Puppet::Resource unless param.source.child_of?(current.source) puts caller if Puppet[:trace] msg = "Parameter '#{param.name}' is already set on #{self}" - if current.source.to_s != "" - msg += " by #{current.source}" - end + msg += " by #{current.source}" if current.source.to_s != "" if current.file or current.line fields = [] fields << current.file if current.file @@ -330,9 +318,7 @@ class Puppet::Parser::Resource < Puppet::Resource def extract_parameters(params) params.each do |param| # Don't set the same parameter twice - if @parameters[param.name] - self.fail Puppet::ParseError, "Duplicate parameter '#{param.name}' for on #{self}" - end + self.fail Puppet::ParseError, "Duplicate parameter '#{param.name}' for on #{self}" if @parameters[param.name] set_parameter(param) end diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index 02dd3e733..5a0dbfeba 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -74,9 +74,7 @@ class Puppet::Parser::Scope # Is the value a number?, return the correct object or nil if not a number def self.number?(value) - unless value.is_a?(Fixnum) or value.is_a?(Bignum) or value.is_a?(Float) or value.is_a?(String) - return nil - end + return nil unless value.is_a?(Fixnum) or value.is_a?(Bignum) or value.is_a?(Float) or value.is_a?(String) if value.is_a?(String) if value =~ /^-?\d+(:?\.\d+|(:?\.\d+)?e\d+)$/ @@ -267,13 +265,11 @@ class Puppet::Parser::Scope # by default) including the values defined in our parent. Local values # shadow parent values. def to_hash(recursive = true) - if recursive and parent then - target = parent.to_hash(recursive) - end + target = parent.to_hash(recursive) if recursive and parent target ||= Hash.new @symtable.keys.each { |name| value = @symtable[name] - if value == :undef then + if value == :undef target.delete(name) else target[name] = value @@ -339,12 +335,8 @@ class Puppet::Parser::Scope else error = Puppet::ParseError.new("Cannot append, variable #{name} is defined in this scope") end - if options[:file] - error.file = options[:file] - end - if options[:line] - error.line = options[:line] - end + error.file = options[:file] if options[:file] + error.line = options[:line] if options[:line] raise error end @@ -399,12 +391,8 @@ class Puppet::Parser::Scope out << '$' else str = "Unrecognised escape sequence '#{ss.matched}'" - if file - str += " in file #{file}" - end - if line - str += " at line #{line}" - end + str += " in file #{file}" if file + str += " at line #{line}" if line Puppet.warning str out << ss.matched end @@ -444,9 +432,7 @@ class Puppet::Parser::Scope # Undefine a variable; only used for testing. def unsetvar(var) table = ephemeral?(var) ? @ephemeral.last : @symtable - if table.include?(var) - table.delete(var) - end + table.delete(var) if table.include?(var) end # remove ephemeral scope up to level diff --git a/lib/puppet/parser/type_loader.rb b/lib/puppet/parser/type_loader.rb index e0b4143fc..24411522b 100644 --- a/lib/puppet/parser/type_loader.rb +++ b/lib/puppet/parser/type_loader.rb @@ -102,9 +102,7 @@ class Puppet::Parser::TypeLoader fullname = (namespace + "::#{name}").sub(/^::/, '') # Try to load the module init file if we're a qualified name - if fullname.include?("::") - names_to_try << fullname.split("::")[0] - end + names_to_try << fullname.split("::")[0] if fullname.include?("::") # Then the fully qualified name names_to_try << fullname diff --git a/lib/puppet/parser/yaml_trimmer.rb b/lib/puppet/parser/yaml_trimmer.rb index 14064c8e6..09159e38f 100644 --- a/lib/puppet/parser/yaml_trimmer.rb +++ b/lib/puppet/parser/yaml_trimmer.rb @@ -3,9 +3,7 @@ module Puppet::Parser::YamlTrimmer def to_yaml_properties r = instance_variables - REMOVE - if respond_to?(:skip_for_yaml) - r -= skip_for_yaml() - end + r -= skip_for_yaml() if respond_to?(:skip_for_yaml) r end end |