Skip to content

FixToAccountForVersionChange #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/facter/facter_dot_d.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def initialize(dir = '/etc/facts.d', cache_file = File.join(Puppet[:libdir], 'fa

def entries
Dir.entries(@dir).reject { |f| f =~ %r{^\.|\.ttl$} }.sort.map { |f| File.join(@dir, f) }
rescue # rubocop:disable Lint/RescueWithoutErrorClass
rescue
[]
end

Expand Down Expand Up @@ -113,14 +113,14 @@ def script_parser(file)
def cache_save!
cache = load_cache
File.open(@cache_file, 'w', 0o600) { |f| f.write(YAML.dump(cache)) }
rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass
rescue # rubocop:disable Lint/HandleExceptions
end

def cache_store(file, data)
load_cache

@cache[file] = { :data => data, :stored => Time.now.to_i }
rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass
rescue # rubocop:disable Lint/HandleExceptions
end

def cache_lookup(file)
Expand All @@ -136,15 +136,15 @@ def cache_lookup(file)
return cache[file][:data] if ttl == -1
return cache[file][:data] if (now - cache[file][:stored]) <= ttl
return nil
rescue # rubocop:disable Lint/RescueWithoutErrorClass
rescue
return nil
end

def cache_time(file)
meta = file + '.ttl'

return File.read(meta).chomp.to_i
rescue # rubocop:disable Lint/RescueWithoutErrorClass
rescue
return 0
end

Expand All @@ -156,7 +156,7 @@ def load_cache
end

return @cache
rescue # rubocop:disable Lint/RescueWithoutErrorClass
rescue
@cache = {}
return @cache
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/any2bool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module Puppet::Parser::Functions

valid_float = begin
!!Float(arg) # rubocop:disable Style/DoubleNegation : Could not find a better way to check if a boolean
rescue # rubocop:disable Lint/RescueWithoutErrorClass
rescue
false
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/parser/functions/dig44.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module Puppet::Parser::Functions
if structure.is_a? Array
begin
key = Integer key
rescue # rubocop:disable Lint/RescueWithoutErrorClass
rescue
break
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/puppet/parser/functions/uriescape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ module Puppet::Parser::Functions

result = if value.is_a?(Array)
# Numbers in Puppet are often string-encoded which is troublesome ...
value.map { |i| i.is_a?(String) ? URI.escape(i) : i } # rubocop:disable Lint/UriEscapeUnescape
value.map { |i| i.is_a?(String) ? URI.escape(i) : i }
else
URI.escape(value) # rubocop:disable Lint/UriEscapeUnescape
URI.escape(value)
end

return result
Expand Down
22 changes: 12 additions & 10 deletions spec/acceptance/member_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@
end

describe 'members array of integers' do
it_behaves_like 'item found' do
let(:pp) do
<<-DOC
let(:pp) do
<<-DOC
if member( [1,2,3,4], 4 ){
notify { 'output correct': }
}
DOC
end
DOC
end

it_behaves_like 'item found' do
end
end
describe 'members of mixed array' do
it_behaves_like 'item found' do
let(:pp) do
<<-DOC
let(:pp) do
<<-DOC
if member( ['a','4',3], 'a' ){
notify { 'output correct': }
}
DOC
end
DOC
end

it_behaves_like 'item found' do
end
end
it 'members arrays without members'
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/private_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
scope.expects(:warning).with("private() DEPRECATED: This function will cease to function on Puppet 4; please use assert_private() before upgrading to puppet 4 for backwards-compatibility, or migrate to the new parser's typing system.") # rubocop:disable Metrics/LineLength : unable to cut line to required length
begin
subject.call []
rescue # rubocop:disable Lint/HandleExceptions, Lint/RescueWithoutErrorClass
rescue # rubocop:disable Lint/HandleExceptions
# ignore this
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/puppet/type/file_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path) }.to raise_error(Puppet::Error, %r{line is a required attribute})
end
it 'does not require that a line is specified when matching for absence' do
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Lint/BooleanSymbol, Metrics/LineLength
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Metrics/LineLength
end
it 'although if a line is specified anyway when matching for absence it still works and the line is silently ignored' do
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Lint/BooleanSymbol, Metrics/LineLength
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :path => tmp_path, :line => 'i_am_irrelevant', :ensure => :absent, :match_for_absence => :true, :match => 'match') }.not_to raise_error # rubocop:disable Metrics/LineLength
end
it 'requires that a file is specified' do
expect { Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'path') }.to raise_error(Puppet::Error, %r{path is a required attribute})
Expand All @@ -84,7 +84,7 @@
expect(file_line[:ensure]).to eq :present
end
it 'defaults to replace => true' do
expect(file_line[:replace]).to eq :true # rubocop:disable Lint/BooleanSymbol
expect(file_line[:replace]).to eq :true
end
it 'defaults to encoding => UTF-8' do
expect(file_line[:encoding]).to eq 'UTF-8'
Expand Down