ingenerator/vagrant-mirror

View on GitHub

Showing 8 of 10 total issues

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

        def execute(mirrors, env)
          ui = env[:ui]
          ui.info("Beginning directory mirroring")

          begin
Severity: Minor
Found in lib/vagrant-mirror/middleware/mirror.rb - About 6 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 execute has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def execute(mirrors, env)
          ui = env[:ui]
          ui.info("Beginning directory mirroring")

          begin
Severity: Minor
Found in lib/vagrant-mirror/middleware/mirror.rb - About 1 hr to fix

    Method execute has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def execute(mirrors, env)
              ui = env[:ui]
              ui.info("Beginning directory synchronisation at " + DateTime.now.iso8601)
    
              begin
    Severity: Minor
    Found in lib/vagrant-mirror/middleware/sync.rb - About 1 hr to fix

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

              def execute(mirrors, env)
                ui = env[:ui]
                ui.info("Beginning directory synchronisation at " + DateTime.now.iso8601)
      
                begin
      Severity: Minor
      Found in lib/vagrant-mirror/middleware/sync.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 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate(env, errors)
              folders.each do | folder |
                errors.add("vagrant-mirror cannot mirror an empty or nil host path") if (folder[:name].nil? || folder[:name].empty?)
                errors.add("vagrant-mirror cannot mirror an empty or nil guest path") if (folder[:guest_path].nil? || folder[:guest_path].empty?)
                valid_opts = [:name, :guest_path, :delete, :beep, :exclude, :symlinks]
      Severity: Minor
      Found in lib/vagrant-mirror/config.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

      Avoid deeply nested control flow statements.
      Open

                              if (mirror_config[:beep])
                                print "\a"
                              end
      Severity: Major
      Found in lib/vagrant-mirror/middleware/mirror.rb - About 45 mins to fix

        Avoid too many return statements within this method.
        Open

                    return help
        Severity: Major
        Found in lib/vagrant-mirror/command.rb - About 30 mins to fix

          Method exclude? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def exclude?(path, mirror_config)
                    compiled_excludes = mirror_config.fetch(:compiled_excludes, {})
                    excluded = false
          
                    mirror_config[:exclude].each do | exclude |
          Severity: Minor
          Found in lib/vagrant-mirror/middleware/mirror.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

          Severity
          Category
          Status
          Source
          Language