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 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 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 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 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 scc_activate_product
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def scc_activate_product
logger.info "Activating product #{@product.product_string} to SCC"
auth = request.headers['HTTP_AUTHORIZATION']
if @system.proxy_byos
response = SccProxy.scc_activate_product(@product, auth, params[:token], params[:email])
- 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_deregistration
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def scc_deregistration
if @system.proxy_byos
auth = request.headers['HTTP_AUTHORIZATION']
response = SccProxy.deregister_system_scc(auth, @system.system_token)
unless response.code_type == Net::HTTPNoContent
- 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 prepare_scc_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def prepare_scc_request(uri_path, product, auth, token, email)
Method announce_system
has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring. Open
def announce_system
auth_header = nil
auth_header = request.headers['HTTP_AUTHORIZATION'] if request.headers.include?('HTTP_AUTHORIZATION')
system_information = hwinfo_params[:hwinfo].to_json
- 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"