gitlabhq/gitlabhq

View on GitHub

Showing 1,661 of 2,359 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 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 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 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 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 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 inherit! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def inherit!(deps)
                return unless deps
      
                self.class.nodes.each do |key, factory|
                  next unless factory.inheritable?
      Severity: Minor
      Found in lib/gitlab/config/entry/inheritable.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_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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def self.execute(import_path)
                unless import_path.ends_with?('/')
                  import_path = "#{import_path}/"
                end
        
        
        Severity: Minor
        Found in lib/gitlab/bare_repository_import/importer.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 create_label has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def create_label(parent, entity)
                authorize! :admin_label, parent
        
                label = available_labels_for(parent).find_by_title(params[:name])
                conflict!('Label already exists') if label
        Severity: Minor
        Found in lib/api/helpers/label_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 filter_runners has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def filter_runners(runners, scope, allowed_scopes: ::Ci::Runner::AVAILABLE_SCOPES)
                return runners unless scope.present?
        
                unless allowed_scopes.include?(scope)
                  render_api_error!('Scope contains invalid value', 400)
        Severity: Minor
        Found in lib/api/runners.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 text has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def text
                  message = ["**#{status_text(resource)}**"]
        
                  if resource.upvotes.zero? && resource.downvotes.zero? && resource.user_notes_count.zero?
                    return message.join
        Severity: Minor
        Found in lib/gitlab/slash_commands/presenters/issue_show.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_substitutions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

              def perform_substitutions(content, commands)
                return unless content
        
                substitution_definitions = self.command_definitions.select do |definition|
                  definition.is_a?(Gitlab::QuickActions::SubstitutionDefinition)
        Severity: Minor
        Found in lib/gitlab/quick_actions/extractor.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_issue_comment_body has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

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

              def each_releases_page(args, &block)
                return to_enum(__method__, args) unless block_given?
          
                page = 1
                offset = ''
          Severity: Minor
          Found in lib/quality/helm_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 apply_filters has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def apply_filters(projects)
                  projects = projects.with_issues_available_for_user(current_user) if params[:with_issues_enabled]
                  projects = projects.with_merge_requests_enabled if params[:with_merge_requests_enabled]
                  projects = projects.with_statistics if params[:statistics]
          
          
          Severity: Minor
          Found in lib/api/projects.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_each has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                    def validate_each(record, attribute, value)
                      valid = validate_array_of_strings(value)
          
                      record.errors.add(attribute, 'should be an array of strings') unless valid
          
          
          Severity: Minor
          Found in lib/gitlab/config/entry/validators.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 explain has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def explain(context, arg)
                  return unless available?(context)
          
                  message = if explanation.respond_to?(:call)
                              execute_block(explanation, context, arg)
          Severity: Minor
          Found in lib/gitlab/quick_actions/command_definition.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

          Consider simplifying this complex logical expression.
          Open

              elsif confidential?
                author == user ||
                  assignees.include?(user) ||
                  project.team.member?(user, Gitlab::Access::REPORTER)
              else
          Severity: Major
          Found in app/models/issue.rb - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                      if closing && opening &&
                          closing.text? && opening.text? &&
                          closing.content.first == DOLLAR_SIGN &&
                          opening.content.last == DOLLAR_SIGN
            
            
            Severity: Major
            Found in lib/banzai/filter/math_filter.rb - About 40 mins to fix
              Severity
              Category
              Status
              Source
              Language