BaxterStockman/vagrant-ansible_auto

View on GitHub
lib/vagrant/ansible_auto/inventory.rb

Summary

Maintainability
B
5 hrs
Test Coverage

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

    There are no issues that match your filters.

    Category
    Status