Skip to content

Commit 02919a8

Browse files
author
David Swan
committed
Rubocop Finished
1 parent 2d474b5 commit 02919a8

File tree

115 files changed

+8000
-7226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+8000
-7226
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,6 @@ Style/IfUnlessModifier:
9696
Enabled: false
9797
Style/SymbolProc:
9898
Enabled: false
99+
#TODO: Additional value added to resolve error's
100+
Style/GlobalVars:
101+
Enabled: false

.sync.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ spec/spec_helper.rb:
1010
env:
1111
global:
1212
- "PARALLEL_TEST_PROCESSORS=16 # reduce test parallelism to prevent overloading containers"
13+
extras:
14+
- rvm: 2.1.9
15+
script: bundle exec rake rubocop
16+

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ matrix:
2828
- rvm: 2.1.9
2929
bundler_args: --without system_tests
3030
env: PUPPET_GEM_VERSION="~> 4.0"
31+
- rvm: 2.1.9
32+
script: bundle exec rake rubocop
3133
notifications:
3234
email: false

lib/facter/apache_version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Facter.add(:apache_version) do
2-
confine :kernel => 'Linux'
2+
confine kernel: 'Linux'
33
setcode do
44
if Facter::Util::Resolution.which('apachectl')
55
apache_version = Facter::Util::Resolution.exec('apachectl -v 2>&1')

lib/puppet/functions/apache/apache_pw_hash.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010

1111
def apache_pw_hash(password)
1212
require 'base64'
13-
return '{SHA}' + Base64.strict_encode64(Digest::SHA1.digest(password))
13+
'{SHA}' + Base64.strict_encode64(Digest::SHA1.digest(password))
1414
end
1515
end

lib/puppet/functions/apache/bool2httpd.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
# # => 'Off'
1515
Puppet::Functions.create_function(:'apache::bool2httpd') do
1616
def bool2httpd(arg)
17-
if arg.nil? or arg == false or arg =~ /false/i or arg == :undef
18-
return 'Off'
19-
elsif arg == true or arg =~ /true/i
20-
return 'On'
21-
end
22-
23-
return arg.to_s
17+
return 'Off' if arg.nil? || arg == false || arg =~ %r{false}i || arg == :undef
18+
return 'On' if arg == true || arg =~ %r{true}i
19+
arg.to_s
2420
end
2521
end

lib/puppet/functions/apache/validate_apache_log_level.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
# validate_apache_loglevel('warn ssl_module:info')
99
#
1010
# Expected to be used from the main or vhost.
11-
#
1211
# Might be used from directory too later as apache supports that
1312
Puppet::Functions.create_function(:'apache::validate_apache_log_level') do
1413
dispatch :validate_apache_log_level do
1514
required_param 'String', :log_level
1615
end
1716

18-
def validate_apache_log_level (log_level)
17+
def validate_apache_log_level(log_level)
1918
msg = "Log level '${log_level}' is not one of the supported Apache HTTP Server log levels."
20-
raise Puppet::ParseError, (msg) unless log_level =~ Regexp.compile('(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])')
19+
raise Puppet::ParseError, msg unless log_level =~ Regexp.compile('(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])')
2120
end
2221
end

lib/puppet/parser/functions/apache_pw_hash.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
require 'base64'
22

3-
Puppet::Parser::Functions::newfunction(:apache_pw_hash, :type => :rvalue, :doc => <<-EOS
4-
Hashes a password in a format suitable for htpasswd files read by apache.
3+
Puppet::Parser::Functions.newfunction(:apache_pw_hash, type: :rvalue, doc: <<-DOC
4+
Hashes a password in a format suitable for htpasswd files read by apache.
55
6-
Currently uses SHA-hashes, because although this format is considered insecure, its the
7-
most secure format supported by the most platforms.
8-
EOS
9-
) do |args|
6+
Currently uses SHA-hashes, because although this format is considered insecure, its the
7+
most secure format supported by the most platforms.
8+
DOC
9+
) do |args|
1010
raise(Puppet::ParseError, "apache_pw_hash() wrong number of arguments. Given: #{args.size} for 1)") if args.size != 1
11-
raise(Puppet::ParseError, "apache_pw_hash(): first argument must be a string") unless args[0].is_a? String
12-
raise(Puppet::ParseError, "apache_pw_hash(): first argument must not be empty") if args[0].empty?
11+
raise(Puppet::ParseError, 'apache_pw_hash(): first argument must be a string') unless args[0].is_a? String
12+
raise(Puppet::ParseError, 'apache_pw_hash(): first argument must not be empty') if args[0].empty?
1313

1414
password = args[0]
1515
return '{SHA}' + Base64.strict_encode64(Digest::SHA1.digest(password))
Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
Puppet::Parser::Functions::newfunction(:bool2httpd, :type => :rvalue, :doc => <<-EOS
2-
Transform a supposed boolean to On or Off. Pass all other values through.
3-
Given a nil value (undef), bool2httpd will return 'Off'
1+
Puppet::Parser::Functions.newfunction(:bool2httpd, type: :rvalue, doc: <<-DOC
2+
Transform a supposed boolean to On or Off. Pass all other values through.
3+
Given a nil value (undef), bool2httpd will return 'Off'
44
5-
Example:
5+
Example:
66
7-
$trace_enable = false
8-
$server_signature = 'mail'
7+
$trace_enable = false
8+
$server_signature = 'mail'
99
10-
bool2httpd($trace_enable)
11-
# => 'Off'
12-
bool2httpd($server_signature)
13-
# => 'mail'
14-
bool2httpd(undef)
15-
# => 'Off'
16-
17-
EOS
18-
) do |args|
10+
bool2httpd($trace_enable)
11+
# => 'Off'
12+
bool2httpd($server_signature)
13+
# => 'mail'
14+
bool2httpd(undef)
15+
# => 'Off'
16+
DOC
17+
) do |args|
1918
raise(Puppet::ParseError, "bool2httpd() wrong number of arguments. Given: #{args.size} for 1)") if args.size != 1
2019

2120
arg = args[0]
22-
23-
if arg.nil? or arg == false or arg =~ /false/i or arg == :undef
24-
return 'Off'
25-
elsif arg == true or arg =~ /true/i
26-
return 'On'
27-
end
28-
21+
return 'Off' if arg.nil? || arg == false || arg =~ %r{false}i || arg == :undef
22+
return 'On' if arg == true || arg =~ %r{true}i
2923
return arg.to_s
3024
end
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
# validate_apache_log_level.rb
12
module Puppet::Parser::Functions
2-
newfunction(:validate_apache_log_level, :doc => <<-'ENDHEREDOC') do |args|
3+
newfunction(:validate_apache_log_level, doc: <<-DOC
34
Perform simple validation of a string against the list of known log
45
levels as per http://httpd.apache.org/docs/current/mod/core.html#loglevel
56
validate_apache_loglevel('info')
@@ -10,18 +11,17 @@ module Puppet::Parser::Functions
1011
validate_apache_loglevel('warn ssl_module:info')
1112
1213
Expected to be used from the main or vhost.
13-
14+
1415
Might be used from directory too later as apaceh supports that
1516
16-
ENDHEREDOC
17-
if (args.size != 1) then
18-
raise Puppet::ParseError, ("validate_apache_loglevel(): wrong number of arguments (#{args.length}; must be 1)")
17+
DOC
18+
) do |args|
19+
if args.size != 1
20+
raise Puppet::ParseError, "validate_apache_loglevel(): wrong number of arguments (#{args.length}; must be 1)"
1921
end
2022

2123
log_level = args[0]
2224
msg = "Log level '${log_level}' is not one of the supported Apache HTTP Server log levels."
23-
24-
raise Puppet::ParseError, (msg) unless log_level =~ Regexp.compile('(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])')
25-
25+
raise Puppet::ParseError, msg unless log_level =~ Regexp.compile('(emerg|alert|crit|error|warn|notice|info|debug|trace[1-8])')
2626
end
2727
end

lib/puppet/provider/a2mod.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# a2mod.rb
12
class Puppet::Provider::A2mod < Puppet::Provider
23
def self.prefetch(mods)
34
instances.each do |prov|
4-
if mod = mods[prov.name]
5+
mod = mods[prov.name]
6+
if mod
57
mod.provider = prov
68
end
79
end
@@ -13,15 +15,15 @@ def flush
1315

1416
def properties
1517
if @property_hash.empty?
16-
@property_hash = query || {:ensure => :absent}
18+
@property_hash = query || { ensure: :absent }
1719
@property_hash[:ensure] = :absent if @property_hash.empty?
1820
end
1921
@property_hash.dup
2022
end
2123

2224
def query
2325
self.class.instances.each do |mod|
24-
if mod.name == self.name or mod.name.downcase == self.name
26+
if mod.name == name || mod.name.downcase == name
2527
return mod.properties
2628
end
2729
end

lib/puppet/provider/a2mod/a2mod.rb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
require 'puppet/provider/a2mod'
22

3-
Puppet::Type.type(:a2mod).provide(:a2mod, :parent => Puppet::Provider::A2mod) do
4-
desc "Manage Apache 2 modules on Debian and Ubuntu"
3+
Puppet::Type.type(:a2mod).provide(:a2mod, parent: Puppet::Provider::A2mod) do
4+
desc 'Manage Apache 2 modules on Debian and Ubuntu'
55

6-
optional_commands :encmd => "a2enmod"
7-
optional_commands :discmd => "a2dismod"
8-
commands :apache2ctl => "apache2ctl"
6+
optional_commands encmd: 'a2enmod'
7+
optional_commands discmd: 'a2dismod'
8+
commands apache2ctl: 'apache2ctl'
99

10-
confine :osfamily => :debian
11-
defaultfor :operatingsystem => [:debian, :ubuntu]
10+
confine osfamily: :debian
11+
defaultfor operatingsystem: [:debian, :ubuntu]
1212

13-
def self.instances
14-
modules = apache2ctl("-M").lines.collect { |line|
15-
m = line.match(/(\w+)_module \(shared\)$/)
16-
m[1] if m
17-
}.compact
13+
def self.instances
14+
modules = apache2ctl('-M').lines.map { |line|
15+
m = line.match(%r{(\w+)_module \(shared\)$})
16+
m[1] if m
17+
}.compact
1818

19-
modules.map do |mod|
20-
new(
21-
:name => mod,
22-
:ensure => :present,
23-
:provider => :a2mod
24-
)
25-
end
19+
modules.map do |mod|
20+
new(
21+
name: mod,
22+
ensure: :present,
23+
provider: :a2mod,
24+
)
2625
end
26+
end
2727

28-
def create
29-
encmd resource[:name]
30-
end
28+
def create
29+
encmd resource[:name]
30+
end
3131

32-
def destroy
33-
discmd resource[:name]
34-
end
32+
def destroy
33+
discmd resource[:name]
34+
end
3535
end

0 commit comments

Comments
 (0)