gitlabhq/gitlabhq

View on GitHub

Showing 2,385 of 2,385 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

const memoizedLocale = () => {
  const cache = [];

  const timeAgoLocale = [
    () => [s__('Timeago|just now'), s__('Timeago|right now')],
Severity: Major
Found in app/assets/javascripts/lib/utils/datetime_utility.js and 1 other location - About 1 day to fix
app/assets/javascripts/lib/utils/datetime_utility.js on lines 98..125

Duplicated Code

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).

Tuning

This issue has a mass of 298.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File users.rb has 696 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module API
  class Users < Grape::API
    include PaginationParams
    include APIGuard
    include Helpers::CustomAttributes
Severity: Major
Found in lib/api/users.rb - About 1 day to fix

    File pipeline.rb has 669 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Ci
      class Pipeline < ApplicationRecord
        extend Gitlab::Ci::Model
        include HasStatus
        include Importable
    Severity: Major
    Found in app/models/ci/pipeline.rb - About 1 day to fix

      Class Converter has 77 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class Converter
              def on_0(_) reset                              end
      
              def on_1(_) enable(STYLE_SWITCHES[:bold])      end
      
      
      Severity: Major
      Found in lib/gitlab/ci/ansi2html.rb - About 1 day to fix

        File filtered_search_manager.js has 640 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import _ from 'underscore';
        import recentSearchesStorageKeys from 'ee_else_ce/filtered_search/recent_searches_storage_keys';
        import { getParameterByName, getUrlParamsArray } from '~/lib/utils/common_utils';
        import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
        import { visitUrl } from '../lib/utils/url_utility';
        Severity: Major
        Found in app/assets/javascripts/filtered_search/filtered_search_manager.js - About 1 day to fix

          Notes has 74 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default class Notes {
            static initialize(notes_url, note_ids, last_fetched_at, view, enableGFM) {
              if (!this.instance) {
                this.instance = new Notes(notes_url, note_ids, last_fetched_at, view, enableGFM);
              }
          Severity: Major
          Found in app/assets/javascripts/notes.js - About 1 day to fix

            Class IssuableFinder has 69 methods (exceeds 20 allowed). Consider refactoring.
            Open

            class IssuableFinder
              prepend FinderWithCrossProjectAccess
              include FinderMethods
              include CreatedAtFilter
              include Gitlab::Utils::StrongMemoize
            Severity: Major
            Found in app/finders/issuable_finder.rb - About 1 day to fix

              Class Commit has 69 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Commit
                extend ActiveModel::Naming
                extend Gitlab::Cache::RequestCache
              
                include ActiveModel::Conversion
              Severity: Major
              Found in app/models/commit.rb - About 1 day to fix

                File file_icon_map.js has 586 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                const fileExtensionIcons = {
                  html: 'html',
                  htm: 'html',
                  html_vm: 'html',
                  asp: 'html',

                  Class Note has 68 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  class Note < ApplicationRecord
                    extend ActiveModel::Naming
                    include Participable
                    include Mentionable
                    include Awardable
                  Severity: Major
                  Found in app/models/note.rb - About 1 day to fix

                    Class NotificationService has 68 methods (exceeds 20 allowed). Consider refactoring.
                    Open

                    class NotificationService
                      class Async
                        attr_reader :parent
                        delegate :respond_to_missing, to: :parent
                    
                    
                    Severity: Major
                    Found in app/services/notification_service.rb - About 1 day to fix

                      Class Group has 67 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Group < Namespace
                        include Gitlab::ConfigHelper
                        include AfterCommitQueue
                        include AccessRequestable
                        include Avatarable
                      Severity: Major
                      Found in app/models/group.rb - About 1 day to fix

                        File migration_helpers.rb has 571 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module Gitlab
                          module Database
                            module MigrationHelpers
                              BACKGROUND_MIGRATION_BATCH_SIZE = 1000 # Number of rows to process per job
                              BACKGROUND_MIGRATION_JOB_BUFFER_SIZE = 1000 # Number of jobs to bulk queue at a time
                        Severity: Major
                        Found in lib/gitlab/database/migration_helpers.rb - About 1 day to fix

                          Class ApplicationController has 65 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          class ApplicationController < ActionController::Base
                            include Gitlab::GonHelper
                            include GitlabRoutingHelper
                            include PageLayoutHelper
                            include SafeParamsHelper
                          Severity: Major
                          Found in app/controllers/application_controller.rb - About 1 day to fix

                            File projects_helper.rb has 560 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            module ProjectsHelper
                              prepend_if_ee('::EE::ProjectsHelper') # rubocop: disable Cop/InjectEnterpriseEditionModule
                            
                              def link_to_project(project)
                                link_to namespace_project_path(namespace_id: project.namespace, id: project), title: h(project.name) do
                            Severity: Major
                            Found in app/helpers/projects_helper.rb - About 1 day to fix

                              Class File has 63 methods (exceeds 20 allowed). Consider refactoring.
                              Open

                                  class File
                                    include Gitlab::Utils::StrongMemoize
                              
                                    attr_reader :diff, :repository, :diff_refs, :fallback_diff_refs, :unique_identifier
                              
                              
                              Severity: Major
                              Found in lib/gitlab/diff/file.rb - About 1 day to fix

                                Function dropzoneInput has 224 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export default function dropzoneInput(form) {
                                  const divHover = '<div class="div-dropzone-hover"></div>';
                                  const iconPaperclip = '<i class="fa fa-paperclip div-dropzone-icon"></i>';
                                  const $attachButton = form.find('.button-attach-file');
                                  const $attachingFileMessage = form.find('.attaching-file-message');
                                Severity: Major
                                Found in app/assets/javascripts/dropzone_input.js - About 1 day to fix

                                  Class Parser has 61 methods (exceeds 20 allowed). Consider refactoring.
                                  Open

                                        class Parser
                                          # keys represent the trailing digit in color changing command (30-37, 40-47, 90-97. 100-107)
                                          COLOR = {
                                            0 => 'black', # not that this is gray in the intense color table
                                            1 => 'red',
                                  Severity: Major
                                  Found in lib/gitlab/ci/ansi2json/parser.rb - About 1 day to fix

                                    Function init has 215 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                      static init(els, options) {
                                        let $els = $(els);
                                    
                                        if (!els) {
                                          $els = $('.js-milestone-select');
                                    Severity: Major
                                    Found in app/assets/javascripts/milestone_select.js - About 1 day to fix

                                      File common_utils.js has 525 lines of code (exceeds 250 allowed). Consider refactoring.
                                      Open

                                      /**
                                       * @module common-utils
                                       */
                                      
                                      import { GlBreakpointInstance as breakpointInstance } from '@gitlab/ui/dist/utils';
                                      Severity: Major
                                      Found in app/assets/javascripts/lib/utils/common_utils.js - About 1 day to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language