amahi/platform

View on GitHub

Showing 88 of 112 total issues

Method conf_file has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def conf_file
        # clean the path first
        path.sub!(/\/+$/, '')
        path.gsub!(/\/+/, '/')
        domain = ''
Severity: Minor
Found in app/models/webapp.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

Class Server has 22 methods (exceeds 20 allowed). Consider refactoring.
Open

class Server < ApplicationRecord

    # CAUTION - this class *assumes* new servers are created
    # started and enabled at boot time as services!

Severity: Minor
Found in app/models/server.rb - About 2 hrs to fix

    Method stats has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

            def stats
                host = 'localhost'
                port = 7634
    
                begin
    Severity: Minor
    Found in plugins/030-disks/lib/disks/disk_utils.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

    Class NetworkController has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class NetworkController < ApplicationController
      KIND = Setting::NETWORK
      before_action :admin_required
      before_action :set_page_title
      IP_RANGE = 10
    Severity: Minor
    Found in plugins/050-network/app/controllers/network_controller.rb - About 2 hrs to fix

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

          def self.available
              tl = all.to_a
              Dir.chdir(File.join(Rails.root, THEME_ROOT)) do
                  Dir.glob("*").sort.each do |theme_dir|
                      next if where(:css=>theme_dir).first
      Severity: Minor
      Found in app/models/theme.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

      Function storeTmplItems has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function storeTmplItems( content ) {
              var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
              for ( i = 0, l = content.length; i < l; i++ ) {
                  if ( (elem = content[i]).nodeType !== 1 ) {
                      continue;
      Severity: Minor
      Found in app/assets/javascripts/lib/jquery.ui.templates.js - About 2 hrs to fix

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

            def update
                sleep 2 if development?
                user = User.find params[:id]
                name = user.name
                if can_i_edit_details?(user)
        Severity: Minor
        Found in plugins/010-users/app/controllers/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 run_script has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.run_script(script, name, environment = {})
                require 'tempfile'
                include Process
        
                # number of linear backoff steps to wait. 22 ~= 160s
        Severity: Minor
        Found in lib/system_utils.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 header_workgroup has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def self.header_workgroup(domain)
                short_domain = Setting.find_or_create_by(Setting::GENERAL, 'workgroup', 'WORKGROUP').value
                debug = Setting.shares.value_by_name('debug') == '1'
                win98 = Setting.shares.value_by_name('win98') == '1'
                ret = ["# This file is automatically generated for WORKGROUP setup.",
        Severity: Minor
        Found in app/models/share.rb - About 1 hr to fix

          Method conf_file has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def conf_file
                  # clean the path first
                  path.sub!(/\/+$/, '')
                  path.gsub!(/\/+/, '/')
                  domain = ''
          Severity: Minor
          Found in app/models/webapp.rb - About 1 hr to fix

            Method estimate_pids has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def estimate_pids
                    pf = pid_file
                    ret = []
                    begin
                        # check if the pid file is there
            Severity: Minor
            Found in app/models/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 uninstall_bg has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                def uninstall_bg
                    if Rails.env=="production"
                        cmd = Command.new("chmod 666 /var/run/docker.sock")
                        cmd.execute
                    end
            Severity: Minor
            Found in app/models/app.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 uninstall_bg has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def uninstall_bg
                    if Rails.env=="production"
                        cmd = Command.new("chmod 666 /var/run/docker.sock")
                        cmd.execute
                    end
            Severity: Minor
            Found in app/models/app.rb - About 1 hr to fix

              Method share_conf has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def share_conf
                      ret = "[%s]\n"        \
                      "\tcomment = %s\n"     \
                      "\tpath = %s\n"     \
                      "\twriteable = %s\n"     \
              Severity: Minor
              Found in app/models/share.rb - About 1 hr to fix

                Function buildTmplFn has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    function buildTmplFn( markup ) {
                        return new Function("jQuery","$item",
                            // Use the variable __ to hold a string array while building the compiled template. (See https://github.com/jquery/jquery-tmpl/issues#issue/10).
                            "var $=jQuery,call,__=[],$data=$item.data;" +
                
                
                Severity: Minor
                Found in app/assets/javascripts/lib/jquery.ui.templates.js - About 1 hr to fix

                  Method platform_versions has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def platform_versions
                              platform = ""
                              hda_ctl = ""
                              if fedora? or centos?
                                  open("|rpm -q hda-platform hda-ctl") do |f|
                  Severity: Minor
                  Found in lib/platform.rb - About 1 hr to fix

                    Function processItemKey has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                            function processItemKey( el ) {
                                var pntKey, pntNode = el, pntItem, tmplItem, key;
                                // Ensure that each rendered template inserted into the DOM has its own template item,
                                if ( (key = el.getAttribute( tmplItmAtt ))) {
                                    while ( pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute( tmplItmAtt ))) { }
                    Severity: Minor
                    Found in app/assets/javascripts/lib/jquery.ui.templates.js - About 1 hr to fix

                      Method stats has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              def stats
                                  host = 'localhost'
                                  port = 7634
                      
                                  begin
                      Severity: Minor
                      Found in plugins/030-disks/lib/disks/disk_utils.rb - About 1 hr to fix

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

                            def initialize_system
                                username = params[:username]
                                pwd = params[:password]
                                conf = params[:password_confirmation]
                                unless valid_admin_password?(pwd, conf)
                        Severity: Minor
                        Found in app/controllers/user_sessions_controller.rb - About 1 hr to fix

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

                              def self.run_script(script, name, environment = {})
                                  require 'tempfile'
                                  include Process
                          
                                  # number of linear backoff steps to wait. 22 ~= 160s
                          Severity: Minor
                          Found in lib/system_utils.rb - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language