SUSE/connect

View on GitHub

Showing 23 of 23 total issues

Method extract_options has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def extract_options # rubocop:disable MethodLength
        @opts = OptionParser.new

        @opts.separator 'Register SUSE Linux Enterprise installations with the SUSE Customer Center.'
        @opts.separator 'Registration allows access to software repositories (including updates)'
Severity: Major
Found in lib/suse/connect/cli.rb - About 4 hrs to fix

    Method execute! has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

          def execute! # rubocop:disable MethodLength, CyclomaticComplexity, PerceivedComplexity, AbcSize
            # check for parameter dependencies
            if @config.status
              status.print_product_statuses(:json)
            elsif @config.status_text
    Severity: Minor
    Found in lib/suse/connect/cli.rb - About 3 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 execute! has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def execute! # rubocop:disable MethodLength, CyclomaticComplexity, PerceivedComplexity, AbcSize
            # check for parameter dependencies
            if @config.status
              status.print_product_statuses(:json)
            elsif @config.status_text
    Severity: Major
    Found in lib/suse/connect/cli.rb - About 2 hrs to fix

      Class Client has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Client
            include SUSE::Toolkit::Utilities
            include Logger
      
            attr_reader :config, :api
      Severity: Minor
      Found in lib/suse/connect/client.rb - About 2 hrs to fix

        Method json_request has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

              def json_request(method, path, params = {})
                # for :get requests, the params need to go to the url, for other requests into the body
                if method == :get
                  request = VERB_TO_CLASS[method].new(path_with_params(path, params))
                else
        Severity: Minor
        Found in lib/suse/connect/connection.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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def execute(cmd, quiet = true, valid_exit_codes = [0]) # rubocop:disable CyclomaticComplexity
                log.debug("Executing: '#{cmd}' Quiet: #{quiet}")
                output, error, status = execute_raw(cmd)
        
                # Catching interactive failures of zypper. --non-interactive always returns with exit code 0 here
        Severity: Minor
        Found in lib/suse/toolkit/system_calls.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 json_product_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def json_product_status
                statuses = product_statuses.map do |product_status|
                  status = {}
                  status[:identifier] = product_status.installed_product.identifier
                  status[:version] = product_status.installed_product.version
        Severity: Minor
        Found in lib/suse/connect/status.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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

              def announce_system(auth, distro_target = nil, instance_data = nil, namespace = nil)
                payload = {
                  hostname:      System.hostname,
                  hwinfo:        System.hwinfo,
                  distro_target: distro_target || Zypper.distro_target
        Severity: Minor
        Found in lib/suse/connect/api.rb and 1 other location - About 45 mins to fix
        lib/suse/connect/api.rb on lines 75..84

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 41.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

              def update_system(auth, distro_target = nil, instance_data = nil, namespace = nil)
                payload = {
                  hostname:      System.hostname,
                  hwinfo:        System.hwinfo,
                  distro_target: distro_target || Zypper.distro_target
        Severity: Minor
        Found in lib/suse/connect/api.rb and 1 other location - About 45 mins to fix
        lib/suse/connect/api.rb on lines 55..65

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 41.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method uuid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def uuid
              if File.exist?('/sys/hypervisor/uuid')
                # INFO: bnc#890881 read the uuid generated by the hypervisor (SLES for EC2)
                File.read('/sys/hypervisor/uuid').chomp
              else
        Severity: Minor
        Found in lib/suse/connect/hwinfo/x86.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 print_information has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def print_information(action)
                server = (@config.url == 'https://scc.suse.com') ? 'SUSE Customer Center' : "registration proxy #{@config.url}"
                if action == :register
                  log.info "Registering system to #{server}".bold if @config.url
                elsif @config.url
        Severity: Minor
        Found in lib/suse/connect/client.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 uuid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def uuid
              if File.exist?('/sys/hypervisor/uuid')
                # INFO: bnc#890881 read the uuid generated by the hypervisor (SLES for EC2)
                File.read('/sys/hypervisor/uuid').chomp
              else
        Severity: Minor
        Found in lib/suse/connect/hwinfo/arm64.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 system_migrations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def system_migrations(auth, products, target_base_product: nil, kind:)
                payload = { installed_products: products.map(&:to_params) }
                payload[:target_base_product] = target_base_product.to_params if target_base_product
                endpoints = {
                  online: '/connect/systems/products/migrations',
        Severity: Minor
        Found in lib/suse/connect/api.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

        Method deregister! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def deregister!
                if File.exist?('/usr/sbin/registercloudguest') && !@config.product
                  # exclude the product as de-registering a product
                  # through SUSEConnect while having registercloudguest set is
                  # allowed for SCC as proxy cases
        Severity: Minor
        Found in lib/suse/connect/client.rb - About 25 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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            def output
              @output ||= execute('lscpu', false).split("\n").each_with_object({}) do |line, hash|
                k, v = line.split(':')
                hash[k] = v.strip if v
              end
        Severity: Minor
        Found in lib/suse/connect/hwinfo/x86.rb and 1 other location - About 25 mins to fix
        lib/suse/connect/hwinfo/arm64.rb on lines 43..48

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 30.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            def output
              @output ||= execute('lscpu', false).split("\n").each_with_object({}) do |line, hash|
                k, v = line.split(':')
                hash[k] = v.strip if v
              end
        Severity: Minor
        Found in lib/suse/connect/hwinfo/arm64.rb and 1 other location - About 25 mins to fix
        lib/suse/connect/hwinfo/x86.rb on lines 40..45

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 30.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Method extract_extensions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def extract_extensions(product)
                extensions = []
                product.extensions.each do |extension|
                  extensions << {
                    available: extension.available.nil? ? true : extension.available,
        Severity: Minor
        Found in lib/suse/connect/status.rb - About 25 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 initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(endpoint, language: nil, insecure: false, debug: false, verify_callback: nil)
                endpoint         = prefix_protocol(endpoint)
                uri              = URI.parse(endpoint)
                http             = Net::HTTP.new(uri.host, uri.port)
        
        
        Severity: Minor
        Found in lib/suse/connect/connection.rb - About 25 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 update_system_token! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def update_system_token!(response)
                return unless System.credentials?
        
                value = response.to_hash[SUSE::Toolkit::Utilities::SYSTEM_TOKEN_HEADER.downcase]
                token = value.first.strip unless value.nil? || value.first.nil?
        Severity: Minor
        Found in lib/suse/connect/connection.rb - About 25 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 verify_callback= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def verify_callback=(callback)
                if callback
                  log.debug "Using custom verify_callback: #{callback.source_location.map(&:to_s).join(':')}"
                  http.verify_callback = callback
                else
        Severity: Minor
        Found in lib/suse/connect/connection.rb - About 25 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

        Severity
        Category
        Status
        Source
        Language