Showing 31 of 89 total issues
File engine.rb
has 312 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'json'
require 'net/http'
ANNOUNCE_URL = 'https://scc.suse.com/connect/subscriptions/systems'.freeze
ACTIVATE_PRODUCT_URL = 'https://scc.suse.com/connect/systems/products'.freeze
Method try_copying_from_cache
has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring. Open
def try_copying_from_cache(files, ignore_errors: false)
# We need to verify if the cached copy is still relevant
# Create a HTTP/HTTPS HEAD request if possible, return nil if not
cache_requests = files.map { |file| [file, cache_head_request(file)] }.to_h
available_in_cache = cache_requests.compact.values
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method scc_check_subscription_expiration
has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring. Open
def scc_check_subscription_expiration(headers, login, system_token, logger)
auth = headers['HTTP_AUTHORIZATION'] if headers.include?('HTTP_AUTHORIZATION')
uri = URI.parse(SYSTEMS_ACTIVATIONS_URL)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method in_alpha_or_beta?
has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring. Open
def in_alpha_or_beta?
products = []
unless errored_repos_id.empty?
products = Product.joins(:repositories).where(
'repositories.id' => errored_repos_id
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
File products_controller_spec.rb
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rails_helper'
# rubocop:disable RSpec/NestedGroups
describe Api::Connect::V3::Systems::ProductsController, type: :request do
Method handle_exceptions
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_exceptions
yield
rescue RMT::Deduplicator::HardlinkException => e
raise RMT::CLI::Error.new(
_('Could not create deduplication hardlink: %{error}.') % { error: e.message },
Method scc_check_subscription_expiration
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scc_check_subscription_expiration(headers, login, system_token, logger)
auth = headers['HTTP_AUTHORIZATION'] if headers.include?('HTTP_AUTHORIZATION')
uri = URI.parse(SYSTEMS_ACTIVATIONS_URL)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
Method authenticate_system
has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring. Open
def authenticate_system(skip_on_duplicated: false)
authenticate_or_request_with_http_basic('RMT API') do |login, password|
@systems = System.get_by_credentials(login, password)
if @systems.present?
# Return now if we just detected duplicates and we were told to skip on
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method clean
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def clean
base_directory = RMT::DEFAULT_MIRROR_DIR
repos_to_delete = Repository.where(mirroring_enabled: false).map do |repo|
repository_dir = File.join(base_directory, repo.local_path)
Method try_copying_from_cache
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def try_copying_from_cache(files, ignore_errors: false)
# We need to verify if the cached copy is still relevant
# Create a HTTP/HTTPS HEAD request if possible, return nil if not
cache_requests = files.map { |file| [file, cache_head_request(file)] }.to_h
available_in_cache = cache_requests.compact.values
Method get_system
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def get_system(systems)
return nil if systems.blank?
byos_systems_with_token = systems.select { |system| system.proxy_byos && system.system_token }
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method parse_package_list
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_package_list(packagelist)
packages = []
hdl = File.open(packagelist.local_path, 'rb')
current = {}
Method packages
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def packages
print "\n\e[1m"
print _("Scanning the mirror directory for 'repomd.xml' files...")
print "\e[0m\n"
Method generate_partial_report
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate_partial_report(repo_base_dir, cleaned_files)
cleaned_files_count = cleaned_files.count
cleaned_files_size = cleaned_files.sum(&:file_size)
cleaned_db_entries = cleaned_files.sum(&:db_entries_count)
Method run_package_clean
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run_package_clean(repomd_files)
# Initialize table to keep registry of inodes referencing dangling files/links
@inodes = Hash.new(0)
partial_reports =
Method change_product
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def change_product(target, set_enabled, all_modules)
base_products = fetch_base_product target
base_products.each do |base_product|
products = [base_product]
Method main
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def main
OptionParser.new do |opts|
opts.banner += ' [Repositories]'
opts.separator 'Get repository CDN tokens'
opts.version = '0.0.1'
Method create_product_activation
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def create_product_activation
activation = @system.activations.where(service_id: @product.service.id).first_or_create
# in BYOS mode, we rely on the activation being performed in
# `engines/scc_proxy/lib/scc_proxy/engine.rb` and don't need further checks here
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method scc_deactivate_product
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
def scc_deactivate_product
auth = request.headers['HTTP_AUTHORIZATION']
if @system.proxy_byos && @product[:product_type] != 'base'
response = SccProxy.deactivate_product_scc(auth, @product, @system.system_token)
unless response.code_type == Net::HTTPOK
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method authenticate_system
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def authenticate_system(skip_on_duplicated: false)
authenticate_or_request_with_http_basic('RMT API') do |login, password|
@systems = System.get_by_credentials(login, password)
if @systems.present?
# Return now if we just detected duplicates and we were told to skip on
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"