gitlabhq/gitlabhq

View on GitHub

Showing 111 of 111 total issues

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

  def validate_each(record, attribute, value)
    raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base

    value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)

Severity: Minor
Found in lib/file_size_validator.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

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

    def execute
      # get namespace id
      namespace_id = params.delete(:namespace_id)

      # Load default feature settings
Severity: Minor
Found in app/contexts/projects/create_context.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

File user.rb has 251 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class User < ActiveRecord::Base
  devise :database_authenticatable, :token_authenticatable, :lockable,
         :recoverable, :rememberable, :trackable, :validatable, :omniauthable, :registerable

  attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username,
Severity: Minor
Found in app/models/user.rb - About 2 hrs to fix

    Function utf8_encode has 48 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function utf8_encode (argString) {
      // http://kevin.vanzonneveld.net
      // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
      // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
      // +   improved by: sowberry
    Severity: Minor
    Found in app/assets/javascripts/lib/utf8_encode.js - About 1 hr to fix

      Method each_diff_line_near has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def each_diff_line_near(diff, index, expected_line_code)
          max_number_of_lines = 16
      
          prev_match_line = nil
          prev_lines = []
      Severity: Minor
      Found in app/helpers/commits_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 reject_muted_users has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

        def reject_muted_users(users, project = nil)
          users = users.compact.uniq
      
          users.reject do |user|
            next user.notification.disabled? unless project
      Severity: Minor
      Found in app/services/notification_service.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 dump has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def dump
            prepare
      
            Project.find_each(batch_size: 1000) do |project|
              print " * #{project.path_with_namespace} ... "
      Severity: Minor
      Found in lib/backup/repository.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 md5 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function md5 (str) {
        // http://kevin.vanzonneveld.net
        // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
        // + namespaced by: Michael White (http://getsprink.com)
        // +    tweaked by: Jack
      Severity: Minor
      Found in app/assets/javascripts/lib/md5.js - 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 restore has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def restore
            if File.exists?(repos_path)
              # Move repos dir to 'repositories.old' dir
              bk_repos_path = File.join(repos_path, '..', 'repositories.old.' + Time.now.to_i.to_s)
              FileUtils.mv(repos_path, bk_repos_path)
      Severity: Minor
      Found in lib/backup/repository.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 auth! has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def auth!
            return render_not_found unless project
      
            if @auth.provided?
              return bad_request unless @auth.basic?
      Severity: Minor
      Found in lib/gitlab/backend/grack_auth.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 search_autocomplete_source has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def search_autocomplete_source
          projects = current_user.authorized_projects.map { |p| { label: "project: #{simple_sanitize(p.name_with_namespace)}", url: project_path(p) } }
          groups = current_user.authorized_groups.map { |group| { label: "group: #{simple_sanitize(group.name)}", url: group_path(group) } }
      
          default_nav = [
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 1 hr to fix

        Method execute has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def execute
              # get namespace id
              namespace_id = params.delete(:namespace_id)
        
              # Load default feature settings
        Severity: Minor
        Found in app/contexts/projects/create_context.rb - About 1 hr to fix

          Method processing has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def processing diff_arr
                  indexes = _indexes_of_changed_lines diff_arr
          
                  indexes.each do |index|
                    first_line = diff_arr[index+1]
          Severity: Minor
          Found in lib/gitlab/inline_diff.rb - About 1 hr to fix

            Method place_chain has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def place_chain(commit, parent_time = nil)
                  leaves = take_left_leaves(commit)
                  if leaves.empty?
                    return
                  end
            Severity: Minor
            Found in app/models/network/graph.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 remove_old has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def remove_old
                  # delete backups
                  print "Deleting old backups ... "
                  keep_time = Gitlab.config.backup.keep_time.to_i
                  path = Gitlab.config.backup.path
            Severity: Minor
            Found in lib/backup/manager.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 <=> has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def <=>(other)
                  return unless other.is_a? VersionInfo
                  return unless valid? && other.valid?
            
                  if other.major < @major
            Severity: Minor
            Found in lib/gitlab/version_info.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 current_user has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

                def current_user
                  @current_user ||= User.find_by_authentication_token(params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER])
                  identifier = sudo_identifier()
                  # If the sudo is the current user do nothing
                  if (identifier && !(@current_user.id == identifier || @current_user.username == identifier))
            Severity: Minor
            Found in lib/api/helpers.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 unpack has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def unpack
                  Dir.chdir(Gitlab.config.backup.path)
            
                  # check for existing backups in the backup dir
                  file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i }
            Severity: Minor
            Found in lib/backup/manager.rb - About 1 hr to fix

              Method each has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def each
                    line_old = 1
                    line_new = 1
                    type = nil
              
              
              Severity: Minor
              Found in lib/gitlab/diff_parser.rb - About 1 hr to fix

                Function inWords has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    inWords: function(distanceMillis) {
                      var $l = this.settings.strings;
                      var prefix = $l.prefixAgo;
                      var suffix = $l.suffixAgo;
                      if (this.settings.allowFuture) {
                Severity: Minor
                Found in app/assets/javascripts/lib/jquery.timeago.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language