diff --git a/src/api/.rubocop.yml b/src/api/.rubocop.yml index 25be35bd47e..f7a08bc0534 100644 --- a/src/api/.rubocop.yml +++ b/src/api/.rubocop.yml @@ -32,6 +32,10 @@ Style/AndOr: Style/AsciiComments: Enabled: true +# Checks for methods invoked via the :: operator +Style/ColonMethodCall: + Enabled: true + # Use ` or %x around command literals. Style/CommandLiteral: EnforcedStyle: percent_x diff --git a/src/api/.rubocop_todo.yml b/src/api/.rubocop_todo.yml index ecc21df792f..d1ff6dbce05 100644 --- a/src/api/.rubocop_todo.yml +++ b/src/api/.rubocop_todo.yml @@ -338,19 +338,6 @@ Style/ClosingParenthesisIndentation: Exclude: - 'test/unit/project_test.rb' -# Offense count: 14 -# Cop supports --auto-correct. -Style/ColonMethodCall: - Exclude: - - 'app/controllers/configurations_controller.rb' - - 'app/controllers/webui/package_controller.rb' - - 'app/helpers/webui/project_helper.rb' - - 'app/mixins/build_log_support.rb' - - 'app/models/issue_tracker.rb' - - 'config/application.rb' - - 'config/initializers/activexml.rb' - - 'config/unicorn/development.rb' - # Offense count: 18 # Cop supports --auto-correct. # Configuration parameters: Keywords. diff --git a/src/api/app/controllers/configurations_controller.rb b/src/api/app/controllers/configurations_controller.rb index 008a0c30e6f..495da864007 100644 --- a/src/api/app/controllers/configurations_controller.rb +++ b/src/api/app/controllers/configurations_controller.rb @@ -49,8 +49,8 @@ def update # is it defined in options.yml if value && !value.blank? - v = ::Configuration::map_value( key, value ) - ov = ::Configuration::map_value( key, ::Configuration::OPTIONS_YML[key] ) + v = ::Configuration.map_value( key, value ) + ov = ::Configuration.map_value( key, ::Configuration::OPTIONS_YML[key] ) if ov != v && ov.present? render_error status: 403, errorcode: 'no_permission_to_change', message: "The api has a different value for #{key} configured in options.yml file. Remove it there first." diff --git a/src/api/app/controllers/webui/package_controller.rb b/src/api/app/controllers/webui/package_controller.rb index d4d5f963150..11d8367cf08 100644 --- a/src/api/app/controllers/webui/package_controller.rb +++ b/src/api/app/controllers/webui/package_controller.rb @@ -849,7 +849,7 @@ def update_build_log @finished = true else @log_chunk = chunk - @offset += ActiveXML::backend.last_body_length + @offset += ActiveXML.backend.last_body_length end rescue Timeout::Error, IOError @@ -973,7 +973,7 @@ def rpmlint_result def get_rpmlint_log(project, package, repository, architecture) path = "/build/#{pesc project}/#{pesc repository}/#{pesc architecture}/#{pesc package}/rpmlint.log" - ActiveXML::backend.direct_http(URI(path), timeout: 500) + ActiveXML.backend.direct_http(URI(path), timeout: 500) end def rpmlint_log diff --git a/src/api/app/helpers/webui/project_helper.rb b/src/api/app/helpers/webui/project_helper.rb index c367006150a..9731637907b 100644 --- a/src/api/app/helpers/webui/project_helper.rb +++ b/src/api/app/helpers/webui/project_helper.rb @@ -7,7 +7,7 @@ def show_status_comment(comment, package, firstfail, comments_to_clear) status_comment_html = ''.html_safe if comment # TODO: Port _to_remote helpers to jQuery - status_comment_html = ERB::Util::h(comment) + status_comment_html = ERB::Util.h(comment) if !firstfail if User.current.can_modify_project?(@project.api_obj) status_comment_html += ' '.html_safe + link_to(image_tag('comment_delete.png', size: '16x16', alt: 'Clear'), diff --git a/src/api/app/mixins/build_log_support.rb b/src/api/app/mixins/build_log_support.rb index 0f97ea6885b..45ba63ced84 100644 --- a/src/api/app/mixins/build_log_support.rb +++ b/src/api/app/mixins/build_log_support.rb @@ -4,7 +4,7 @@ module BuildLogSupport def raw_log_chunk( project, package, repo, arch, start, theend ) logger.debug "get log chunk #{start}-#{theend}" path = "/build/#{pesc project}/#{pesc repo}/#{pesc arch}/#{pesc package}/_log?nostream=1&start=#{start}&end=#{theend}" - ActiveXML::backend.direct_http URI("#{path}"), timeout: 500 + ActiveXML.backend.direct_http URI("#{path}"), timeout: 500 end def get_log_chunk( project, package, repo, arch, start, theend ) @@ -30,7 +30,7 @@ def get_log_chunk( project, package, repo, arch, start, theend ) def get_size_of_log( project, package, repo, arch) logger.debug 'get log entry' path = "/build/#{pesc project}/#{pesc repo}/#{pesc arch}/#{pesc package}/_log?view=entry" - data = ActiveXML::backend.direct_http URI("#{path}"), timeout: 500 + data = ActiveXML.backend.direct_http URI("#{path}"), timeout: 500 return 0 unless data doc = Xmlhash.parse(data) doc.elements('entry') do |e| @@ -41,13 +41,13 @@ def get_size_of_log( project, package, repo, arch) def get_job_status( project, package, repo, arch) path = "/build/#{pesc project}/#{pesc repo}/#{pesc arch}/#{pesc package}/_jobstatus" - ActiveXML::backend.direct_http URI("#{path}"), timeout: 500 + ActiveXML.backend.direct_http URI("#{path}"), timeout: 500 end def get_status(project, package, repo, arch) path = "/build/#{pesc project}/_result?view=status&package=#{pesc package}&arch=#{pesc arch}&repository=#{pesc repo}" code = "" - data = ActiveXML::backend.direct_http URI("#{path}"), timeout: 500 + data = ActiveXML.backend.direct_http URI("#{path}"), timeout: 500 return code unless data doc = Xmlhash.parse(data) if doc['result'] && doc['result']['status'] && doc['result']['status']['code'] diff --git a/src/api/app/models/issue_tracker.rb b/src/api/app/models/issue_tracker.rb index 2961817f730..6bbecd14640 100644 --- a/src/api/app/models/issue_tracker.rb +++ b/src/api/app/models/issue_tracker.rb @@ -50,7 +50,7 @@ def valid_issue_name?(name) def show_url_for(issue, html = nil) return unless issue url = show_url.gsub('@@@', issue) - return "#{CGI::escapeHTML(show_label_for(issue))}" if html + return "#{CGI.escapeHTML(show_label_for(issue))}" if html url end diff --git a/src/api/config/application.rb b/src/api/config/application.rb index a77d48d2118..ac3d3f2eb7a 100644 --- a/src/api/config/application.rb +++ b/src/api/config/application.rb @@ -5,7 +5,7 @@ # Assets should be precompiled for production (so we don't need the gems loaded then) Bundler.require(*Rails.groups(assets: %w(development test))) require_relative '../lib/engines/base.rb' -OBSEngine::load_engines +OBSEngine.load_engines module OBSApi class Application < Rails::Application diff --git a/src/api/config/initializers/activexml.rb b/src/api/config/initializers/activexml.rb index ff858f1f780..95f77714357 100644 --- a/src/api/config/initializers/activexml.rb +++ b/src/api/config/initializers/activexml.rb @@ -3,7 +3,7 @@ CONFIG['source_protocol'] ||= 'http' CONFIG['api_relative_url_root'] ||= '' -map = ActiveXML::setup_transport_backend(CONFIG['source_protocol'], CONFIG['source_host'], CONFIG['source_port']) +map = ActiveXML.setup_transport_backend(CONFIG['source_protocol'], CONFIG['source_host'], CONFIG['source_port']) map.connect :directory, 'rest:///source/:project/:package?:expand&:rev&:meta&:linkrev&:emptylink&:view&:extension&:lastworking&:withlinked&:deleted' map.connect :jobhistory, 'rest:///build/:project/:repository/:arch/_jobhistory?:package&:limit&:code' @@ -33,7 +33,7 @@ end end -map = ActiveXML::setup_transport_api(CONFIG['frontend_protocol'], CONFIG['frontend_host'], CONFIG['frontend_port'], CONFIG['api_relative_url_root']) +map = ActiveXML.setup_transport_api(CONFIG['frontend_protocol'], CONFIG['frontend_host'], CONFIG['frontend_port'], CONFIG['api_relative_url_root']) map.connect :webuiproject, 'rest:///source/:name/_meta?:view', delete: 'rest:///source/:name?:force', diff --git a/src/api/config/unicorn/development.rb b/src/api/config/unicorn/development.rb index 12c2acb7934..a41cde0c5ac 100644 --- a/src/api/config/unicorn/development.rb +++ b/src/api/config/unicorn/development.rb @@ -4,6 +4,6 @@ after_fork do |server, _| listener = server.listener_opts.first[0] port = Integer(listener.split(':')[1]) - ActiveXML::api.port = port + ActiveXML.api.port = port CONFIG['frontend_port'] = port end