BaxterStockman/vagrant-ansible_auto

View on GitHub

Showing 17 of 17 total issues

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

      def finalize!
        super
        @inventory.groups                   = @groups                             unless @groups                          == UNSET_VALUE
        @inventory.vars                     = @vars                               unless @vars                            == UNSET_VALUE
        @inventory.children                 = @children                           unless @children                        == UNSET_VALUE
Severity: Minor
Found in lib/vagrant/ansible_auto/config.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 with_default_gateway_addresses has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

              def with_default_gateway_addresses(machine)
                return enum_for(__method__, machine) unless block_given?

                machine.communicate.execute('ip route show', error_check: false) do |type, data|
                  if type == :stdout
Severity: Minor
Found in lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.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

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

    class Inventory
      include VagrantPlugins::AnsibleAuto::Util::Config

      UNNAMED_GROUP = '_'.freeze

Severity: Minor
Found in lib/vagrant/ansible_auto/inventory.rb - About 2 hrs to fix

    Method with_candidate_addresses has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

                  def with_candidate_addresses(machine)
                    return enum_for(__method__, machine) unless block_given?
    
                    seen_candidates = Set.new
                    yield_unseen_candidate = lambda do |host_and_port|
    Severity: Minor
    Found in lib/vagrant/ansible_auto/cap/guest/posix/ssh_server_address.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 groups= has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

          def groups=(new_groups)
            @groups = nil
    
            new_groups.each do |group_heading, entries|
              group, type = parse_group_heading(group_heading)
    Severity: Minor
    Found in lib/vagrant/ansible_auto/inventory.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 provision has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

          def provision
            @config = @__ansible_config.merge(config)
    
            return super unless machine.guest.capability?(:ssh_server_address)
    
    
    Severity: Minor
    Found in lib/vagrant/ansible_auto/provisioner.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 with_candidate_addresses has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                  def with_candidate_addresses(machine)
                    return enum_for(__method__, machine) unless block_given?
    
                    seen_candidates = Set.new
                    yield_unseen_candidate = lambda do |host_and_port|
    Severity: Minor
    Found in lib/vagrant/ansible_auto/cap/guest/posix/ssh_server_address.rb - About 1 hr to fix

      Method with_open_ports has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

                    def with_open_ports(machine, target_machine = nil)
                      return enum_for(__method__, machine, target_machine) unless block_given?
      
                      return unless machine.guest.capability?(:port_open?)
      
      
      Severity: Minor
      Found in lib/vagrant/ansible_auto/cap/guest/posix/ssh_server_address.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 validate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate(machine)
              super
      
              errors = _detected_errors + @__errors
      
      
      Severity: Minor
      Found in lib/vagrant/ansible_auto/config.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 fetch_public_key has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                    def fetch_public_key(machine, path)
                      return unless machine.guest.capability?(:executable_installed?) \
                        && machine.guest.capability(:executable_installed?, 'ssh-keygen')
      
                      public_key = ''
      Severity: Minor
      Found in lib/vagrant/ansible_auto/cap/guest/posix/public_key.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 merge! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def merge!(other)
                if block_given?
                  other.each do |key, value|
                    convert_key(key).tap do |ckey|
                      self[ckey] = if key? ckey
      Severity: Minor
      Found in lib/vagrant/ansible_auto/util/hash_with_indifferent_access.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 parse_superclass has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def parse_superclass(superclass)
              return nil unless superclass
      
              case superclass.type
              when :call, :command_call
      Severity: Minor
      Found in yard/extensions.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 add_host has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def add_host(host, hostvars = nil)
              hosts.add case host
                        when Host
                          host.tap { |h| h.hostvars = hostvars unless hostvars.nil? }
                        when String, Symbol
      Severity: Minor
      Found in lib/vagrant/ansible_auto/inventory.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 with_ini_lines_groups has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def with_ini_lines_groups
              return enum_for(__method__) unless block_given?
      
              to_h.tap { |h| h.delete(UNNAMED_GROUP) }.sort.each do |group, entries|
                yield "[#{group}]"
      Severity: Minor
      Found in lib/vagrant/ansible_auto/inventory.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

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

                      machine.communicate.execute('ip route show', error_check: false) do |type, data|
                        if type == :stdout
                          data.each_line { |l| yield l.split[2] if l.start_with? 'default' }
      Severity: Minor
      Found in lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb and 2 other locations - About 15 mins to fix
      lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb on lines 29..31
      lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb on lines 35..37

      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 26.

      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 3 locations. Consider refactoring.
      Open

                      machine.communicate.execute('route -n', error_check: false) do |type, data|
                        if type == :stdout
                          data.each_line { |l| yield l.split[1] if l.start_with? '0.0.0.0' }
      Severity: Minor
      Found in lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb and 2 other locations - About 15 mins to fix
      lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb on lines 23..25
      lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb on lines 35..37

      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 26.

      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 3 locations. Consider refactoring.
      Open

                      machine.communicate.execute('netstat -rn', error_check: false) do |type, data|
                        if type == :stdout
                          data.each_line { |l| yield l.split[1] if l.start_with? '0.0.0.0' }
      Severity: Minor
      Found in lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb and 2 other locations - About 15 mins to fix
      lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb on lines 23..25
      lib/vagrant/ansible_auto/cap/guest/posix/gateway_addresses.rb on lines 29..31

      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 26.

      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

      Severity
      Category
      Status
      Source
      Language