gitlabhq/gitlabhq

View on GitHub

Complex method in #create

  def create
    unless @user.password_automatically_set || @user.valid_password?(user_params[:current_password])
      redirect_to new_profile_password_path, alert: 'You must provide a valid current password'
      return
    end
Found in Profiles::PasswordsController - About 2 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #show

  def show
    blob = @snippet.blob
    conditionally_expand_blob(blob)

    respond_to do |format|
Found in Projects::SnippetsController - About 2 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #user_merge_branch

      def user_merge_branch(user, source_sha, target_branch, message)
        request_enum = QueueEnumerator.new
        response_enum = GitalyClient.call(
          @repository.storage,
          :operation_service,
Found in Gitlab::GitalyClient::OperationService - About 2 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #show

  def show
    if @project.import_finished?
      if continue_params
        redirect_to continue_params[:to], notice: continue_params[:notice]
      else
Found in Projects::ImportsController - About 2 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex class definition

module Ci
  class TriggerPolicy < BasePolicy
    delegate { @subject.project }

    with_options scope: :subject, score: 0
Found in Ci::TriggerPolicy - About 2 hrs to fix

    Complex class definition

    class AwardEmoji < ActiveRecord::Base
      DOWNVOTE_NAME = "thumbsdown".freeze
      UPVOTE_NAME   = "thumbsup".freeze
    
      include Participable
    Found in AwardEmoji - About 2 hrs to fix

      Complex method in #paginated_second_collection

          def paginated_second_collection(page)
            @second_collection_pages ||= Hash.new do |hash, page|
              second_collection_page = page - first_collection_page_count
      
              offset = if second_collection_page < 1 || first_collection_page_count.zero?
      Found in Gitlab::MultiCollectionPaginator - About 2 hrs to fix

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Complex method in #groups_data

              def groups_data
                metrics_groups = groups_with_active_metrics(Gitlab::Prometheus::MetricGroup.all)
                lookup = active_series_lookup(metrics_groups)
      
                groups = {}

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Complex method in #find_id_by_path

              def find_id_by_path(repository, root_id, path)
                root_tree = repository.lookup(root_id)
                path_arr = path.split('/')
      
                entry = root_tree.find do |entry|
      Found in Gitlab::Git::Tree - About 2 hrs to fix

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Complex class definition

      class UserPolicy < BasePolicy
        desc "The current user is the user in question"
        condition(:user_is_self, score: 0) { @subject == @user }
      
        desc "This is the ghost user"
      Found in UserPolicy - About 2 hrs to fix

        Complex class definition

        class PagesDomain < ActiveRecord::Base
          belongs_to :project
        
          validates :domain, hostname: { allow_numeric_hostname: true }
          validates :domain, uniqueness: { case_sensitive: false }
        Found in PagesDomain - About 2 hrs to fix

          Complex method in #labels

            def labels
              @labels ||= GlobalLabel.build_collection(milestones.includes(:labels).map(&:labels).flatten)
                                     .sort_by!(&:title)
            end
          Found in GlobalMilestone - About 2 hrs to fix

          Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

          Refactorings

          Read More

          Complex method in #collection_objects_for_ids

                def collection_objects_for_ids(collection, ids)
                  if RequestStore.active?
                    ids = ids.map(&:to_i)
                    cache = collection_cache[collection_cache_key(collection)]
                    to_query = ids - cache.keys
          Found in Banzai::ReferenceParser::BaseParser - About 2 hrs to fix

          Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

          Refactorings

          Read More

          Complex method in #execute

              def execute(cluster)
                api_client =
                  GoogleApi::CloudPlatform::Client.new(cluster.gcp_token, nil)
          
                begin
          Found in Ci::FinalizeClusterCreationService - About 2 hrs to fix

          Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

          Refactorings

          Read More

          Complex method in #up

            def up
              Gitlab::Database.with_connection_pool(2) do |pool|
                threads = []
          
                threads << Thread.new do
          Found in RemoveInactiveDefaultEmailServices - About 2 hrs to fix

          Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

          Refactorings

          Read More

          Complex method in #redis_store_options

                def redis_store_options
                  config = raw_config_hash
                  redis_url = config.delete(:url)
                  redis_uri = URI.parse(redis_url)
          
          
          Found in Gitlab::Redis::Wrapper - About 2 hrs to fix

          Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

          Refactorings

          Read More

          Complex class definition

          module Gitlab
            module EtagCaching
              class Router
                Route = Struct.new(:regexp, :name)
                # We enable an ETag for every request matching the regex.
          Found in Gitlab::EtagCaching::Router - About 1 hr to fix

            Complex method in #filter_projects_path

              def filter_projects_path(options = {})
                exist_opts = {
                  sort: params[:sort] || @sort,
                  scope: params[:scope],
                  group: params[:group],
            Found in ExploreHelper - About 1 hr to fix

            Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

            Refactorings

            Read More

            Complex method in #execute_without_lease

                def execute_without_lease
                  current = current_authorizations_per_project
                  fresh = fresh_access_levels_per_project
            
                  remove = current.each_with_object([]) do |(project_id, row), array|
            Found in Users::RefreshAuthorizedProjectsService - About 1 hr to fix

            Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

            Refactorings

            Read More

            Complex class definition

            module Gitlab
              module Ci
                class Config
                  module Entry
                    ##
            Found in Gitlab::Ci::Config::Entry::Environment - About 1 hr to fix

              Complex method in #nodes_user_can_reference

                    def nodes_user_can_reference(current_user, nodes)
                      project_attr = 'data-project'
                      author_attr = 'data-author'
              
                      projects = lazy { projects_for_nodes(nodes) }
              Found in Banzai::ReferenceParser::UserParser - About 1 hr to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex method in #uploader

                def uploader
                  return @uploader if defined?(@uploader)
              
                  case model
                  when nil
              Found in UploadsController - About 1 hr to fix

              Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

              Refactorings

              Read More

              Complex class definition

              # Gitaly note: JV: needs RPC for Gitlab::Git::Diff.between.
              
              # Gitlab::Git::Diff is a wrapper around native Rugged::Diff object
              module Gitlab
                module Git
              Found in Gitlab::Git::Diff - About 1 hr to fix

                Complex method in #create

                  def create
                    group = Group.find(params[:link_group_id]) if params[:link_group_id].present?
                
                    if group
                      return render_404 unless can?(current_user, :read_group, group)
                Found in Projects::GroupLinksController - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More

                Complex method in #to_hash

                          def to_hash
                            { name: name,
                              before_script: before_script_value,
                              script: script_value,
                              commands: commands,
                Found in Gitlab::Ci::Config::Entry::Job - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More

                Complex method in #move_repository

                    def move_repository(from_name, to_name)
                      from_exists = gitlab_shell.exists?(project.repository_storage_path, "#{from_name}.git")
                      to_exists = gitlab_shell.exists?(project.repository_storage_path, "#{to_name}.git")
                
                      # If we don't find the repository on either original or target we should log that as it could be an issue if the
                Found in Projects::HashedStorageMigrationService - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More

                Complex method in #find_changed_line_pairs

                        def find_changed_line_pairs(lines)
                          # Prefixes of all diff lines, indicating their types
                          # For example: `" - +  -+  ---+++ --+  -++"`
                          line_prefixes = lines.each_with_object("") { |line, s| s << line[0] }.gsub(/[^ +-]/, ' ')
                
                
                Found in Gitlab::Diff::InlineDiff - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More

                Complex method in #destroy

                  def destroy
                    result = Tags::DestroyService.new(project, current_user).execute(params[:id])
                
                    respond_to do |format|
                      if result[:status] == :success
                Found in Projects::TagsController - About 1 hr to fix

                Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                Refactorings

                Read More

                Complex class definition

                class PersonalAccessToken < ActiveRecord::Base
                  include Expirable
                  include TokenAuthenticatable
                  add_authentication_token_field :token
                
                
                Found in PersonalAccessToken - About 1 hr to fix

                  Complex method in #show

                    def show
                      # n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37602
                      Gitlab::GitalyClient.allow_n_plus_1_calls do
                        @url = project_network_path(@project, @ref, @options.merge(format: :json))
                        @commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")
                  Found in Projects::NetworkController - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #item_for_discussion

                      def item_for_discussion(discussion)
                        first_note_to_resolve = discussion.first_note_to_resolve || discussion.first_note
                  
                        is_very_first_note = first_note_to_resolve == discussion.first_note
                        action = is_very_first_note ? "started" : "commented on"
                  Found in Issues::BuildService - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #can_be_resolved_in_ui?

                        def can_be_resolved_in_ui?
                          return @conflicts_can_be_resolved_in_ui if defined?(@conflicts_can_be_resolved_in_ui)
                  
                          return @conflicts_can_be_resolved_in_ui = false unless merge_request.cannot_be_merged?
                          return @conflicts_can_be_resolved_in_ui = false unless merge_request.has_complete_diff_refs?
                  Found in MergeRequests::Conflicts::ListService - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #user_avatar_without_link

                    def user_avatar_without_link(options = {})
                      avatar_size = options[:size] || 16
                      user_name = options[:user].try(:name) || options[:user_name]
                      avatar_url = options[:url] || avatar_icon(options[:user] || options[:user_email], avatar_size)
                      has_tooltip = options[:has_tooltip].nil? ? true : options[:has_tooltip]
                  Found in AvatarsHelper - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #update

                    def update
                      password_attributes = user_params.select do |key, value|
                        %w(password password_confirmation).include?(key.to_s)
                      end
                      password_attributes[:password_automatically_set] = false
                  Found in Profiles::PasswordsController - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #expand_hierarchy_for_child

                    def expand_hierarchy_for_child(child, hierarchy, hierarchy_top, preloaded)
                      parent = hierarchy_top if hierarchy_top && child.parent_id == hierarchy_top.id
                      parent ||= preloaded.detect { |possible_parent| possible_parent.is_a?(Group) && possible_parent.id == child.parent_id }
                  
                      if parent.nil? && !child.parent_id.nil?
                  Found in GroupDescendant - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #create_user_map

                    def create_user_map
                      user_map_json = params[:user_map]
                      user_map_json = "{}" if user_map_json.blank?
                  
                      begin
                  Found in Import::GoogleCodeController - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #show

                    def show
                      @cpus = Vmstat.cpu rescue nil
                      @memory = Vmstat.memory rescue nil
                      mounts = Sys::Filesystem.mounts
                  
                  
                  Found in Admin::SystemInfoController - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex method in #perform

                    def perform(project_id, files = [], statistics = [])
                      project = Project.find_by(id: project_id)
                  
                      return unless project && project.repository.exists?
                  
                  
                  Found in ProjectCacheWorker - About 1 hr to fix

                  Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                  Refactorings

                  Read More

                  Complex class definition

                  module Gitlab
                    module BackgroundMigration
                      class NormalizeLdapExternUidsRange
                        class Identity < ActiveRecord::Base
                          self.table_name = 'identities'

                    Complex class definition

                    # -*- ruby encoding: utf-8 -*-
                    
                    # Based on the `ruby-net-ldap` gem's `Net::LDAP::DN`
                    #
                    # For our purposes, this class is used to normalize DNs in order to allow proper
                    Found in Gitlab::LDAP::DN - About 1 hr to fix

                      Complex method in #create

                        def create
                          @hook = @project.hooks.new(hook_params)
                          @hook.save
                      
                          unless @hook.valid?
                      Found in Projects::HooksController - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex method in #read_build_page

                        def read_build_page(response)
                          if response.code != 200 || response['results']['results']['size'] == '0'
                            # If actual build link can't be determined, send user to build summary page.
                            URI.join("#{bamboo_url}/", "browse/#{build_key}").to_s
                          else
                      Found in BambooService - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex method in #execute

                            def execute
                              command, match = match_command
                      
                              if command
                                if command.allowed?(project, current_user)
                      Found in Gitlab::SlashCommands::Command - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex method in #all_state_names

                          def all_state_names
                            state_machines.values.flat_map(&:states).flat_map { |s| s.map(&:name) }
                          end
                      Found in HasStatus - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex method in #find_projects_for_paths

                            def find_projects_for_paths(paths)
                              if RequestStore.active?
                                cache = project_refs_cache
                                to_query = paths - cache.keys
                      
                      
                      Found in Banzai::Filter::AbstractReferenceFilter - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex method in #find

                          def find(query)
                            by_content = find_by_content(query)
                      
                            already_found = Set.new(by_content.map(&:filename))
                            by_filename = find_by_filename(query, except: already_found)
                      Found in Gitlab::FileFinder - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex method in #perform

                        def perform(project_id, forked_from_repository_storage_path, source_path, target_path)
                          project = Project.find(project_id)
                      
                          return unless start_fork(project)
                      
                      
                      Found in RepositoryForkWorker - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex method in #update

                        def update
                          respond_to do |format|
                            result = Users::UpdateService.new(current_user, user_params.merge(user: @user)).execute
                      
                            if result[:status] == :success
                      Found in ProfilesController - About 1 hr to fix

                      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                      Refactorings

                      Read More

                      Complex class definition

                      module API
                        class Session < Grape::API
                          desc 'Login to get token' do
                            success Entities::UserWithPrivateDetails
                          end
                      Found in API::Session - About 1 hr to fix

                        Complex method in #link_urls

                              def link_urls
                                # Link `github: "user/repo"` to https://github.com/user/repo
                                link_regex(/(github:|:github\s*=>)\s*['"](?<name>[^'"]+)['"]/, &method(:github_url))
                        
                                # Link `git: "https://gitlab.example.com/user/repo"` to https://gitlab.example.com/user/repo
                        Found in Gitlab::DependencyLinker::GemfileLinker - About 1 hr to fix

                        Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

                        Refactorings

                        Read More