engines/scc_proxy/lib/scc_proxy/engine.rb

Summary

Maintainability
D
1 day
Test Coverage

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
Severity: Minor
Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 3 hrs to fix

    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
    Severity: Minor
    Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 2 hrs to fix

    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
    Severity: Minor
    Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 1 hr to fix

      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 }
      
      
      Severity: Minor
      Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 1 hr to fix

      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
      Severity: Minor
      Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 55 mins to fix

      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])
      Severity: Minor
      Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 45 mins to fix

      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
      Severity: Minor
      Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 45 mins to fix

      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)
      Severity: Minor
      Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 35 mins to fix

        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
        
        
        Severity: Minor
        Found in engines/scc_proxy/lib/scc_proxy/engine.rb - About 35 mins to fix

        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

        There are no issues that match your filters.

        Category
        Status