ManageIQ/ovirt

View on GitHub

Showing 54 of 54 total issues

Class Service has 58 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Service
    include Logging

    DEFAULT_OPTIONS  = {}
    REQUIRED_OPTIONS = [:server, :username, :password]
Severity: Major
Found in lib/ovirt/service.rb - About 1 day to fix

    File event.rb has 486 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Ovirt
      class Event < Base
        self.top_level_strings    = [:description, :severity]
        self.top_level_integers   = [:code]
        self.top_level_timestamps = [:time]
    Severity: Minor
    Found in lib/ovirt/event.rb - About 7 hrs to fix

      Class Base has 46 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Base
          extend Logging
          include Logging
      
          def self.create_from_xml(service, xml)
      Severity: Minor
      Found in lib/ovirt/base.rb - About 6 hrs to fix

        File service.rb has 371 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require 'nokogiri'
        require 'openssl'
        require 'rest-client'
        require 'tempfile'
        require 'uri'
        Severity: Minor
        Found in lib/ovirt/service.rb - About 4 hrs to fix

          Class Vm has 34 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class Vm < Template
              self.top_level_strings    = [:name, :origin, :type, :description]
              self.top_level_booleans   = [:stateless]
              self.top_level_integers   = [:memory]
              self.top_level_timestamps = [:creation_time, :start_time]
          Severity: Minor
          Found in lib/ovirt/vm.rb - About 4 hrs to fix

            Method build_clone_xml has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
            Open

                def build_clone_xml(options)
                  builder = Nokogiri::XML::Builder.new do |xml|
                    xml.vm do
                      xml.name options[:name]
                      xml.cluster(:id => Base.object_to_id(options[:cluster]))
            Severity: Minor
            Found in lib/ovirt/template.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

            File vm.rb has 304 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            require_relative 'legacy_support/cloud_init_via_floppy_payload'
            
            module Ovirt
              class Vm < Template
                self.top_level_strings    = [:name, :origin, :type, :description]
            Severity: Minor
            Found in lib/ovirt/vm.rb - About 3 hrs to fix

              File base.rb has 285 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              module Ovirt
                class Base
                  extend Logging
                  include Logging
              
              
              Severity: Minor
              Found in lib/ovirt/base.rb - About 2 hrs to fix

                Cyclomatic complexity for build_clone_xml is too high. [15/11]
                Open

                    def build_clone_xml(options)
                      builder = Nokogiri::XML::Builder.new do |xml|
                        xml.vm do
                          xml.name options[:name]
                          xml.cluster(:id => Base.object_to_id(options[:cluster]))
                Severity: Minor
                Found in lib/ovirt/template.rb by rubocop

                Checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

                An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one. Blocks that are calls to builtin iteration methods (e.g. `ary.map{...}) also add one, others are ignored.

                def each_child_node(*types)               # count begins: 1
                  unless block_given?                     # unless: +1
                    return to_enum(__method__, *types)
                
                  children.each do |child|                # each{}: +1
                    next unless child.is_a?(Node)         # unless: +1
                
                    yield child if types.empty? ||        # if: +1, ||: +1
                                   types.include?(child.type)
                  end
                
                  self
                end                                       # total: 6

                Method xml_to_hash has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    def self.xml_to_hash(xml)
                      node                          = xml_to_nokogiri(xml)
                      hash                          = hash_from_id_and_href(node)
                      hash[:relationships]          = xml_to_relationships(node)
                      hash[:actions]                = xml_to_actions(node)
                Severity: Minor
                Found in lib/ovirt/base.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 parse_node_extended has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def self.parse_node_extended(node, hash)
                      hash[:relationships][:host_nics] = hash[:relationships].delete(:nics)
                
                      parse_first_node(node, :certificate, hash,
                                       :node => [:organization, :subject])
                Severity: Minor
                Found in lib/ovirt/host.rb - About 1 hr to fix

                  Method build_clone_xml has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def build_clone_xml(options)
                        builder = Nokogiri::XML::Builder.new do |xml|
                          xml.vm do
                            xml.name options[:name]
                            xml.cluster(:id => Base.object_to_id(options[:cluster]))
                  Severity: Minor
                  Found in lib/ovirt/template.rb - About 1 hr to fix

                    Method resource_verb has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def resource_verb(path, verb, *args)
                          log_header = "#{self.class.name}#resource_#{verb}"
                          resource   = create_resource(path)
                          logger.info "#{log_header}: Sending URL: <#{resource.url}>"
                          logger.debug "#{log_header}: With args: <#{args.inspect}>"
                    Severity: Minor
                    Found in lib/ovirt/service.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 api_uri has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def api_uri(path = nil)
                          # Calculate the complete URI:
                          uri = URI.join(base_uri, api_path).to_s
                    
                          # The path passed to this method will have the "/api" prefix if it comes from the "ems_ref"
                    Severity: Minor
                    Found in lib/ovirt/service.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 create_disk has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def create_disk(options = {})
                          create_device("disk") do |xml|
                            [:name, :interface, :format, :size, :type].each do |key|
                              next if options[key].blank?
                              xml.send("#{key}_", options[key])
                    Severity: Minor
                    Found in lib/ovirt/vm.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 resource_verb has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def resource_verb(path, verb, *args)
                          log_header = "#{self.class.name}#resource_#{verb}"
                          resource   = create_resource(path)
                          logger.info "#{log_header}: Sending URL: <#{resource.url}>"
                          logger.debug "#{log_header}: With args: <#{args.inspect}>"
                    Severity: Minor
                    Found in lib/ovirt/service.rb - About 1 hr to fix

                      Method create_nic has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def create_nic(options = {})
                            create_device("nic") do |xml|
                              xml.name      options[:name]
                              xml.interface options[:interface] unless options[:interface].blank?
                              xml.network(:id => options[:network_id]) unless options[:network_id].blank?
                      Severity: Minor
                      Found in lib/ovirt/vm.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 apply_options! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def apply_options!(options)
                            update! do |xml|
                              xml.name options[:name]                     if options[:name]
                              xml.interface options[:interface]           if options[:interface]
                              xml.network(:id => options[:network_id])    if options[:network_id]
                      Severity: Minor
                      Found in lib/ovirt/nic.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 probe_api_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def probe_api_path(uri, path)
                            uri = URI.join(uri, path)
                            request = RestClient::Resource.new(uri.to_s, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)
                            begin
                              request.get
                      Severity: Minor
                      Found in lib/ovirt/service.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 standard_collection has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def standard_collection(uri_suffix, element_name = nil, paginate = false, sort_by = :name, direction = :asc)
                      Severity: Minor
                      Found in lib/ovirt/service.rb - About 35 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language