From b918a193de16f9b1c88687ccfab91664f975f1ab Mon Sep 17 00:00:00 2001 From: Jacob Helwig Date: Thu, 21 Jun 2018 14:45:50 -0700 Subject: Apply automatic PDK validation cleanup --- spec/lib/puppet_spec/compiler.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'spec/lib') diff --git a/spec/lib/puppet_spec/compiler.rb b/spec/lib/puppet_spec/compiler.rb index 8964a26..c3d33a5 100644 --- a/spec/lib/puppet_spec/compiler.rb +++ b/spec/lib/puppet_spec/compiler.rb @@ -34,8 +34,8 @@ module PuppetSpec::Compiler catalog.resources.each { |res| yield res } end transaction = Puppet::Transaction.new(catalog, - Puppet::Transaction::Report.new, - prioritizer) + Puppet::Transaction::Report.new, + prioritizer) transaction.evaluate transaction.report.finalize_report @@ -70,7 +70,7 @@ module PuppetSpec::Compiler collect_notices(code, node) do |compiler| unless topscope_vars.empty? scope = compiler.topscope - topscope_vars.each {|k,v| scope.setvar(k, v) } + topscope_vars.each { |k, v| scope.setvar(k, v) } end if block_given? compiler.compile do |catalog| @@ -95,7 +95,7 @@ module PuppetSpec::Compiler compiler = Puppet::Parser::Compiler.new(node) unless variables.empty? scope = compiler.topscope - variables.each {|k,v| scope.setvar(k, v) } + variables.each { |k, v| scope.setvar(k, v) } end if source.nil? @@ -105,7 +105,7 @@ module PuppetSpec::Compiler end # evaluate given source is the context of the compiled state and return its result - compiler.compile do |catalog | + compiler.compile do |_catalog| Puppet::Pops::Parser::EvaluatingParser.singleton.evaluate_string(compiler.topscope, source, source_location) end end -- cgit v1.2.3 From 0c845b50fba49390189b147eaf3269c078045c36 Mon Sep 17 00:00:00 2001 From: Jacob Helwig Date: Mon, 25 Jun 2018 11:21:24 -0700 Subject: Remove Rubocop Performance/Caller violation Turns out that using `caller(n..n).first` is _significantly_ faster than `caller[n]`. --- spec/lib/puppet_spec/compiler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/lib') diff --git a/spec/lib/puppet_spec/compiler.rb b/spec/lib/puppet_spec/compiler.rb index c3d33a5..49a6534 100644 --- a/spec/lib/puppet_spec/compiler.rb +++ b/spec/lib/puppet_spec/compiler.rb @@ -90,7 +90,7 @@ module PuppetSpec::Compiler # (Parameters given by name) # def evaluate(code: 'undef', source: nil, node: Puppet::Node.new('testnode'), variables: {}) - source_location = caller[0] + source_location = caller(0..0).first Puppet[:code] = code compiler = Puppet::Parser::Compiler.new(node) unless variables.empty? -- cgit v1.2.3