gitlabhq/gitlabhq

View on GitHub

Showing 1,432 of 2,076 total issues

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 map_line_number has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def map_line_number(from_line, from:, to:)
        # If no diff file could be found, the file wasn't changed, and the
        # mapped line number is the same as the specified line number.
        return from_line unless diff_file

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

      def extensions
        EXTENSION_MUTEX.synchronize do
          strong_memoize(:extensions) do
            Set.new.tap do |set|
              YAML.load_file(Rails.root.join('vendor', 'languages.yml')).each do |_name, details|
Severity: Minor
Found in lib/gitlab/language_data.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 diff_stats_collection has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def diff_stats_collection
          strong_memoize(:diff_stats) do
            # There are scenarios where we don't need to request Diff Stats,
            # when caching for instance.
            next unless @include_stats
Severity: Minor
Found in lib/gitlab/diff/file_collection/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 in_lock has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def in_lock(key, ttl: 1.minute, retries: 10, sleep_sec: 0.01.seconds)
      raise ArgumentError, 'Key needs to be specified' unless key

      lease = Gitlab::ExclusiveLease.new(key, timeout: ttl)

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

            def perform!
              unless @pipeline.config_processor
                unless @pipeline.ci_yaml_file
                  return error("Missing #{@pipeline.ci_yaml_file_path} file")
                end
Severity: Minor
Found in lib/gitlab/ci/pipeline/chain/validate/config.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 find_next_marker has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def find_next_marker(scanner)
          beginning_of_section_len = 8
          maybe_marker = scanner.exist?(beginning_of_section_regex)

          if maybe_marker.nil?
Severity: Minor
Found in lib/gitlab/ci/trace/section_parser.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 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

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 merge_to_ref has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

    Method format_issue_comment_body has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def format_issue_comment_body(id, author, date, content, updates, attachments)
    Severity: Minor
    Found in lib/gitlab/google_code_import/importer.rb - About 45 mins to fix

      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 get_xterm_color_class has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def get_xterm_color_class(command_stack, prefix)
                # the 38 and 48 commands have to be followed by "5" and the color index
                return unless command_stack.length >= 2
                return unless command_stack[0] == "5"
      
      
      Severity: Minor
      Found in lib/gitlab/ci/ansi2html.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 validate_job_dependencies! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate_job_dependencies!(name, job)
              return unless job[:dependencies]
      
              stage_index = @stages.index(job[:stage])
      
      
      Severity: Minor
      Found in lib/gitlab/ci/yaml_processor.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 attributes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

                def attributes(*attributes)
                  attributes.flatten.each do |attribute|
                    if method_defined?(attribute)
                      raise ArgumentError, 'Method already defined!'
                    end
      Severity: Minor
      Found in lib/gitlab/config/entry/attributable.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 compute_class_for_class has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_class_for_class(subject_class)
            subject_class.ancestors.each do |klass|
              next unless klass.name
      
              begin
      Severity: Minor
      Found in lib/declarative_policy.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

      Severity
      Category
      Status
      Source
      Language