amahi/platform

View on GitHub

Showing 88 of 112 total issues

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

    def simple_remote_checkbox options
        parsed_options = {}
        parsed_options[:checked] = 'checked' if options[:checked]
        parsed_options[:disabled] = 'disabled' if options[:disabled]

Severity: Minor
Found in app/helpers/application_helper.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_address? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def valid_address?(addr)
        return false if addr.nil?
        # NOTE: do not allow aliases to the hda as a blank address
        return false if addr.blank?
        return false unless (addr =~ VALID_ADDRESS)
Severity: Minor
Found in app/controllers/aliases_controller.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 install_webapp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def install_webapp(installer, source)

        name = webapp_name(installer.url_name)
        path = WEBAPP_PATH % name

Severity: Minor
Found in app/models/app.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 service_start_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def service_start_command(name)
            service = service_name(name)
            if fedora? or arch? or centos?
                "/usr/bin/systemctl start #{service}.service"
            elsif ubuntu? and File.exist?(UPSTART_CONF % service)
Severity: Minor
Found in lib/platform.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 service_stop_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def service_stop_command(name)
            service = service_name(name)
            if fedora? or arch? or centos?
                "/usr/bin/systemctl stop #{service}.service"
            elsif ubuntu? and File.exist?(UPSTART_CONF % service)
Severity: Minor
Found in lib/platform.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 read_lease has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.read_lease(file)
        res = []
        return res unless File.exists?(file)
        current = {}
        File.foreach(file) do |line|
Severity: Minor
Found in lib/leases.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize
        @file = '/etc/mtab'
        @info = []
        begin
            f = File.open('/etc/mtab')
Severity: Minor
Found in lib/partition_utils.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 update_pubkey has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def update_pubkey
        sleep 2 if development?
        @user = User.find(params[:id])
        # sleep a little to see the spinner working well
        unless @user
Severity: Minor
Found in plugins/010-users/app/controllers/users_controller.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 service_disable_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def service_disable_command(name)
            service = service_name(name)
            if fedora? or arch? or centos?
                "/usr/bin/systemctl enable #{service}.service"
            elsif ubuntu? and File.exist?(UPSTART_CONF % service)
Severity: Minor
Found in lib/platform.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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def create
        nm = params[:name]
        path = params[:path]
        if nm.nil? or nm.blank? or ((not (valid_name?(nm))) or (nm.size > 32) or (path.size > 64))
            flash.now[:error] = "Bad share name!"
Severity: Minor
Found in app/controllers/share_controller.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 service_enable_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def service_enable_command(name)
            service = service_name(name)
            if fedora? or arch? or centos?
                "/usr/bin/systemctl enable #{service}.service"
            elsif ubuntu? and File.exist?(UPSTART_CONF % service)
Severity: Minor
Found in lib/platform.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 before_save_hook has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def before_save_hook
        if monitored_changed?
            monitored ? monit_file_add : monit_file_remove
            # DEBUG RAILS_DEFAULT_LOGGER.info "* * * MONITORED CHANGED to #{monitored}"
        end
Severity: Minor
Found in app/models/server.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

Consider simplifying this complex logical expression.
Open

        if params[:button] && params[:button] == "Web"
            require 'uri'
            redirect_to URI.escape("http://www.google.com/search?q=#{params[:query]}")
        else
            @query = params[:query]
Severity: Major
Found in app/controllers/search_controller.rb - About 40 mins to fix

    Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(controller, label, url, parent = nil, advanced = false)
    Severity: Minor
    Found in lib/tab.rb - About 35 mins to fix

      Method toggle_disk_pool_partition has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def toggle_disk_pool_partition
              path = params[:path]
              part = DiskPoolPartition.where(:path=>path).first
              if part
                  # was enabled - disable it by deleting it
      Severity: Minor
      Found in app/controllers/share_controller.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 update_address has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def update_address
              a = DnsAlias.find(params[:id])
              addr = params[:value].strip
              # FIXME - report errors to the user!
              unless valid_address?(addr)
      Severity: Minor
      Found in app/controllers/aliases_controller.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 locate_cache has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def locate_cache(term)
              FileUtils.mkdir_p(SEARCH_CACHE)
              sha1 = Digest::SHA1.hexdigest(term)
              cache = File.join(SEARCH_CACHE, sha1)
              # expire old entries in the cache to prevent accumulation (12 hours, index is 24 hours old)
      Severity: Minor
      Found in app/controllers/search_controller.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 download_direct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.download_direct(url)
      
              redirect_limit = 5
      
              while redirect_limit > 0
      Severity: Minor
      Found in lib/downloader.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

      Avoid too many return statements within this method.
      Open

                  return true
      Severity: Major
      Found in app/controllers/aliases_controller.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return false
        Severity: Major
        Found in app/models/app.rb - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language