amahi/platform

View on GitHub

Showing 112 of 112 total issues

File app.rb has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'tempfile'
require 'digest/md5'
require 'amahi_api'
require 'command'
require 'downloader'
Severity: Minor
Found in app/models/app.rb - About 7 hrs to fix

    File share.rb has 398 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'command'
    require 'platform'
    require 'temp_cache'
    
    class Share < ApplicationRecord
    Severity: Minor
    Found in app/models/share.rb - About 5 hrs to fix

      Method install_bg has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
      Open

          def install_bg
              # Change permissions of docker.sock file
              if Rails.env=="production"
                  cmd = Command.new("chmod 666 /var/run/docker.sock")
                  cmd.execute
      Severity: Minor
      Found in app/models/app.rb - About 5 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

      File platform.rb has 374 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'downloader'
      
      class Platform
      
          # upstart conf file for an ubuntu system
      Severity: Minor
      Found in lib/platform.rb - About 5 hrs to fix

        File jquery.ui.templates.js has 356 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*!
         * jQuery Templates Plugin 1.0.0pre
         * http://github.com/jquery/jquery-tmpl
         * Requires jQuery 1.4.2
         *
        Severity: Minor
        Found in app/assets/javascripts/lib/jquery.ui.templates.js - About 4 hrs to fix

          Method install_bg has 103 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def install_bg
                  # Change permissions of docker.sock file
                  if Rails.env=="production"
                      cmd = Command.new("chmod 666 /var/run/docker.sock")
                      cmd.execute
          Severity: Major
          Found in app/models/app.rb - About 4 hrs to fix

            Method create_config_file has 102 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def create_config_file
                    root = "plugins/#{plural_name}"
                    # FIXME bug in thor?
                    # destination_root="#{Rails.root}/plugins/#{plural_name}"
            
            
            Severity: Major
            Found in lib/generators/plugin/plugin_generator.rb - About 4 hrs to fix

              Class App has 32 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class App < ApplicationRecord
              
                  # App and Log storage path is different for both production and development environment.
                  BASE_PORT = 35000
                  if Rails.env == "production"
              Severity: Minor
              Found in app/models/app.rb - About 4 hrs to fix

                Class Share has 31 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Share < ApplicationRecord
                
                    DEFAULT_SHARES_ROOT = '/var/hda/files'
                
                    SIGNATURE = "Amahi configuration"
                Severity: Minor
                Found in app/models/share.rb - About 3 hrs to fix

                  Method share_conf has a Cognitive Complexity of 25 (exceeds 5 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 3 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 set_platform has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
                  Open

                          def set_platform
                              if File.exist?('/etc/amahi-release')
                                  line = nil
                                  File.open("/etc/amahi-release", "r") do |issue|
                                      line = issue.gets
                  Severity: Minor
                  Found in lib/platform.rb - About 3 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 Platform has 27 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Platform
                  
                      # upstart conf file for an ubuntu system
                      UPSTART_CONF = "/etc/init/%s.conf"
                  
                  
                  Severity: Minor
                  Found in lib/platform.rb - About 3 hrs to fix

                    Method platform_versions has a Cognitive Complexity of 22 (exceeds 5 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 3 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 locate_search has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def locate_search(term, filter, page, rpp)
                            base = Share.basenames
                            # lines to skip
                            skip = (page - 1) * rpp
                            open locate_cache(term) do |l|
                    Severity: Minor
                    Found in app/controllers/search_controller.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 ApplicationController has 25 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class ApplicationController < ActionController::Base
                        require 'ipaddr'
                        protect_from_forgery with: :exception
                    
                        before_action :before_action_hook
                    Severity: Minor
                    Found in app/controllers/application_controller.rb - About 2 hrs to fix

                      File share_controller.rb has 283 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require 'partition_utils'
                      
                      class ShareController < ApplicationController
                          before_action :admin_required
                      
                      
                      Severity: Minor
                      Found in app/controllers/share_controller.rb - About 2 hrs to fix

                        Method read_lease has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                        Open

                                def self.read_lease(file)
                                    res = {}
                                    return res unless File.exists?(file)
                                    current = {}
                                    File.foreach(file) do |l|
                        Severity: Minor
                        Found in lib/leases.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 ShareController has 24 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class ShareController < ApplicationController
                            before_action :admin_required
                        
                            VALID_NAME = Regexp.new "\A\\w[\\w ]+\z"
                            # Disk Pool minimum free: default og 10GB, but for root,
                        Severity: Minor
                        Found in app/controllers/share_controller.rb - About 2 hrs to fix

                          Class SharesController has 24 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class SharesController < ApplicationController
                          
                              before_action :admin_required
                          
                              before_action :get_share
                          Severity: Minor
                          Found in plugins/020-shares/app/controllers/shares_controller.rb - About 2 hrs to fix

                            Method header_pdc has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                def self.header_pdc(domain)
                                    short_domain = Setting.shares.value_by_name("workgroup") || 'workgroup'
                                    debug = Setting.shares.value_by_name('debug') == '1'
                                    admins = User.admins rescue ["no_such_user"]
                                    ret = ["# This file is automatically generated for PDC setup.",
                            Severity: Major
                            Found in app/models/share.rb - About 2 hrs to fix
                              Severity
                              Category
                              Status
                              Source
                              Language