fgrehm/vagrant-notify

View on GitHub

Showing 22 of 22 total issues

Method validate has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def validate(machine)
        errors = _detected_errors

        if backed_by_cloud_provider?(machine)
          machine.ui.warn("Disabling vagrant-notify, cloud provider #{machine.provider_name} in use.")
Severity: Minor
Found in lib/vagrant-notify/config.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 action_start_server has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

        def action_start_server
          Vagrant::Action::Builder.new.tap do |b|
            b.use Call, CheckProvider do |env, b2|
              next if !env[:result]

Severity: Minor
Found in lib/vagrant-notify/action.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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

OptionParser.new do |opts|
  opts.on('-u', '--urgency LEVEL')           { |v| options[:u] = v } # Option gets removed
  opts.on('-t', '--expire-time TIME')        { |v| options[:t] = v } # Option gets removed
  opts.on('-a', '--app-name APP_NAME')       { |v| options[:a] = v } # TO DO: Set to -title
  opts.on('-i', '--icon ICON[,ICON...]')     { |v| options[:i] = v } # Option gets removed
Severity: Major
Found in examples/osx/applescript/notify-send.rb and 3 other locations - About 1 hr to fix
examples/osx/growl_for_mac/notify-send.rb on lines 11..18
examples/osx/terminal-notifier/notify-send.rb on lines 11..18
examples/windows/snarl/notify-send.rb on lines 13..20

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

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

OptionParser.new do |opts|
  opts.on('-u', '--urgency LEVEL')           { |v| options[:u] = v } # TO DO: set to priority
  opts.on('-t', '--expire-time TIME')        { |v| options[:t] = v } # Set to timeout (notify-send milliseconds to snarl seconds)
  opts.on('-a', '--app-name APP_NAME')       { |v| options[:a] = v } # Option gets removed
  opts.on('-i', '--icon ICON[,ICON...]')     { |v| options[:i] = v } # Option gets removed (Snarl does not properly handle masked git-bash/cygwin absoute paths)
Severity: Major
Found in examples/windows/snarl/notify-send.rb and 3 other locations - About 1 hr to fix
examples/osx/applescript/notify-send.rb on lines 11..18
examples/osx/growl_for_mac/notify-send.rb on lines 11..18
examples/osx/terminal-notifier/notify-send.rb on lines 11..18

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

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

OptionParser.new do |opts|
  opts.on('-u', '--urgency LEVEL')           { |v| options[:u] = v } # TO DO: set to --priority
  opts.on('-t', '--expire-time TIME')        { |v| options[:t] = v } # Option gets removed
  opts.on('-a', '--app-name APP_NAME')       { |v| options[:a] = v } # Set to --name 
  opts.on('-i', '--icon ICON[,ICON...]')     { |v| options[:i] = v } # Set to --image
Severity: Major
Found in examples/osx/growl_for_mac/notify-send.rb and 3 other locations - About 1 hr to fix
examples/osx/applescript/notify-send.rb on lines 11..18
examples/osx/terminal-notifier/notify-send.rb on lines 11..18
examples/windows/snarl/notify-send.rb on lines 13..20

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

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

Identical blocks of code found in 4 locations. Consider refactoring.
Open

OptionParser.new do |opts|
  opts.on('-u', '--urgency LEVEL')           { |v| options[:u] = v } # Option gets removed
  opts.on('-t', '--expire-time TIME')        { |v| options[:t] = v } # Option gets removed
  opts.on('-a', '--app-name APP_NAME')       { |v| options[:a] = v } # TO DO: Set to -title
  opts.on('-i', '--icon ICON[,ICON...]')     { |v| options[:i] = v } # Option gets removed
Severity: Major
Found in examples/osx/terminal-notifier/notify-send.rb and 3 other locations - About 1 hr to fix
examples/osx/applescript/notify-send.rb on lines 11..18
examples/osx/growl_for_mac/notify-send.rb on lines 11..18
examples/windows/snarl/notify-send.rb on lines 13..20

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

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 execute has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def execute
        options = {}
        opts = OptionParser.new do |o|
          o.banner = 'Usage: vagrant notify'
          o.separator ''
Severity: Minor
Found in lib/vagrant-notify/command.rb - About 1 hr to fix

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

          def execute
            options = {}
            opts = OptionParser.new do |o|
              o.banner = 'Usage: vagrant notify'
              o.separator ''
    Severity: Minor
    Found in lib/vagrant-notify/command.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 call has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

            def call(env)
              message = notify_provision_messages(env) unless env[:machine].config.notify.enable == false
              system(message[:start]) unless env[:machine].config.notify.enable == false
    
              begin
    Severity: Minor
    Found in lib/vagrant-notify/action/notify_provisioning_status.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 action_status_server has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

            def action_status_server
              Vagrant::Action::Builder.new.tap do |b|
                b.use Call, CheckProvider do |env, b2|
                  next if !env[:result]
    
    
    Severity: Minor
    Found in lib/vagrant-notify/action.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 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def validate(machine)
            errors = _detected_errors
    
            if backed_by_cloud_provider?(machine)
              machine.ui.warn("Disabling vagrant-notify, cloud provider #{machine.provider_name} in use.")
    Severity: Minor
    Found in lib/vagrant-notify/config.rb - About 1 hr to fix

      Method run has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def self.run(id, port, bind_ip, sender_app, sender_params_str, sender_params_escape, machine_name='default', provider='virtualbox')
      Severity: Major
      Found in lib/vagrant-notify/server.rb - About 1 hr to fix

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

        if ARGV.length == 0
          puts "No summary specified"
          exit 1
        elsif ARGV.length == 1
          message = "-message '\\#{ARGV[0]}'"
        Severity: Minor
        Found in examples/osx/terminal-notifier/notify-send.rb and 1 other location - About 55 mins to fix
        examples/osx/applescript/notify-send.rb on lines 22..32

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

        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

        if ARGV.length == 0
          puts "No summary specified"
          exit 1
        elsif ARGV.length == 1
          message = "\"#{ARGV[0]}\""
        Severity: Minor
        Found in examples/osx/applescript/notify-send.rb and 1 other location - About 55 mins to fix
        examples/osx/terminal-notifier/notify-send.rb on lines 22..32

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

        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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def initialize(id, sender_app, sender_params_str, sender_params_escape, machine_name = :default, provider = :virtualbox)
        Severity: Minor
        Found in lib/vagrant-notify/server.rb - About 45 mins to fix

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

                  def action_stop_server
                    Vagrant::Action::Builder.new.tap do |b|
                      b.use Call, CheckProvider do |env, b2|
                        next if !env[:result]
          
          
          Severity: Minor
          Found in lib/vagrant-notify/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 valid_process? has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def valid_process?(pid)
                    if RUBY_PLATFORM =~ /mswin|msys|mingw|cygwin|bccwin|wince|emc/
                      Vagrant::Notify::Action::Windows::ProcessInfo.queryProcess(pid) if pid
                    else
                      Process.getpgid(pid.to_i) if pid
          Severity: Minor
          Found in lib/vagrant-notify/action/server_is_running.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 queryProcess has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                    def self.queryProcess(pid)
                      return false unless pid =~ /\A\d+\z/
                      result = `c\:/Windows/System32/wbem/WMIC.exe process where \"ProcessID = '#{pid}'\" get ProcessID,Commandline /format:list 2>nul`
                      querypid = false
                      result.split(/\r?\n/).each do |line|
          Severity: Minor
          Found in lib/vagrant-notify/action/windows/process_info.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 which has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def which(cmd)
                    exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
                    ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
                      exts.each { |ext|
                        exe = File.join(path, "#{cmd}#{ext}")
          Severity: Minor
          Found in lib/vagrant-notify/action/start_server.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 next_available_port has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def next_available_port(bind_ip)
                    # Determine a list of usable ports for us to use
                    usable_ports = Set.new(@env[:machine].config.vm.usable_port_range)
          
                    # Pass one, remove all defined host ports from usable ports
          Severity: Minor
          Found in lib/vagrant-notify/action/start_server.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