Skip to content

Commit

Permalink
Merge pull request #10055 from saraycp/rubocop_autocorrect_IX_control…
Browse files Browse the repository at this point in the history
…lers

Correct Rubocop Style/RegexpLiteral offences in controllers
  • Loading branch information
vpereira committed Aug 24, 2020
2 parents 7af64d7 + 6a7a474 commit 0268bc7
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 15 deletions.
7 changes: 0 additions & 7 deletions src/api/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1386,13 +1386,6 @@ Style/OptionalBooleanParameter:
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Exclude:
- 'app/controllers/application_controller.rb'
- 'app/controllers/person_controller.rb'
- 'app/controllers/public_controller.rb'
- 'app/controllers/webui/monitor_controller.rb'
- 'app/controllers/webui/package_controller.rb'
- 'app/controllers/webui/sitemaps_controller.rb'
- 'app/controllers/webui/webui_controller.rb'
- 'app/helpers/webui/webui_helper.rb'
- 'app/mixins/build_log_support.rb'
- 'app/models/cloud/ec2/configuration.rb'
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def validate_xml_response

request_format = request.format != 'json'
response_status = response.status.to_s[0..2] == '200'
response_headers = response.headers['Content-Type'] !~ /.*\/json/i && response.headers['Content-Disposition'] != 'attachment'
response_headers = response.headers['Content-Type'] !~ %r{.*/json}i && response.headers['Content-Disposition'] != 'attachment'

return unless request_format && response_status && response_headers

Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/person_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def internal_register
render_ok
rescue Exception => e
# Strip passwords from request environment and re-raise exception
request.env['RAW_POST_DATA'] = request.env['RAW_POST_DATA'].sub(/<password>(.*)<\/password>/, '<password>STRIPPED<password>')
request.env['RAW_POST_DATA'] = request.env['RAW_POST_DATA'].sub(%r{<password>(.*)</password>}, '<password>STRIPPED<password>')
raise e
end

Expand Down
4 changes: 2 additions & 2 deletions src/api/app/controllers/public_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ def binary_packages
# So we have to revert this here...
filepath = b['filepath']
# having both gsub! in one line can crash with some ruby builds
filepath.gsub!(/:\//, ':')
filepath.gsub!(/^[^\/]*\/[^\/]*\//, '')
filepath.gsub!(%r{:/}, ':')
filepath.gsub!(%r{^[^/]*/[^/]*/}, '')

@binary_links[dist_id][:binary] << { type: binary_type, arch: b['arch'], url: repo.download_url(filepath) }
if @binary_links[dist_id][:repository].blank?
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/monitor_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def index
end
end
workers_list.each do |bid, barch|
hostname, subid = bid.gsub(%r{:}, '/').split('/')
hostname, subid = bid.gsub(/:/, '/').split('/')
id = bid.gsub(%r{[:./]}, '_')
workers[hostname] ||= {}
workers[hostname]['_arch'] = barch
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/package_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def update_build_log
@log_chunk = ''
rescue Backend::Error => e
case e.summary
when %r{Logfile is not that big}
when /Logfile is not that big/
@log_chunk = ''
when /start out of range/
# probably build compare has cut log and offset is wrong, reset offset
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/sitemaps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def packages

predication =
case project_name
when %r{home}
when /home/
projects_table[:name].matches("#{project_name}%")
when 'opensuse'
projects_table[:name].matches('openSUSE:%')
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/controllers/webui/webui_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Webui::WebuiController < ActionController::Base

def valid_xml_id(rawid)
rawid = "_#{rawid}" if rawid !~ /^[A-Za-z_]/ # xs:ID elements have to start with character or '_'
CGI.escapeHTML(rawid.gsub(/[+&: .\/~()@#]/, '_'))
CGI.escapeHTML(rawid.gsub(%r{[+&: ./~()@#]}, '_'))
end

def home
Expand Down

0 comments on commit 0268bc7

Please sign in to comment.