Skip to content

Commit

Permalink
Rubocop: Redundant merge!
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Jan 10, 2017
1 parent f0c7322 commit d4bbaaa
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 21 deletions.
12 changes: 0 additions & 12 deletions .rubocop_todo.yml
Expand Up @@ -162,18 +162,6 @@ Performance/RedundantMatch:
Exclude:
- 'app/helpers/application_helper.rb'

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: MaxKeyValuePairs.
Performance/RedundantMerge:
Exclude:
- 'app/helpers/application_helper.rb'
- 'app/inputs/date_pair_input.rb'
- 'app/inputs/date_time_input.rb'
- 'app/models/polymorphic/address.rb'
- 'spec/models/setting_spec.rb'


# Offense count: 12
Style/AccessorMethodName:
Exclude:
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/application_helper.rb
Expand Up @@ -362,11 +362,11 @@ def shown_on_landing_page?
def links_to_export(action = :index)
token = current_user.single_access_token
url_params = { action: action }
url_params.merge!(id: params[:id]) unless params[:id].blank?
url_params.merge!(query: params[:query]) unless params[:query].blank?
url_params.merge!(q: params[:q]) unless params[:q].blank?
url_params.merge!(view: @view) unless @view.blank? # tasks
url_params.merge!(id: params[:id]) unless params[:id].blank?
url_params[:id] = params[:id] unless params[:id].blank?
url_params[:query] = params[:query] unless params[:query].blank?
url_params[:q] = params[:q] unless params[:q].blank?
url_params[:view] = @view unless @view.blank? # tasks
url_params[:id] = params[:id] unless params[:id].blank?

exports = %w(xls csv).map do |format|
link_to(format.upcase, url_params.merge(format: format), title: I18n.t(:"to_#{format}")) unless action.to_s == "show"
Expand Down
2 changes: 1 addition & 1 deletion app/inputs/date_pair_input.rb
Expand Up @@ -17,7 +17,7 @@ def input(wrapper_options)
label = field == field1 ? I18n.t('pair.start') : I18n.t('pair.end')
[:required, :disabled].each { |k| input_html_options.delete(k) } # ensure these come from field not default options
input_html_options.merge!(field.input_options)
input_html_options.merge!(value: value(field))
input_html_options[:value] = value(field)
out << "<label#{' class="req"' if input_html_options[:required]}>#{label}</label>".html_safe
text = @builder.text_field(field.name, merge_wrapper_options(input_html_options, wrapper_options))
out << text << '</div>'.html_safe
Expand Down
2 changes: 1 addition & 1 deletion app/inputs/date_time_input.rb
Expand Up @@ -7,7 +7,7 @@ class DateTimeInput < SimpleForm::Inputs::DateTimeInput
def input(wrapper_options)
add_autocomplete!
input_html_options.merge(input_options)
input_html_options.merge!(value: value)
input_html_options[:value] = value
@builder.text_field(attribute_name, merge_wrapper_options(input_html_options, wrapper_options))
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/polymorphic/address.rb
Expand Up @@ -51,7 +51,7 @@ def blank?
def self.reject_address(attributes)
exists = attributes['id'].present?
empty = %w(street1 street2 city state zipcode country full_address).map { |name| attributes[name].blank? }.all?
attributes.merge!(_destroy: 1) if exists && empty
attributes[:_destroy] = 1 if exists && empty
(!exists && empty)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/models/setting_spec.rb
Expand Up @@ -31,7 +31,7 @@

it "should use value from YAML if setting is missing from database" do
@setting = FactoryGirl.create(:setting, name: "magoody", value: nil)
Setting.yaml_settings.merge!(magoody: "thingymabob")
Setting.yaml_settings[:magoody] = "thingymabob"
expect(Setting[:magoody]).to eq("thingymabob")
expect(Setting.magoody).to eq("thingymabob")
end
Expand Down

0 comments on commit d4bbaaa

Please sign in to comment.