fgrehm/vagrant-lxc

View on GitHub

Showing 28 of 30 total issues

Class Driver has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Driver
      # This is raised if the container can't be found when initializing it with
      # a name.
      class ContainerNotFound < StandardError; end

Severity: Minor
Found in lib/vagrant-lxc/driver.rb - About 3 hrs to fix

    Method prepare has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def prepare(machine, folders, _opts)
            machine.ui.output(I18n.t("vagrant.actions.lxc.share_folders.preparing"))
            # short guestpaths first, so we don't step on ourselves
            folders = folders.sort_by do |id, data|
              if data[:guestpath]
    Severity: Minor
    Found in lib/vagrant-lxc/synced_folder.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 configure_private_network has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip)
            @logger.info "Configuring network interface for #{container_name} using #{ip} and bridge #{bridge_name}"
            if ip
              ip += '/24'
            end
    Severity: Minor
    Found in lib/vagrant-lxc/driver.rb - About 1 hr to fix

      Method call has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def call(env)
                config = env[:machine].provider_config
                container_name = config.container_name
      
                case container_name
      Severity: Minor
      Found in lib/vagrant-lxc/action/create.rb - About 1 hr to fix

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

                def call(env)
                  @env = env
        
                  if redir_pids.any?
                    env[:ui].info I18n.t("vagrant.actions.vm.clear_forward_ports.deleting")
        Severity: Minor
        Found in lib/vagrant-lxc/action/clear_forwarded_ports.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 prepare has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def prepare(machine, folders, _opts)
                machine.ui.output(I18n.t("vagrant.actions.lxc.share_folders.preparing"))
                # short guestpaths first, so we don't step on ourselves
                folders = folders.sort_by do |id, data|
                  if data[:guestpath]
        Severity: Minor
        Found in lib/vagrant-lxc/synced_folder.rb - About 1 hr to fix

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

                def execute(*command, &block)
                  # Get the options hash if it exists
                  opts = {}
                  opts = command.pop if command.last.is_a?(Hash)
          
          
          Severity: Minor
          Found in lib/vagrant-lxc/sudo_wrapper.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 has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def create(template, backingstore, backingstore_options, config_file, template_opts = {})
                    if config_file
                      config_opts = ['-f', config_file]
                    end
          
          
          Severity: Minor
          Found in lib/vagrant-lxc/driver/cli.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 call has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def call(env)
                    config = env[:machine].provider_config
                    container_name = config.container_name
          
                    case container_name
          Severity: Minor
          Found in lib/vagrant-lxc/action/create.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 remove_bridges_that_are_not_in_use has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def remove_bridges_that_are_not_in_use(env)
                    env[:machine].config.vm.networks.find do |type, config|
                      next if type.to_sym != :private_network
          
                      bridge = config.fetch(:lxc__bridge_name)
          Severity: Minor
          Found in lib/vagrant-lxc/action/gc_private_network_bridges.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 action_provision has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.action_provision
                  Builder.new.tap do |b|
                    b.use Builtin::ConfigValidate
                    b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2|
                      if env1[:result]
          Severity: Minor
          Found in lib/vagrant-lxc/action.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 action_ssh_run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.action_ssh_run
                  Builder.new.tap do |b|
                    b.use Builtin::ConfigValidate
                    b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2|
                      if env[:result]
          Severity: Minor
          Found in lib/vagrant-lxc/action.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 action_destroy has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.action_destroy
                  Builder.new.tap do |b|
                    b.use Builtin::Call, Builtin::IsState, :not_created do |env1, b2|
                      if env1[:result]
                        b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
          Severity: Minor
          Found in lib/vagrant-lxc/action.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 compile_forwarded_ports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def compile_forwarded_ports(config)
                    mappings = {}
          
                    config.vm.networks.each do |type, options|
                      next if options[:disabled]
          Severity: Minor
          Found in lib/vagrant-lxc/action/forward_ports.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 action_ssh has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.action_ssh
                  Builder.new.tap do |b|
                    b.use Builtin::ConfigValidate
                    b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2|
                      if env[:result]
          Severity: Minor
          Found in lib/vagrant-lxc/action.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 create has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {})
          Severity: Minor
          Found in lib/vagrant-lxc/driver.rb - About 45 mins to fix

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

                  def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip)
                    @logger.info "Configuring network interface for #{container_name} using #{ip} and bridge #{bridge_name}"
                    if ip
                      ip += '/24'
                    end
            Severity: Minor
            Found in lib/vagrant-lxc/driver.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 run has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def run(*command)
                    options = command.last.is_a?(Hash) ? command.last : {}
            
                    # Avoid running LXC commands with a restrictive umask.
                    # Otherwise disasters occur, like the container root directory
            Severity: Minor
            Found in lib/vagrant-lxc/sudo_wrapper.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 action_halt has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                  def self.action_halt
                    Builder.new.tap do |b|
                      b.use Builtin::Call, Builtin::IsState, :not_created do |env, b2|
                        if env[:result]
                          b2.use Builtin::Message, I18n.t("vagrant_lxc.messages.not_created")
            Severity: Minor
            Found in lib/vagrant-lxc/action.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 configure_private_network has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                  def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip)
            Severity: Minor
            Found in lib/vagrant-lxc/driver.rb - About 35 mins to fix
              Severity
              Category
              Status
              Source
              Language