gitlabhq/gitlabhq

View on GitHub

Very high overall complexity: 377

require 'mime/types'

module API
  class Commits < Grape::API
    include PaginationParams
Found in API::Commits - About 2 days to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Complex class definition

module API
  module V3
    class ProjectSnippets < Grape::API
      include PaginationParams

Found in API::V3::ProjectSnippets - About 2 days to fix

    Complex class definition

    module API
      class API < Grape::API
        include APIGuard
    
        LOG_FILENAME = Rails.root.join("log", "api_json.log")
    Found in API::API - About 2 days to fix

      Identical code found in 1 other location

      module API
        class Services < Grape::API
          services = {
            'asana' => [
              {
      Found in API::Services and 1 other location - About 2 days to fix
      lib/api/v3/services.rb on lines 622..645

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Refactorings

      Further Reading

      Identical code found in 1 other location

      module API
        module V3
          class Services < Grape::API
            services = {
              'asana' => [
      Found in API::V3::Services and 1 other location - About 2 days to fix
      lib/api/services.rb on lines 695..718

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Refactorings

      Further Reading

      Complex class definition

      class MergeRequestEntity < IssuableEntity
        include RequestAwareEntity
      
        expose :in_progress_merge_commit_sha
        expose :merge_commit_sha
      Found in MergeRequestEntity - About 2 days to fix

        Very high overall complexity: 371

        module API
          class Issues < Grape::API
            include PaginationParams
        
            before { authenticate! }
        Found in API::Issues - About 2 days to fix

        When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

        Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

        Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

        Refactorings

        Further Reading

        Very high overall complexity: 370

        class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationController
          include ToggleSubscriptionAction
          include IssuableActions
          include RendersNotes
          include RendersCommits
        Found in Projects::MergeRequestsController - About 2 days to fix

        When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

        Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

        Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

        Refactorings

        Further Reading

        Complex class definition

        module API
          class Files < Grape::API
            FILE_ENDPOINT_REQUIREMENTS = API::PROJECT_ENDPOINT_REQUIREMENTS.merge(file_path: API::NO_SLASH_URL_PART_REGEX)
        
            # Prevents returning plain/text responses for files with .txt extension
        Found in API::Files - About 2 days to fix

          Very high overall complexity: 368

          require 'carrierwave/orm/activerecord'
          
          class Issue < ActiveRecord::Base
            include InternalId
            include Issuable
          Found in Issue - About 2 days to fix

          When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

          Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

          Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

          Refactorings

          Further Reading

          Complex class definition

          module API
            module V3
              class ProjectHooks < Grape::API
                include PaginationParams
          
          
          Found in API::V3::ProjectHooks - About 2 days to fix

            Very high overall complexity: 362

            require 'mime/types'
            
            module API
              module V3
                class Commits < Grape::API
            Found in API::V3::Commits - About 2 days to fix

            When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

            Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

            Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

            Refactorings

            Further Reading

            Complex class definition

            require 'mime/types'
            
            module API
              class Repositories < Grape::API
                include PaginationParams
            Found in API::Repositories - About 2 days to fix

              Complex class definition

              module API
                module V3
                  class Triggers < Grape::API
                    include PaginationParams
              
              
              Found in API::V3::Triggers - About 2 days to fix

                Complex class definition

                module API
                  class Labels < Grape::API
                    include PaginationParams
                
                    before { authenticate! }
                Found in API::Labels - About 2 days to fix

                  Very high overall complexity: 349

                  require 'gon'
                  require 'fogbugz'
                  
                  class ApplicationController < ActionController::Base
                    include Gitlab::CurrentSettings
                  Found in ApplicationController - About 2 days to fix

                  When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                  Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                  Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                  Refactorings

                  Further Reading

                  Very complex method in #inject_rblineprof

                        def inject_rblineprof
                          ret = nil
                          profile = lineprof(rblineprof_profiler_regex) do
                            ret = yield
                          end
                  Found in Peek::Rblineprof::CustomControllerHelpers - About 2 days 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

                  Very high overall complexity: 345

                  module API
                    class Runner < Grape::API
                      helpers ::API::Helpers::Runner
                  
                      resource :runners do
                  Found in API::Runner - About 2 days to fix

                  When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                  Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                  Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                  Refactorings

                  Further Reading

                  Very complex method in #each_pair

                              def each_pair
                                state = :key
                                key = StringIO.new
                                value = StringIO.new
                                hex_buffer = ""

                  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

                  Very complex method in #each_pair

                        def each_pair
                          state = :key
                          key = StringIO.new
                          value = StringIO.new
                          hex_buffer = ""
                  Found in Gitlab::LDAP::DN - About 2 days 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 AwardEmoji < Grape::API
                      include PaginationParams
                  
                      before { authenticate! }
                  Found in API::AwardEmoji - About 2 days to fix

                    Complex class definition

                    module API
                      class ProjectHooks < Grape::API
                        include PaginationParams
                    
                        before { authenticate! }
                    Found in API::ProjectHooks - About 2 days to fix

                      Complex class definition

                      module API
                        module V3
                          class AwardEmoji < Grape::API
                            include PaginationParams
                      
                      
                      Found in API::V3::AwardEmoji - About 2 days to fix

                        Very high overall complexity: 336

                        module Gitlab
                          module GithubImport
                            class Importer
                              include Gitlab::ShellAdapter
                        
                        
                        Found in Gitlab::GithubImport::Importer - About 2 days to fix

                        When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                        Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                        Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                        Refactorings

                        Further Reading

                        Complex class definition

                        module API
                          class AccessRequests < Grape::API
                            include PaginationParams
                        
                            before { authenticate! }
                        Found in API::AccessRequests - About 2 days to fix

                          Complex class definition

                          class CommitStatus < ActiveRecord::Base
                            include HasStatus
                            include Importable
                            include AfterCommitQueue
                          
                          
                          Found in CommitStatus - About 2 days to fix

                            Identical code found in 1 other location

                            module API
                              class Settings < Grape::API
                                before { authenticated_as_admin! }
                            
                                helpers do
                            Found in API::Settings and 1 other location - About 2 days to fix
                            lib/api/v3/settings.rb on lines 66..74

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Refactorings

                            Further Reading

                            Identical code found in 1 other location

                            module API
                              module V3
                                class Settings < Grape::API
                                  before { authenticated_as_admin! }
                            
                            
                            Found in API::V3::Settings and 1 other location - About 2 days to fix
                            lib/api/settings.rb on lines 70..78

                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                            Refactorings

                            Further Reading

                            Complex class definition

                            module API
                              # Environments RESTfull API endpoints
                              class Environments < Grape::API
                                include ::API::Helpers::CustomValidators
                                include PaginationParams
                            Found in API::Environments - About 2 days to fix

                              Very high overall complexity: 326

                              class Projects::IssuesController < Projects::ApplicationController
                                include RendersNotes
                                include ToggleSubscriptionAction
                                include IssuableActions
                                include ToggleAwardEmoji
                              Found in Projects::IssuesController - About 2 days to fix

                              When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                              Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                              Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                              Refactorings

                              Further Reading

                              Very high overall complexity: 320

                              # Gitlab::Git::Commit is a wrapper around native Rugged::Commit object
                              module Gitlab
                                module Git
                                  class Commit
                                    include Gitlab::EncodingHelper
                              Found in Gitlab::Git::Commit - About 2 days to fix

                              When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                              Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                              Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                              Refactorings

                              Further Reading

                              Very high overall complexity: 317

                              require './spec/support/sidekiq'
                              require './spec/support/test_env'
                              
                              class Gitlab::Seeder::CycleAnalytics
                                def initialize(project, perf: false)
                              Found in Gitlab::Seeder::CycleAnalytics - About 2 days to fix

                              When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                              Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                              Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                              Refactorings

                              Further Reading

                              Very high overall complexity: 314

                              module API
                                module V3
                                  class Issues < Grape::API
                                    include PaginationParams
                              
                              
                              Found in API::V3::Issues - About 2 days to fix

                              When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                              Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                              Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                              Refactorings

                              Further Reading

                              Identical code found in 1 other location

                              module API
                                class Services < Grape::API
                                  services = {
                                    'asana' => [
                                      {
                              Found in API::Services and 1 other location - About 2 days to fix
                              lib/api/v3/services.rb on lines 255..290

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Refactorings

                              Further Reading

                              Identical code found in 1 other location

                              module API
                                module V3
                                  class Services < Grape::API
                                    services = {
                                      'asana' => [
                              Found in API::V3::Services and 1 other location - About 2 days to fix
                              lib/api/services.rb on lines 234..269

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Refactorings

                              Further Reading

                              Very high overall complexity: 312

                              module Gitlab
                                module GoogleCodeImport
                                  class Importer
                                    attr_reader :project, :repo, :closed_statuses
                              
                              
                              Found in Gitlab::GoogleCodeImport::Importer - About 2 days to fix

                              When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                              Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                              Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                              Refactorings

                              Further Reading

                              Identical code found in 1 other location

                              module API
                                class MergeRequests < Grape::API
                                  include PaginationParams
                              
                                  before { authenticate_non_get! }
                              Found in API::MergeRequests and 1 other location - About 2 days to fix
                              lib/api/v3/merge_requests.rb on lines 17..30

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Refactorings

                              Further Reading

                              Identical code found in 1 other location

                              module API
                                module V3
                                  class MergeRequests < Grape::API
                                    include PaginationParams
                              
                              
                              Found in API::V3::MergeRequests and 1 other location - About 2 days to fix
                              lib/api/merge_requests.rb on lines 81..94

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Refactorings

                              Further Reading

                              Complex class definition

                              module API
                                class Pipelines < Grape::API
                                  include PaginationParams
                              
                                  before { authenticate! }
                              Found in API::Pipelines - About 2 days to fix

                                Complex class definition

                                module API
                                  class Wikis < Grape::API
                                    helpers do
                                      params :wiki_page_params do
                                        requires :content, type: String, desc: 'Content of a wiki page'
                                Found in API::Wikis - About 2 days to fix

                                  Complex class definition

                                  require './spec/support/sidekiq'
                                  
                                  class Gitlab::Seeder::Pipelines
                                    STAGES = %w[build test deploy notify]
                                    BUILDS = [
                                  Found in Gitlab::Seeder::Pipelines - About 2 days to fix

                                    Very complex method in #restore

                                        def restore
                                          Gitlab.config.repositories.storages.each do |name, repository_storage|
                                            path = repository_storage['path']
                                            next unless File.exist?(path)
                                    
                                    
                                    Found in Backup::Repository - About 2 days 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

                                    Very high overall complexity: 300

                                    class Commit
                                      extend ActiveModel::Naming
                                      extend Gitlab::Cache::RequestCache
                                    
                                      include ActiveModel::Conversion
                                    Found in Commit - About 2 days to fix

                                    When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                                    Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                                    Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                                    Refactorings

                                    Further Reading

                                    Complex class definition

                                    require 'mime/types'
                                    
                                    module API
                                      module V3
                                        class Branches < Grape::API
                                    Found in API::V3::Branches - About 2 days to fix

                                      Complex class definition

                                      module API
                                        # notification_settings API
                                        class NotificationSettings < Grape::API
                                          before { authenticate! }
                                      
                                      
                                      Found in API::NotificationSettings - About 2 days to fix

                                        Very high overall complexity: 293

                                        module Backup
                                          class Manager
                                            ARCHIVES_TO_BACKUP = %w[uploads builds artifacts pages lfs registry].freeze
                                            FOLDERS_TO_BACKUP = %w[repositories db].freeze
                                            FILE_NAME_SUFFIX = '_gitlab_backup.tar'.freeze
                                        Found in Backup::Manager - About 2 days to fix

                                        When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                                        Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                                        Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                                        Refactorings

                                        Further Reading

                                        Very high overall complexity: 291

                                        module API
                                          module V3
                                            class Builds < Grape::API
                                              include PaginationParams
                                        
                                        
                                        Found in API::V3::Builds - About 1 day to fix

                                        When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

                                        Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

                                        Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

                                        Refactorings

                                        Further Reading

                                        Complex class definition

                                        require 'carrierwave/orm/activerecord'
                                        
                                        class Issue < ActiveRecord::Base
                                          include InternalId
                                          include Issuable
                                        Found in Issue - About 1 day to fix

                                          Similar code found in 2 other locations

                                          # Generated from:
                                          # SVG element list: https://www.w3.org/TR/SVG/eltindex.html
                                          # SVG Attribute list: https://www.w3.org/TR/SVG/attindex.html
                                          module Gitlab
                                            module Sanitizers
                                          Found in Gitlab::Sanitizers::SVG::Whitelist and 2 other locations - About 1 day to fix
                                          lib/gitlab/sanitizers/svg/whitelist.rb on lines 30..30
                                          lib/gitlab/sanitizers/svg/whitelist.rb on lines 31..31

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Refactorings

                                          Further Reading

                                          Similar code found in 2 other locations

                                          # Generated from:
                                          # SVG element list: https://www.w3.org/TR/SVG/eltindex.html
                                          # SVG Attribute list: https://www.w3.org/TR/SVG/attindex.html
                                          module Gitlab
                                            module Sanitizers
                                          Found in Gitlab::Sanitizers::SVG::Whitelist and 2 other locations - About 1 day to fix
                                          lib/gitlab/sanitizers/svg/whitelist.rb on lines 30..30
                                          lib/gitlab/sanitizers/svg/whitelist.rb on lines 95..95

                                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                          Refactorings

                                          Further Reading