gitlabhq/gitlabhq

View on GitHub

Showing 1,551 of 2,202 total issues

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

    def loop_until(timeout: nil, limit: 1_000_000)
      raise ArgumentError unless limit

      start = Time.now

Severity: Minor
Found in lib/gitlab/loop_helpers.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 expand_attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def expand_attributes(klass, attributes)
        expanded = attributes.flat_map do |attribute|
          attr_config = klass.encrypted_attributes[attribute]
          crypt_column_name = attr_config&.fetch(:attribute)

Severity: Minor
Found in lib/gitlab/background_migration/encrypt_columns.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 bulk_insert has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self.bulk_insert(table, rows, return_ids: false, disable_quote: [])
      return if rows.empty?

      keys = rows.first.keys
      columns = keys.map { |key| connection.quote_column_name(key) }
Severity: Minor
Found in lib/gitlab/database.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 aggregate_rblineprof has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def aggregate_rblineprof(lineprof_stats)
        samples = []

        lineprof_stats.each do |(file, stats)|
          source_lines = File.read(file).each_line.to_a
Severity: Minor
Found in lib/gitlab/sherlock/line_profiler.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 groups has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def groups(highlight: true)
      prev_sha = nil
      groups = []
      current_group = nil

Severity: Minor
Found in lib/gitlab/blame.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 trace_unchanged_line has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def trace_unchanged_line(position)
          a_path = position.old_path
          a_line = position.old_line
          b_path = position.new_path
          b_line = position.new_line
Severity: Minor
Found in lib/gitlab/diff/position_tracer/line_strategy.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 store_in_cache_if_needed has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def store_in_cache_if_needed
          return delete_from_cache unless commit
          return unless sha
          return unless ref

Severity: Minor
Found in lib/gitlab/cache/ci/project_pipeline_status.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 lazy_page_iterator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def lazy_page_iterator(starting_page: 1, page_limit: nil, per_page: PER_PAGE)
        Enumerator.new do |y|
          page = starting_page
          page_limit = (starting_page - 1) + page_limit if page_limit

Severity: Minor
Found in lib/gitlab/gitlab_import/client.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 diff has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def diff(from, to, options = {})
        from_id = case from
                  when NilClass
                    Gitlab::Git::EMPTY_TREE_ID
                  else
Severity: Minor
Found in lib/gitlab/gitaly_client/commit_service.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 check_authentication_abilities! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def check_authentication_abilities!(cmd)
      case cmd
      when *DOWNLOAD_COMMANDS
        unless authentication_abilities.include?(:download_code) || authentication_abilities.include?(:build_download_code)
          raise UnauthorizedError, ERROR_MESSAGES[:auth_download]
Severity: Minor
Found in lib/gitlab/git_access.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 process_count_commits_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def process_count_commits_options(options)
        if options[:from] || options[:to]
          ref =
            if options[:left_right] # Compare with merge-base for left-right
              "#{options[:from]}...#{options[:to]}"
Severity: Minor
Found in lib/gitlab/git/repository.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 find_file has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def find_file(name, revision)
        request = Gitaly::WikiFindFileRequest.new(
          repository: @gitaly_repo,
          name: encode_binary(name),
          revision: encode_binary(revision)
Severity: Minor
Found in lib/gitlab/gitaly_client/wiki_service.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 user_merge_to_ref has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def user_merge_to_ref(user, source_sha, branch, target_ref, message, first_parent_ref)
Severity: Minor
Found in lib/gitlab/gitaly_client/operation_service.rb - About 45 mins to fix

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

          def add_concurrent_foreign_key(source, target, column:, on_delete: :cascade, name: nil)
            # Transactions would result in ALTER TABLE locks being held for the
            # duration of the transaction, defeating the purpose of this method.
            if transaction_open?
              raise 'add_concurrent_foreign_key can not be run inside a transaction'
    Severity: Minor
    Found in lib/gitlab/database/migration_helpers.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 update_remote_mirror has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def update_remote_mirror(ref_name, only_branches_matching, ssh_key: nil, known_hosts: nil)
            req_enum = Enumerator.new do |y|
              first_request = Gitaly::UpdateRemoteMirrorRequest.new(
                repository: @gitaly_repo,
                ref_name: ref_name
    Severity: Minor
    Found in lib/gitlab/gitaly_client/remote_service.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 fabricate! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def self.fabricate!(pattern, fallback: false)
            raise RegexpError, 'Pattern is not string!' unless pattern.is_a?(String)
    
            matches = pattern.match(PATTERN)
            raise RegexpError, 'Invalid regular expression!' if matches.nil?
    Severity: Minor
    Found in lib/gitlab/untrusted_regexp/ruby_syntax.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 list_key_ids has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def list_key_ids
          logger.info('Listing all key IDs')
    
          [].tap do |a|
            open_authorized_keys_file('r') do |f|
    Severity: Minor
    Found in lib/gitlab/authorized_keys.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 lfs_token_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def lfs_token_check(login, encoded_token, project)
            deploy_key_matches = login.match(/\Alfs\+deploy-key-(\d+)\z/)
    
            actor =
              if deploy_key_matches
    Severity: Minor
    Found in lib/gitlab/auth.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 format_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def format_response(response)
              response[:text] = format(response[:text]) if response.key?(:text)
    
              if response.key?(:attachments)
                response[:attachments].each do |attachment|
    Severity: Minor
    Found in lib/gitlab/slash_commands/presenters/base.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 compare_source_branch has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def compare_source_branch(target_branch_name, source_repository, source_branch_name, straight:)
            reachable_ref =
              if source_repository == self
                source_branch_name
              else
    Severity: Minor
    Found in lib/gitlab/git/repository.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