amahi/platform

View on GitHub

Showing 88 of 112 total issues

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

    def before_save_hook
        if guest_writeable_changed?
            guest_writeable ? make_guest_writeable : make_guest_non_writeable
        end
        self.tags = self.tags.split(/\s*,\s*|\s+/).reject {|s| s.empty? }.join(', ').downcase if self.tags_changed?
Severity: Minor
Found in app/models/share.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 dir2theme has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def self.dir2theme(dir)
        theme = nil
        Dir.chdir(File.join(Rails.root, THEME_ROOT)) do
            theme_init_file = File.join(dir, "init.rb")
            if File.exist? theme_init_file
Severity: Minor
Found in app/models/theme.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 set_locale has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def set_locale

        preferred_locales = request.headers['HTTP_ACCEPT_LANGUAGE'].split(',').map { |locale| locale.split(';').first } rescue nil
        available_locales = I18n.available_locales
        default_locale = I18n.default_locale
Severity: Minor
Found in app/controllers/application_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 update_workgroup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def update_workgroup
        sleep 2 if development?
        @workgroup = Setting.find(params[:id]) if params[:id]
        if @workgroup && @workgroup.name.eql?("workgroup")
            params[:share][:value].strip!
Severity: Minor
Found in plugins/020-shares/app/controllers/shares_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 simple_remote_select has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

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

        options[:id] = SecureRandom.hex(2) unless options[:id]
Severity: Minor
Found in app/helpers/application_helper.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

Function initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    initialize: function(options){

        var _this = this;
        var options = options || {};

Severity: Minor
Found in app/assets/javascripts/lib/smart-links.js - About 1 hr to fix

    Function tmpl has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            tmpl: function( tmpl, data, options, parentItem ) {
                var ret, topLevel = !parentItem;
                if ( topLevel ) {
                    // This is a top-level tmpl call (not from a nested template using {{tmpl}})
                    parentItem = topTmplItem;
    Severity: Minor
    Found in app/assets/javascripts/lib/jquery.ui.templates.js - About 1 hr to fix

      Method set_platform has 28 lines of code (exceeds 25 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 1 hr to fix

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

                def system_all_new_users
                    res = []
                    Dir.chdir("/home") do
                        Dir.glob("*").sort.reverse.each do |login|
                            unless User.where(:login=> login).first
        Severity: Minor
        Found in app/models/user.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 destroy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def destroy
                sleep 2 if development?
                @user = User.find(params[:id])
                id = nil
                if @user && @user != current_user && !@user.admin?
        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 install_theme has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def install_theme(installer, source)
        
                return if (installer.source_url.nil? or installer.source_url.blank?)
        
                dir = nil
        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 simple_remote_radio has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

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

            def hda
                @page_title = 'Search Results'
                @search_value = 'HDA'
        
                if params[:button] && params[:button] == "Web"
        Severity: Minor
        Found in app/controllers/search_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 read_lease has 26 lines of code (exceeds 25 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 1 hr to fix

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

                  def pkginstall(pkgs, sha1 = nil)
                      if debian? or ubuntu? or mint?
                          c = Command.new "DEBIAN_FRONTEND=noninteractive apt-get -y install #{pkgs}"
                          c.run_now
                      elsif fedora? or centos?
          Severity: Minor
          Found in lib/platform.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 pkguninstall has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                  def pkguninstall(pkgs)
                      if debian? or ubuntu? or mint?
                          c = Command.new "DEBIAN_FRONTEND=noninteractive apt-get -y remove #{pkgs}"
                          c.run_now
                      elsif fedora? or centos?
          Severity: Minor
          Found in lib/platform.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_pin has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def update_pin
                  sleep 2 if development?
                  @user = User.find(params[:id])
                  if(params[:user][:pin].blank? || params[:user][:pin_confirmation].blank?)
                      errors = true
          Severity: Minor
          Found in plugins/010-users/app/controllers/users_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 initialize_system has a Cognitive Complexity of 9 (exceeds 5 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 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 setup_router has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def setup_router
                  @router = nil
                  r = Setting.get_kind('network', 'router_model')
                  return @router unless r
                  begin
          Severity: Minor
          Found in app/controllers/application_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 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

          Severity
          Category
          Status
          Source
          Language