sibprogrammer/owp

View on GitHub

Showing 108 of 803 total issues

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

  def get_limits
    parser = IniParser.new(hardware_server.rpc_client.exec('cat', "/etc/vz/conf/#{identity.to_s}.conf")['output'])

    limits = [
      'KMEMSIZE', 'LOCKEDPAGES', 'SHMPAGES', 'NUMPROC',
Severity: Minor
Found in app/models/virtual_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

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

  def reinstall
    virtual_server = VirtualServer.find_by_id(params[:id])
    if !virtual_server or !@current_user.can_control(virtual_server) or !@current_user.can_reinstall_ve?
      redirect_to :controller => 'dashboard' and return
    end
Severity: Minor
Found in app/controllers/admin/virtual_servers_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 collect_beancounters has a Cognitive Complexity of 8 (exceeds 5 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 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_daemon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def install_daemon(root_password)
    if root_password.blank?
      self.errors.add :root_password, :empty
      return false
    end
Severity: Minor
Found in app/models/hardware_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

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

  def initialize
    check_environment

    if (0 == ARGV.size)
      do_help
Severity: Minor
Found in utils/hw-daemon/hw-daemon.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 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def initialize(host, auth_key, port, timeout, use_ssl = false)
Severity: Minor
Found in lib/hw_daemon_client.rb - About 35 mins to fix

    Function onRender has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        onRender: function(ct, position){
          Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
          if (this.inputValue !== undefined) {
            this.el.dom.value = this.inputValue;
          }
    Severity: Minor
    Found in public/javascripts/application.js - 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 get_diskspace_mb has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_diskspace_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 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 save_profile has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def save_profile
        if !params[:password].blank?
          if !User.authenticate(@current_user.login, params[:current_password])
            @current_user.errors.add(:current_password, t('admin.my_profile.bad_current_password'))
          end
    Severity: Minor
    Found in app/controllers/admin/users_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 toggle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def toggle
        @request = Request.find_by_id(params[:request_id])
        redirect_to :controller => 'dashboard' and return if !@request or (!@current_user.can_handle_requests? and (@request.user.id != @current_user.id))
    
        @request.opened = @current_user.can_handle_requests? ? !@request.opened : true
    Severity: Minor
    Found in app/controllers/admin/requests_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 get_usage_stats has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_usage_stats(virtual_server)
          is_running = 'running' == virtual_server.real_state
    
          stats = []
    
    
    Severity: Minor
    Found in app/controllers/admin/virtual_servers_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 get_usage_stats has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_usage_stats(virtual_server)
        is_running = 'running' == virtual_server.real_state
    
        stats = []
    
    
    Severity: Minor
    Found in app/controllers/api/virtual_servers_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

    Avoid too many return statements within this method.
    Open

          return false
    Severity: Major
    Found in app/models/hardware_server.rb - About 30 mins to fix

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

        def collect_diskspace(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 'stat -c \"%s %b %a\" -f /'`; done"
          counters = hardware_server.rpc_client.exec(command)['output'].split("\n")
      
      
      Severity: Minor
      Found in utils/watchdog/watchdog.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 save has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def save
          hardware_server = HardwareServer.find_by_id(params[:hardware_server_id])
          redirect_to(:controller => 'hardware_servers', :action => 'list') and return if !hardware_server
      
          server_template = (params[:id].to_i > 0) ? ServerTemplate.find_by_id(params[:id]) : ServerTemplate.new
      Severity: Minor
      Found in app/controllers/admin/server_templates_controller.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

      Function owp_ConfigOptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      function owp_ConfigOptions()
      {
          $nodes = array();
          $serverTemplates = array();
          $osTempates = array();
      Severity: Minor
      Found in utils/whmcs/owp/owp.php - 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 restore_password has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def restore_password
          if request.post?
            user = User.find_by_login(params[:login])
            render(:json => { :success => false, :message => t('restore_password.error.user_not_found') }) and return if !user
            render(:json => { :success => false, :message => t('restore_password.error.no_email') }) and return if user.email.blank?
      Severity: Minor
      Found in app/controllers/sessions_controller.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

      Function groupAction has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      Owp.list.groupAction = function(config) {
        config = Ext.apply({
          gridName: '',
          url: '',
          command: '',
      Severity: Minor
      Found in public/javascripts/application.js - 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

      Function action has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      Owp.button.action = function(config) {
        config = Ext.apply({
          gridName: '',
          url: '',
          command: '',
      Severity: Minor
      Found in public/javascripts/application.js - 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 servers_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def servers_list
            if @current_user.superadmin?
              @servers_list = HardwareServer.all
              @servers_list.map! do |server|
                {
      Severity: Minor
      Found in app/controllers/application.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