From 855f3bba8bb1c29ea1ec2dae471c90bec7786f01 Mon Sep 17 00:00:00 2001 From: Bobosila Victor Date: Fri, 24 Sep 2021 13:26:47 +0300 Subject: (MODULES-11197) Rubocop fixes --- .rubocop.yml | 4 ++-- lib/puppet/provider/augeas/augeas.rb | 16 ++++++++-------- lib/puppet/type/augeas.rb | 3 ++- spec/unit/provider/augeas/augeas_spec.rb | 10 +++++----- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8a8251f..ac0ebd8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -73,7 +73,7 @@ Style/SymbolArray: EnforcedStyle: brackets Style/SignalException: Enabled: false -Layout/IndentHeredoc: +Layout/HeredocIndentation: Enabled: false Metrics/BlockNesting: Enabled: false @@ -89,7 +89,7 @@ Style/NumericPredicate: Enabled: false Style/PredicateName: Enabled: false -Style/VariableName: +RSpec/VariableName: Enabled: false RSpec/MessageSpies: EnforcedStyle: receive diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb index 8ab6e7a..8a306db 100644 --- a/lib/puppet/provider/augeas/augeas.rb +++ b/lib/puppet/provider/augeas/augeas.rb @@ -95,17 +95,17 @@ Puppet::Type.type(:augeas).provide(:augeas) do if f == :path start = sc.pos nbracket = 0 - inSingleTick = false - inDoubleTick = false + in_single_tick = false + in_double_tick = false loop do sc.skip(%r{([^\]\[\s\\'"]|\\.)+}) ch = sc.getch nbracket += 1 if ch == '[' nbracket -= 1 if ch == ']' - inSingleTick = !inSingleTick if ch == "'" - inDoubleTick = !inDoubleTick if ch == '"' + in_single_tick = !in_single_tick if ch == "'" + in_double_tick = !in_double_tick if ch == '"' raise(_('unmatched [')) if nbracket < 0 - break if (nbracket == 0 && !inSingleTick && !inDoubleTick && (ch =~ %r{\s})) || sc.eos? + break if (nbracket == 0 && !in_single_tick && !in_double_tick && (ch =~ %r{\s})) || sc.eos? end len = sc.pos - start len -= 1 unless sc.eos? @@ -209,7 +209,7 @@ Puppet::Type.type(:augeas).provide(:augeas) do @aug = nil end - def is_numeric?(s) + def numeric?(s) case s when Integer true @@ -236,8 +236,8 @@ Puppet::Type.type(:augeas).provide(:augeas) do # check the value in augeas result = @aug.get(path) || '' - if ['<', '<=', '>=', '>'].include?(comparator) && is_numeric?(result) && - is_numeric?(arg) + if ['<', '<=', '>=', '>'].include?(comparator) && numeric?(result) && + numeric?(arg) resultf = result.to_f argf = arg.to_f return_value = resultf.send(comparator, argf) diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb index 37683a2..2303fdc 100644 --- a/lib/puppet/type/augeas.rb +++ b/lib/puppet/type/augeas.rb @@ -129,7 +129,8 @@ Puppet::Type.newtype(:augeas) do end newparam(:load_path) do - desc "Optional colon-separated list or array of directories; these directories are searched for schema definitions. The agent's `$libdir/augeas/lenses` path will always be added to support pluginsync." + desc "Optional colon-separated list or array of directories; these directories are searched for schema definitions. + The agent's `$libdir/augeas/lenses` path will always be added to support pluginsync." defaultto '' end diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb index 71d7c60..4750e7e 100644 --- a/spec/unit/provider/augeas/augeas_spec.rb +++ b/spec/unit/provider/augeas/augeas_spec.rb @@ -475,19 +475,19 @@ describe Puppet::Type.type(:augeas).provider(:augeas) do end describe 'performing is_numeric checks (#22617)' do it 'returns false for nil' do - expect(provider.is_numeric?(nil)).to eq(false) + expect(provider.numeric?(nil)).to eq(false) end it 'returns true for Integers' do - expect(provider.is_numeric?(9)).to eq(true) + expect(provider.numeric?(9)).to eq(true) end it 'returns true for numbers in Strings' do - expect(provider.is_numeric?('9')).to eq(true) + expect(provider.numeric?('9')).to eq(true) end it 'returns false for non-number Strings' do - expect(provider.is_numeric?('x9')).to eq(false) + expect(provider.numeric?('x9')).to eq(false) end it 'returns false for other types' do - expect(provider.is_numeric?([true])).to eq(false) + expect(provider.numeric?([true])).to eq(false) end end -- cgit v1.2.3