gitlabhq/gitlabhq

View on GitHub

Showing 99 of 111 total issues

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

  def assign_ref_vars
    # assign allowed options
    allowed_options = ["filter_ref", "extended_sha1"]
    @options = params.select {|key, value| allowed_options.include?(key) && !value.blank? }
    @options = HashWithIndifferentAccess.new(@options)
Severity: Minor
Found in lib/extracts_path.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 link_to_member has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def link_to_member(project, author, opts = {})
    default_opts = { avatar: true, name: true, size: 16 }
    opts = default_opts.merge(opts)

    return "(deleted)" unless author
Severity: Minor
Found in app/helpers/projects_helper.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def execute
    query = params[:search]

    return result unless query.present?

Severity: Minor
Found in app/contexts/search_context.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 handle_omniauth has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def handle_omniauth
    if current_user
      # Change a logged-in user's authentication method:
      current_user.extern_uid = oauth['uid']
      current_user.provider = oauth['provider']
Severity: Minor
Found in app/controllers/omniauth_callbacks_controller.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_branches has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_branches
    if target_project==source_project && target_branch == source_branch
      errors.add :branch_conflict, "You can not use same project/branch for source and target"
    end

Severity: Minor
Found in app/models/merge_request.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def execute(role = :default)
      namespace_id = params[:project].delete(:namespace_id)
      allowed_transfer = can?(current_user, :change_namespace, project) || role == :admin

      if allowed_transfer && namespace_id.present?
Severity: Minor
Found in app/contexts/projects/transfer_context.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 gravatar_icon has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def gravatar_icon(user_email = '', size = nil)
    size = 40 if size.nil? || size <= 0

    if !Gitlab.config.gravatar.enabled || user_email.blank?
      'no_avatar.png'
Severity: Minor
Found in app/helpers/application_helper.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def execute
      update_data = params[:update]

      issues_ids   = update_data[:issues_ids].split(",")
      milestone_id = update_data[:milestone_id]
Severity: Minor
Found in app/contexts/issues/bulk_update_context.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_status_change_note has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

  def self.create_status_change_note(noteable, project, author, status, source)
Severity: Minor
Found in app/models/note.rb - About 35 mins to fix

    Method perform has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def perform(repo_path, oldrev, newrev, ref, identifier)
    Severity: Minor
    Found in app/workers/post_receive.rb - About 35 mins to fix

      Method execute has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def execute(project, user, oldrev, newrev, ref)
      Severity: Minor
      Found in app/services/git_push_service.rb - About 35 mins to fix

        Method create_ref_event has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def create_ref_event(project, user, ref, action = 'add', prefix = 'refs/heads')
        Severity: Minor
        Found in app/models/event.rb - About 35 mins to fix

          Method mentioned_users has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def mentioned_users
              users = []
              return users if mentionable_text.blank?
              has_project = self.respond_to? :project
              matches = mentionable_text.scan(/@[a-zA-Z][a-zA-Z0-9_\-\.]*/)
          Severity: Minor
          Found in app/models/concerns/mentionable.rb - About 35 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 failure_message has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def failure_message
              exception = env["omniauth.error"]
              error   = exception.error_reason if exception.respond_to?(:error_reason)
              error ||= exception.error        if exception.respond_to?(:error)
              error ||= exception.message      if exception.respond_to?(:message)
          Severity: Minor
          Found in app/controllers/omniauth_callbacks_controller.rb - About 35 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_or_create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                  def find_or_create(auth)
                    @auth = auth
          
                    if uid.blank? || email.blank?
                      raise_error("Account must provide an uid and email address")
          Severity: Minor
          Found in lib/gitlab/ldap/user.rb - About 35 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 new_note has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def new_note(note)
              # ignore wall messages
              return true unless note.noteable_type.present?
          
              # ignore gitlab service messages
          Severity: Minor
          Found in app/services/notification_service.rb - About 35 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_project_nav_tabs has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def get_project_nav_tabs(project, current_user)
              nav_tabs = [:home]
          
              if !project.empty_repo? && can?(current_user, :download_code, project)
                nav_tabs << [:files, :commits, :network, :graphs]
          Severity: Minor
          Found in app/helpers/projects_helper.rb - About 35 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 identify has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def identify(identifier, project, newrev)
                if identifier.blank?
                  # Local push from gitlab
                  email = project.repository.commit(newrev).author_email rescue nil
                  User.find_by_email(email) if email
          Severity: Minor
          Found in lib/gitlab/identifier.rb - About 35 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 take_left_leaves has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def take_left_leaves(raw_commit)
                commit = @map[raw_commit.id]
                leaves = []
                leaves.push(commit) if commit.space.zero?
          
          
          Severity: Minor
          Found in app/models/network/graph.rb - About 35 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 edit_requirements has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def edit_requirements
              @blob = Gitlab::Git::Blob.new(@repository, @commit.id, @ref, @path)
          
              unless @blob.exists? && @blob.text?
                redirect_to project_blob_path(@project, @id), notice: "You can only edit text files"
          Severity: Minor
          Found in app/controllers/projects/edit_tree_controller.rb - About 35 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