Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Commit

Permalink
Fixes #16354 - Add rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
David Davis committed Aug 31, 2016
1 parent 7e43a9d commit 2b5a38d
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 52 deletions.
16 changes: 16 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
inherit_from: .rubocop_todo.yml

HashSyntax:
Enabled: false # don't force 1.9 hash syntax

Style/StringLiterals:
Enabled: false # dont't enforce

Style/WordArray:
Enabled: false

Style/GuardClause:
Enabled: false # don't enforce this

Style/SpaceInsideHashLiteralBraces:
Enabled: false
149 changes: 149 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 0`
# on 2016-08-31 13:21:20 -0400 using RuboCop version 0.39.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# Configuration parameters: AllowSafeAssignment.
Lint/AssignmentInCondition:
Enabled: false

# Offense count: 7
# Cop supports --auto-correct.
Lint/DeprecatedClassMethods:
Enabled: false

# Offense count: 1
Lint/HandleExceptions:
Enabled: false

# Offense count: 10
# Cop supports --auto-correct.
# Configuration parameters: IgnoreEmptyBlocks.
Lint/UnusedBlockArgument:
Enabled: false

# Offense count: 6
Lint/UselessAssignment:
Enabled: false

# Offense count: 2
Metrics/BlockNesting:
Max: 4

# Offense count: 151
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
# URISchemes: http, https
Metrics/LineLength:
Max: 263

# Offense count: 2
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 13

# Offense count: 1
# Cop supports --auto-correct.
Performance/StartWith:
Enabled: false

# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly.
# SupportedStyles: assign_to_condition, assign_inside_condition
Style/ConditionalAssignment:
Enabled: false

# Offense count: 1
Style/Documentation:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: empty_lines, no_empty_lines
Style/EmptyLinesAroundBlockBody:
Enabled: false

# Offense count: 52
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
Style/FileName:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: MaxLineLength.
Style/IfUnlessModifier:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
Style/LineEndConcatenation:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth.
# SupportedStyles: aligned, indented
Style/MultilineOperationIndentation:
Enabled: false

# Offense count: 23
# Cop supports --auto-correct.
Style/MutableConstant:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/NegatedIf:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: IncludeSemanticChanges.
Style/NonNilCheck:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: PreferredDelimiters.
Style/PercentLiteralDelimiters:
Enabled: false

# Offense count: 18
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: space, no_space
Style/SpaceAroundEqualsInParameterDefault:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: SupportedStyles.
# SupportedStyles: use_perl_names, use_english_names
Style/SpecialGlobalVars:
EnforcedStyle: use_perl_names

# Offense count: 1
# Cop supports --auto-correct.
Style/UnneededInterpolation:
Enabled: false

# Offense count: 8
# Cop supports --auto-correct.
Style/UnneededPercentQ:
Enabled: false

# Offense count: 2
# Cop supports --auto-correct.
Style/ZeroLengthPredicate:
Enabled: false
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
source 'https://rubygems.org'

group :test do
gem 'rubocop'
end

gem 'kafo', '>= 0.9.3'
gem 'rake'
gem 'puppet', '>= 3.6.0', '< 4.0.0'
Expand Down
11 changes: 9 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ task :prune_foreman_modules => [] do
temp_foreman_modules_dir = File.join(temp_dir, 'foreman-installer', '_build', 'modules')
end
Dir.glob(File.join((temp_foreman_modules_dir || FOREMAN_MODULES_DIR), '*')).each do |mod|
FileUtils.rm_rf(File.join("#{BUILDDIR}",'modules', File.basename(mod)))
FileUtils.rm_rf(File.join("#{BUILDDIR}", 'modules', File.basename(mod)))
end
ensure
FileUtils.remove_entry_secure temp_dir if temp_dir
Expand Down Expand Up @@ -84,6 +84,13 @@ task :setup_local => [:clean, "#{BUILDDIR}/modules"] do
cp_r "#{BUILDDIR}/modules", "modules"
end

begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new
rescue
puts 'Rubocop not loaded'
end

CLEAN.include(BUILDDIR, PKGDIR)

task :default => ['pkg:generate_source']
task :default => [:rubocop, 'pkg:generate_source']
2 changes: 1 addition & 1 deletion bin/capsule-certs-generate
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ Kafo::KafoConfigure.run
config_file.unlink
answers_file.unlink

Kafo::KafoConfigure.exit_code == 2 ? exit(0) : exit(Kafo::KafoConfigure.exit_code)
Kafo::KafoConfigure.exit_code == 2 ? exit(0) : exit(Kafo::KafoConfigure.exit_code)
18 changes: 9 additions & 9 deletions checks/disk_size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def error_exit(message, code)
end

begin
# Error out if there is not 5 gigs of free space.
# If mongo is installed, which is the big item, then add
# the current mongo space to the total
gb_limit = 5 * 1024 * 1024
mongo_dir = "/var/lib/mongodb"
total_space = `df -k --total --exclude-type=tmpfs`.split("\n")[-1].split()[3].to_i
mongo_size = File.directory?(mongo_dir) ? `du -s /var/lib/mongodb/`.split()[0].to_i : 0
error_exit(DISK_SIZE, 1) if (total_space + mongo_size) < gb_limit
# Error out if there is not 5 gigs of free space.
# If mongo is installed, which is the big item, then add
# the current mongo space to the total
gb_limit = 5 * 1024 * 1024
mongo_dir = "/var/lib/mongodb"
total_space = `df -k --total --exclude-type=tmpfs`.split("\n")[-1].split[3].to_i
mongo_size = File.directory?(mongo_dir) ? `du -s /var/lib/mongodb/`.split[0].to_i : 0
error_exit(DISK_SIZE, 1) if (total_space + mongo_size) < gb_limit
rescue
# Eat the exception and continue
# Eat the exception and continue
end
2 changes: 1 addition & 1 deletion checks/lang.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ def error_exit(message, code)
exit code
end

error_exit(INVALID_LANG, 1) if ENV["LANG"] == "C"
error_exit(INVALID_LANG, 1) if ENV["LANG"] == "C"
22 changes: 11 additions & 11 deletions config/capsule.migrations/160120212700-foreman-proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ def move(name, default=nil, new_name=nil)

# migrate from capsule if exist
if answers['capsule'].is_a? Hash
move('puppetca', true)
move('tftp', false)
move('tftp_syslinux_root')
move('tftp_syslinux_files')
move('tftp_root', '/var/lib/tftpboot')
move('tftp_dirs', ['/var/lib/tftpboot/pxelinux.cfg', '/var/lib/tftpboot/boot'])
move('tftp_servername')
move('puppetca', true)
move('tftp', false)
move('tftp_syslinux_root')
move('tftp_syslinux_files')
move('tftp_root', '/var/lib/tftpboot')
move('tftp_dirs', ['/var/lib/tftpboot/pxelinux.cfg', '/var/lib/tftpboot/boot'])
move('tftp_servername')

move('foreman_proxy_port', '9090', 'ssl_port')
move('foreman_proxy_http', true, 'http')
move('foreman_proxy_http_port', '8000', 'http_port')
move('foreman_oauth_effective_user', 'admin', 'oauth_effective_user')
move('foreman_proxy_port', '9090', 'ssl_port')
move('foreman_proxy_http', true, 'http')
move('foreman_proxy_http_port', '8000', 'http_port')
move('foreman_oauth_effective_user', 'admin', 'oauth_effective_user')
end
20 changes: 10 additions & 10 deletions config/katello-devel.migrations/160120212701-foreman-proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def move(name, default=nil, new_name=nil)

# migrate from capsule if exist
if answers['capsule'].is_a? Hash
move('puppetca', true)
move('tftp', false)
move('tftp_syslinux_root')
move('tftp_syslinux_files')
move('tftp_root', '/var/lib/tftpboot')
move('tftp_dirs', ['/var/lib/tftpboot/pxelinux.cfg', '/var/lib/tftpboot/boot'])
move('tftp_servername')
move('puppetca', true)
move('tftp', false)
move('tftp_syslinux_root')
move('tftp_syslinux_files')
move('tftp_root', '/var/lib/tftpboot')
move('tftp_dirs', ['/var/lib/tftpboot/pxelinux.cfg', '/var/lib/tftpboot/boot'])
move('tftp_servername')

move('foreman_proxy_ssl_port', '9090', 'ssl_port')
move('foreman_proxy_http', true, 'http')
move('foreman_proxy_http_port', '8000', 'http_port')
move('foreman_proxy_ssl_port', '9090', 'ssl_port')
move('foreman_proxy_http', true, 'http')
move('foreman_proxy_http_port', '8000', 'http_port')
end
20 changes: 10 additions & 10 deletions config/katello.migrations/160120212701-foreman-proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ def move(name, default=nil, new_name=nil)

# migrate from capsule if exist
if answers['capsule'].is_a? Hash
move('puppetca', true)
move('tftp', false)
move('tftp_syslinux_root')
move('tftp_syslinux_files')
move('tftp_root', '/var/lib/tftpboot')
move('tftp_dirs', ['/var/lib/tftpboot/pxelinux.cfg', '/var/lib/tftpboot/boot'])
move('tftp_servername')
move('puppetca', true)
move('tftp', false)
move('tftp_syslinux_root')
move('tftp_syslinux_files')
move('tftp_root', '/var/lib/tftpboot')
move('tftp_dirs', ['/var/lib/tftpboot/pxelinux.cfg', '/var/lib/tftpboot/boot'])
move('tftp_servername')

move('foreman_proxy_ssl_port', '9090', 'ssl_port')
move('foreman_proxy_http', true, 'http')
move('foreman_proxy_http_port', '8000', 'http_port')
move('foreman_proxy_ssl_port', '9090', 'ssl_port')
move('foreman_proxy_http', true, 'http')
move('foreman_proxy_http_port', '8000', 'http_port')
end
8 changes: 4 additions & 4 deletions hooks/post/10-post_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def new_install?

installer_name = kafo.config.app[:installer_name] || kafo.invocation_path

if [0,2].include?(@kafo.exit_code)
if [0, 2].include?(@kafo.exit_code)
if !app_value(:upgrade)
fqdn = if @kafo.param('capsule_certs','parent_fqdn')
fqdn = if @kafo.param('capsule_certs', 'parent_fqdn')
@kafo.param('capsule_certs', 'parent_fqdn').value
else
`hostname -f`
Expand All @@ -29,8 +29,8 @@ def new_install?

# Fortello UI?
if Kafo::Helpers.module_enabled?(@kafo, 'katello')
say " * <%= color('Katello', :info) %> is running at <%= color('#{@kafo.param('foreman','foreman_url').value}', :info) %>"
say " Initial credentials are <%= color('#{@kafo.param('foreman', 'admin_username').value}', :info) %> / <%= color('#{@kafo.param('foreman', 'admin_password').value}', :info) %>" if @kafo.param('foreman','authentication').value == true && new_install?
say " * <%= color('Katello', :info) %> is running at <%= color('#{@kafo.param('foreman', 'foreman_url').value}', :info) %>"
say " Initial credentials are <%= color('#{@kafo.param('foreman', 'admin_username').value}', :info) %> / <%= color('#{@kafo.param('foreman', 'admin_password').value}', :info) %>" if @kafo.param('foreman', 'authentication').value == true && new_install?
end

if Kafo::Helpers.module_enabled?(@kafo, 'katello')
Expand Down
2 changes: 1 addition & 1 deletion hooks/post/30-upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def fail_and_exit(message)
upgrade_step :remove_gutterball
end

if [0,2].include? @kafo.exit_code
if [0, 2].include? @kafo.exit_code
Kafo::Helpers.log_and_say :info, 'Upgrade completed!'
end
else
Expand Down
1 change: 0 additions & 1 deletion hooks/pre/10-reset_feature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,3 @@ def reset_pulp
end

reset if app_value(:reset) && !app_value(:noop)

1 change: 0 additions & 1 deletion hooks/pre/15-check_java.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ def error_exit(message, code)
error_exit(OPENJDK, 2) unless java_version_string.include? "OpenJDK"
end
end

1 change: 0 additions & 1 deletion hooks/pre_validations/11-check_proxy_url.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ def error(message)
error "--katello-proxy-url must be a full URI and only supports http or https (e.g. http://proxy.example.com)"
end
end

0 comments on commit 2b5a38d

Please sign in to comment.