sibprogrammer/owp

View on GitHub

Showing 108 of 803 total issues

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

  def sync_backups
    backups_list = rpc_client.exec('ls', "--block-size=M -s #{backups_dir}")['output']
    backups_list = backups_list.split("\n")
    # remove totals line
    backups_list.shift
Severity: Minor
Found in app/models/hardware_server.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 profile has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def profile
    @page_title = t('admin.my_profile.title')

    if request.post?
      if !params[:password].blank?
Severity: Minor
Found in app/controllers/iphone/users_controller.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 get_stats has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def get_stats
      [
        [
          'user.png',
          t('admin.dashboard.stats_grid.parameter.panel_users'),
Severity: Minor
Found in app/controllers/application.rb - About 1 hr to fix

    Method save_physically has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def save_physically
        return false if !valid?
    
        content = ""
        content << 'ONBOOT="' + (start_on_boot ? "yes" : "no") + '"' + "\n"
    Severity: Minor
    Found in app/models/server_template.rb - About 1 hr to fix

      Method create_backup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.create_backup(virtual_server, ve_state, description)
          orig_ve_state = virtual_server.state
          if 'running' == orig_ve_state
            case ve_state
              when 'suspend' then virtual_server.suspend
      Severity: Minor
      Found in app/models/backup.rb - About 1 hr to fix

        Method owp_ConfigOptions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function owp_ConfigOptions()
        {
            $nodes = array();
            $serverTemplates = array();
            $osTempates = array();
        Severity: Minor
        Found in utils/whmcs/owp/owp.php - About 1 hr to fix

          Method _owp_apiCall has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function _owp_apiCall($method, $params = '') 
          {
              $queryResult = mysql_query("SELECT * FROM `tblservers` WHERE `type` = 'owp' LIMIT 1");
              $serverInfo = mysql_fetch_array($queryResult);
          
          
          Severity: Minor
          Found in utils/whmcs/owp/owp.php - About 1 hr to fix

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

                def get_virtual_servers_map(virtual_servers)
                  virtual_servers = virtual_servers.map do |virtual_server|
                    {
                      :id => virtual_server.id,
                      :identity => virtual_server.identity,
            Severity: Minor
            Found in app/controllers/admin/base.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
                return if 0 == IpPool.count or ip_address.blank? or !ip_address_changed?
                return if 'auto' == ip_address
            
                old_ips = ip_address_was.blank? ? [] : ip_address_was.split(' ')
            Severity: Minor
            Found in app/models/virtual_server.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 collect_beancounters has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def collect_beancounters(hardware_server)
                counters = hardware_server.rpc_client.exec('cat', "/proc/user_beancounters")['output'].split("\n")
            
                # remove table titles
                counters.shift; counters.shift
            Severity: Minor
            Found in utils/watchdog/watchdog.rb - About 1 hr to fix

              Method collect_cpu_usage has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def collect_cpu_usage(hardware_server)
                  ve_list = hardware_server.virtual_servers.find_all_by_state('running').map(&:identity).join(' ')
                  command = "for VE in #{ve_list}; do echo $VE `vzctl exec $VE 'cat /proc/stat | head -1'`; done"
                  counters = hardware_server.rpc_client.exec(command)['output'].split("\n")
              
              
              Severity: Minor
              Found in utils/watchdog/watchdog.rb - About 1 hr to fix

                Method save_limits has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def save_limits(limits)
                    orig_limits = get_limits
                    vzctl_params = ''
                    limits.each do |limit|
                      orig_limit = orig_limits.find { |item| item[:name] == limit['name'] }
                Severity: Minor
                Found in app/models/virtual_server.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 prepare_daemon_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def prepare_daemon_config(sftp, config_file)
                      if !sftp_file_readable(sftp, config_file)
                        upload_daemon_config(sftp, config_file)
                      else
                        sftp.file.open(config_file, "r") do |file|
                Severity: Minor
                Found in app/models/hardware_server.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 load_config has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def load_config
                    file = File.new(CONFIG_FILE, 'r')
                
                    while (line = file.gets)
                      key, value = line.split('=', 2).each { |v| v.strip! }
                Severity: Minor
                Found in utils/hw-daemon/hw-daemon.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 get_ram_mb has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def get_ram_mb(limit)
                    return 0 if limit.blank?
                    limit = limit.include?(':') ? limit.split(":").last : limit
                    return 0 if ('unlimited' == limit)
                
                
                Severity: Minor
                Found in app/helpers/application_helper.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 objects_group_operation has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def objects_group_operation(model, operation, &access)
                      success = true
                
                      params[:ids].split(',').each do |id|
                        object = model.find(id)
                Severity: Minor
                Found in app/controllers/admin/base.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 clone_physically has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def clone_physically(orig_server)
                    return false if !valid?
                
                    path = '/etc/vz/conf'
                    hardware_server.rpc_client.exec("cp #{shellescape(path)}/#{shellescape(orig_server.identity.to_s)}.conf #{shellescape(path)}/#{shellescape(identity.to_s)}.conf")
                Severity: Minor
                Found in app/models/virtual_server.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 update has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def update
                    role = (params[:id].to_i > 0) ? Role.find_by_id(params[:id]) : Role.new
                    is_new = role.new_record?
                    role.attributes = params
                
                
                Severity: Minor
                Found in app/controllers/admin/roles_controller.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 collect_cpu_usage has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def collect_cpu_usage(hardware_server)
                    ve_list = hardware_server.virtual_servers.find_all_by_state('running').map(&:identity).join(' ')
                    command = "for VE in #{ve_list}; do echo $VE `vzctl exec $VE 'cat /proc/stat | head -1'`; done"
                    counters = hardware_server.rpc_client.exec(command)['output'].split("\n")
                
                
                Severity: Minor
                Found in utils/watchdog/watchdog.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 connect has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                  def connect(root_password = '')
                    if !auth_key.blank?
                      begin
                        if !rpc_client.ping
                          self.errors.add :auth_key, :bad_auth
                Severity: Minor
                Found in app/models/hardware_server.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

                Severity
                Category
                Status
                Source
                Language