Skip to content

Commit

Permalink
Refs #3809 - Turning on some rubocop cops
Browse files Browse the repository at this point in the history
  • Loading branch information
David Davis authored and dLobatog committed May 12, 2016
1 parent a6363a5 commit f4459c1
Show file tree
Hide file tree
Showing 283 changed files with 465 additions and 585 deletions.
67 changes: 0 additions & 67 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,6 @@ Style/EachWithObject:
Style/EmptyLineBetweenDefs:
Enabled: false

# Offense count: 226
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment.
Style/ExtraSpacing:
Enabled: false

# Offense count: 14
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
Style/FileName:
Expand Down Expand Up @@ -429,11 +423,6 @@ Style/NestedParenthesizedCalls:
Style/Next:
Enabled: false

# Offense count: 16
# Cop supports --auto-correct.
Style/Not:
Enabled: false

# Offense count: 24
# Cop supports --auto-correct.
Style/NumericLiterals:
Expand Down Expand Up @@ -560,12 +549,6 @@ Style/SpaceAroundOperators:
Style/SpaceBeforeBlockBraces:
Enabled: false

# Offense count: 17
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Style/SpaceBeforeFirstArg:
Enabled: false

# Offense count: 400
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
Expand All @@ -585,37 +568,13 @@ Style/SpaceInsideBrackets:
Style/SpaceInsideHashLiteralBraces:
Enabled: false

# Offense count: 78
# Cop supports --auto-correct.
Style/SpaceInsideParens:
Enabled: false

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

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

# Offense count: 11877
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Enabled: false

# Offense count: 25
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiteralsInInterpolation:
Enabled: false

# Offense count: 1
Style/StructInheritance:
Enabled: false
Expand All @@ -632,39 +591,13 @@ Style/SymbolLiteral:
Style/SymbolProc:
Enabled: false

# Offense count: 83
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
# SupportedStyles: final_newline, final_blank_line
Style/TrailingBlankLines:
Enabled: false

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
# SupportedStyles: comma, consistent_comma, no_comma
Style/TrailingCommaInArguments:
Enabled: false

# Offense count: 64
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
# SupportedStyles: comma, consistent_comma, no_comma
Style/TrailingCommaInLiteral:
Enabled: false

# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist.
# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
Style/TrivialAccessors:
Enabled: false

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

# Offense count: 271
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles, MinSize, WordRegex.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/about_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index
{
:friendly_name => provider_class.constantize.provider_friendly_name,
:name => provider_name,
:status => enabled_providers.include?(provider_name) ? :installed : :absent,
:status => enabled_providers.include?(provider_name) ? :installed : :absent
}
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def render_message(msg, render_options = {})
end

def log_resource_errors(resource)
logger.error "Unprocessable entity #{resource.class.name} (id: #{resource.try(:id) || "new"}):\n #{resource.errors.full_messages.join("\n ")}\n"
logger.error "Unprocessable entity #{resource.class.name} (id: #{resource.try(:id) || 'new'}):\n #{resource.errors.full_messages.join("\n ")}\n"
end

def authorize
Expand Down Expand Up @@ -172,7 +172,7 @@ def search_options
def paginate_options
{
:page => params[:page],
:per_page => params[:per_page],
:per_page => params[:per_page]
}
end

Expand Down
4 changes: 0 additions & 4 deletions app/controllers/api/v1/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,3 @@ def destroy
end
end
end




1 change: 0 additions & 1 deletion app/controllers/api/v1/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ def status
end
end
end

2 changes: 1 addition & 1 deletion app/controllers/api/v1/media_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MediaController < V1::BaseController
Available families:
#{Operatingsystem.families.map { |f| "* " + f }.join("\n")}
#{Operatingsystem.families.map { |f| '* ' + f }.join("\n")}
eos

api :GET, "/media/", "List all media."
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/api/v1/smart_proxies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ def check_feature_type

allowed_types = Feature.name_map.keys

if not allowed_types.include? params[:type].downcase
raise ArgumentError, "Invalid feature type. Select one of: #{allowed_types.join(", ")}."
if !allowed_types.include? params[:type].downcase
raise ArgumentError, "Invalid feature type. Select one of: #{allowed_types.join(', ')}."
end
end
end
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/api/v2/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,3 @@ def destroy
end
end
end




2 changes: 0 additions & 2 deletions app/controllers/api/v2/compute_profiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,3 @@ def destroy
end
end
end


1 change: 0 additions & 1 deletion app/controllers/api/v2/external_usergroups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,3 @@ def refresh_external_usergroup
end
end
end

1 change: 0 additions & 1 deletion app/controllers/api/v2/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ def status
end
end
end

6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def ajax_request

def remote_user_provided?
return false unless Setting["authorize_login_delegation"]
return false if api_request? and not Setting["authorize_login_delegation_api"]
return false if api_request? and !(Setting["authorize_login_delegation_api"])
(@remote_user = request.env["REMOTE_USER"]).present?
end

Expand Down Expand Up @@ -243,7 +243,7 @@ def process_success(hash = {})
raise Foreman::Exception.new(N_("Unknown action name for success message: %s"), action_name)
end
end
hash[:success_redirect] ||= saved_redirect_url_or(send("#{controller_name}_url"))
hash[:success_redirect] ||= saved_redirect_url_or(send("#{controller_name}_url"))

notice hash[:success_msg]
redirect_to hash[:success_redirect] and return
Expand All @@ -260,7 +260,7 @@ def process_error(hash = {})
end
end

logger.info "Failed to save: #{hash[:object].errors.full_messages.join(", ")}" if hash[:object].respond_to?(:errors)
logger.info "Failed to save: #{hash[:object].errors.full_messages.join(', ')}" if hash[:object].respond_to?(:errors)
hash[:error_msg] ||= [hash[:object].errors[:base] + hash[:object].errors[:conflict].map{|e| _("Conflict - %s") % e}].flatten
hash[:error_msg] = [hash[:error_msg]].flatten.to_sentence
if hash[:render]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def import_puppetclasses

def changed_environments
begin
opts = { :url => @smart_proxy.url }
opts = { :url => @smart_proxy.url }
if @environment.present?
opts.merge!(:env => @environment.name)
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Api::V2::LookupKeysCommonController
included do
before_filter :find_environment, :if => :environment_id?
before_filter :find_puppetclass, :if => :puppetclass_id?
before_filter :find_host, :if => :host_id?
before_filter :find_hostgroup, :if => :hostgroup_id?
before_filter :find_host, :if => :host_id?
before_filter :find_hostgroup, :if => :hostgroup_id?

before_filter :find_smart_class_parameters, :if => :smart_class_parameter_id?
before_filter :find_smart_class_parameter, :if => :smart_class_parameter_id?
Expand Down Expand Up @@ -128,7 +128,7 @@ def return_if_smart_mismatch
def model_not_found(model)
error_message = (
_("%{model} with id '%{id}' was not found") %
{ :id => params["#{model}_id"], :model => model.capitalize } )
not_found(:error => { :message => error_message } )
{ :id => params["#{model}_id"], :model => model.capitalize })
not_found(:error => { :message => error_message })
end
end
2 changes: 1 addition & 1 deletion app/controllers/concerns/api/v2/taxonomies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def update
# NOTE - if not ! and invalid, the error is undefined method `permission_failed?' for #<Location:0x7fe38c1d3ec8> (NoMethodError)
# removed process_response & added explicit render 'api/v2/taxonomies/update'. Otherwise, *_ids are not returned

process_response @taxonomy.update_attributes(params[taxonomy_single])
process_response @taxonomy.update_attributes(params[taxonomy_single])
end

api :DELETE, '/:resource_id/:id', N_('Delete :a_resource')
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/api/version1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def api_version
'1'
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/concerns/api/version2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ def api_version
'2'
end
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/concerns/application_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def set_timezone
# Reset timezone for the next thread
Time.zone = default_timezone
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Foreman::Controller::Environments

def import_environments
begin
opts = params[:proxy].blank? ? { } : { :url => SmartProxy.find(params[:proxy]).try(:url) }
opts = params[:proxy].blank? ? { } : { :url => SmartProxy.find(params[:proxy]).try(:url) }
opts[:env] = params[:env] unless params[:env].blank?
@importer = PuppetClassImporter.new(opts)
@changed = @importer.changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ def needs_filtering?(params)
end
end
end

2 changes: 1 addition & 1 deletion app/controllers/domains_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class DomainsController < ApplicationController
before_filter :find_resource, :only => [:edit, :update, :destroy]

def index
@domains = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
@domains = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
end

def new
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/hostgroups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def destroy
process_error
end
rescue Ancestry::AncestryException
process_error(:error_msg => _("Cannot delete group %{current} because it has nested groups.") % { :current => @hostgroup.title } )
process_error(:error_msg => _("Cannot delete group %{current} because it has nested groups.") % { :current => @hostgroup.title })
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def update_multiple_environment

#update the hosts
@hosts.each do |host|
host.environment = (id == 'inherit' && host.hostgroup.present? ) ? host.hostgroup.environment : ev
host.environment = (id == 'inherit' && host.hostgroup.present?) ? host.hostgroup.environment : ev
host.save(:validate => false)
end

Expand Down Expand Up @@ -779,7 +779,7 @@ def load_vars_for_ajax
def find_multiple
# Lets search by name or id and make sure one of them exists first
if params[:host_names].present? or params[:host_ids].present?
@hosts = resource_base.where("hosts.id IN (?) or hosts.name IN (?)", params[:host_ids], params[:host_names] )
@hosts = resource_base.where("hosts.id IN (?) or hosts.name IN (?)", params[:host_ids], params[:host_names])
if @hosts.empty?
error _('No hosts were found with that id or name')
redirect_to(hosts_path) and return false
Expand All @@ -802,7 +802,7 @@ def toggle_hostmode(mode = true)
@hosts.to_a.delete_if { |host| host.update_attribute(:enabled, mode) }
action = mode ? "enabled" : "disabled"

missed_hosts = @hosts.map(&:name).to_sentence
missed_hosts = @hosts.map(&:name).to_sentence
if @hosts.empty?
notice _("%s selected hosts") % (action.capitalize)
else
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ModelsController < ApplicationController
before_filter :find_resource, :only => [:edit, :update, :destroy]

def index
@models = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
@models = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
end

def new
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/unattended_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def find_host_by_token
token = params.delete('token')
return nil if token.blank?
# Quirk: ZTP requires the .slax suffix
if ( result = token.match(/^([a-z0-9-]+)(.slax)$/i) )
if (result = token.match(/^([a-z0-9-]+)(.slax)$/i))
token, _suffix = result.captures
end
Host.for_token(token).first
Expand Down
Loading

0 comments on commit f4459c1

Please sign in to comment.