fgrehm/vagrant-lxc

View on GitHub

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

      Similar blocks of code found in 2 locations. 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: Major
      Found in lib/vagrant-lxc/action.rb and 1 other location - About 1 hr to fix
      lib/vagrant-lxc/action.rb on lines 190..206

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

      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 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: Major
      Found in lib/vagrant-lxc/action.rb and 1 other location - About 1 hr to fix
      lib/vagrant-lxc/action.rb on lines 64..80

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

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

            Severity
            Category
            Status
            Source
            Language