Skip to content

Commit

Permalink
[ci] Enable Performance/RedundantMerge rubocop cop
Browse files Browse the repository at this point in the history
Identifies places where Hash#merge! can be replaced by Hash#[]=
  • Loading branch information
DavidKang committed Jan 17, 2017
1 parent 28ea17d commit 7f31deb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/api/.rubocop.yml
Expand Up @@ -117,6 +117,10 @@ Style/NumericLiteralPrefix:
Performance/RedundantBlockCall:
Enabled: true

# Identifies places where Hash#merge! can be replaced by Hash#[]=
Performance/RedundantMerge:
Enabled: true

# Checks for redundant `return` expressions
Style/RedundantReturn:
Enabled: false
Expand Down
9 changes: 0 additions & 9 deletions src/api/.rubocop_todo.yml
Expand Up @@ -137,15 +137,6 @@ Performance/RedundantMatch:
- 'app/models/project.rb'
- 'lib/tasks/databases.rake'

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: MaxKeyValuePairs.
Performance/RedundantMerge:
Exclude:
- 'app/mixins/can_render_model.rb'
- 'config/application.rb'
- 'spec/support/shared_examples/features/flags_tables.rb'

# Offense count: 23
# Cop supports --auto-correct.
Performance/StringReplacement:
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/mixins/can_render_model.rb
Expand Up @@ -6,7 +6,7 @@ def render_xml(locals = {})
# FIXME: Hand me the revolver please...
partial = self.class.name == 'RemoteProject' ? 'Project' : self.class.name
action_view = ActionView::Base.new(Rails.configuration.paths['app/views'])
locals.merge!(my_model: self)
locals[:my_model] = self
action_view.render partial: "models/#{partial.underscore}", formats: [:xml],
locals: locals
end
Expand Down
10 changes: 5 additions & 5 deletions src/api/config/application.rb
Expand Up @@ -106,11 +106,11 @@ class Application < Rails::Application

config.action_controller.action_on_unpermitted_parameters = :raise

config.action_dispatch.rescue_responses.merge!('ActiveXML::Transport::UnauthorizedError' => 401)
config.action_dispatch.rescue_responses.merge!('ActiveXML::Transport::ConnectionError' => 503)
config.action_dispatch.rescue_responses.merge!('ActiveXML::Transport::Error' => 500)
config.action_dispatch.rescue_responses.merge!('Timeout::Error' => 408)
config.action_dispatch.rescue_responses.merge!('ActionController::InvalidAuthenticityToken' => 403)
config.action_dispatch.rescue_responses['ActiveXML::Transport::UnauthorizedError'] = 401
config.action_dispatch.rescue_responses['ActiveXML::Transport::ConnectionError'] = 503
config.action_dispatch.rescue_responses['ActiveXML::Transport::Error'] = 500
config.action_dispatch.rescue_responses['Timeout::Error'] = 408
config.action_dispatch.rescue_responses['ActionController::InvalidAuthenticityToken'] = 403

# avoid a warning
I18n.enforce_available_locales = true
Expand Down
6 changes: 3 additions & 3 deletions src/api/spec/support/shared_examples/features/flags_tables.rb
Expand Up @@ -50,7 +50,7 @@ def css_locator_for(repository, architecture)
end

scenario "toggle flags per repository" do
query_attributes.merge!(repo: repository.name)
query_attributes[:repo] = repository.name

disable_flag_field_for(repository: repository.name, architecture: "All")
expect(project.flags.reload.where(query_attributes.merge(status: :disable))).to exist
Expand All @@ -60,7 +60,7 @@ def css_locator_for(repository, architecture)
end

scenario "toggle flags per arch" do
query_attributes.merge!(architecture_id: Architecture.find_by_name("i586"))
query_attributes[:architecture_id] = Architecture.find_by_name("i586")

disable_flag_field_for(repository: "All", architecture: "i586")
expect(project.flags.reload.where(query_attributes.merge(status: :disable))).to exist
Expand All @@ -70,7 +70,7 @@ def css_locator_for(repository, architecture)
end

scenario "toggle all flags at once" do
query_attributes.merge!(flag: flag_type)
query_attributes[:flag] = flag_type

disable_flag_field_for(repository: "All", architecture: "All")
expect(project.flags.reload.where(query_attributes.merge(status: :disable))).to exist
Expand Down

0 comments on commit 7f31deb

Please sign in to comment.