gitlabhq/gitlabhq

View on GitHub

Showing 2,388 of 2,388 total issues

File search_autocomplete.js has 398 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable no-return-assign, consistent-return, class-methods-use-this */

import $ from 'jquery';
import { escape, throttle } from 'underscore';
import { s__, __ } from '~/locale';
Severity: Minor
Found in app/assets/javascripts/search_autocomplete.js - About 5 hrs to fix

    File datetime_utility.js has 397 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import $ from 'jquery';
    import _ from 'underscore';
    import * as timeago from 'timeago.js';
    import dateFormat from 'dateformat';
    import { languageCode, s__, __, n__ } from '../../locale';
    Severity: Minor
    Found in app/assets/javascripts/lib/utils/datetime_utility.js - About 5 hrs to fix

      Class AbstractReferenceFilter has 41 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class AbstractReferenceFilter < ReferenceFilter
            include CrossProjectReference
      
            # REFERENCE_PLACEHOLDER is used for re-escaping HTML text except found
            # reference (which we replace with placeholder during re-scaping).  The
      Severity: Minor
      Found in lib/banzai/filter/abstract_reference_filter.rb - About 5 hrs to fix

        Class Config has 41 methods (exceeds 20 allowed). Consider refactoring.
        Open

              class Config
                prepend_if_ee('::EE::Gitlab::Auth::LDAP::Config') # rubocop: disable Cop/InjectEnterpriseEditionModule
        
                NET_LDAP_ENCRYPTION_METHOD = {
                  simple_tls: :simple_tls,
        Severity: Minor
        Found in lib/gitlab/auth/ldap/config.rb - About 5 hrs to fix

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

              } else {
                reopentext = reopenbtn.data('originalText');
                closetext = closebtn.data('originalText');
                if (reopenbtn.text() !== reopentext) {
                  reopenbtn.text(reopentext);
          Severity: Major
          Found in app/assets/javascripts/notes.js and 1 other location - About 5 hrs to fix
          app/assets/javascripts/notes.js on lines 1183..1198

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

          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

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

              if (textarea.val().trim().length > 0) {
                reopentext = reopenbtn.attr('data-alternative-text');
                closetext = closebtn.attr('data-alternative-text');
                if (reopenbtn.text() !== reopentext) {
                  reopenbtn.text(reopentext);
          Severity: Major
          Found in app/assets/javascripts/notes.js and 1 other location - About 5 hrs to fix
          app/assets/javascripts/notes.js on lines 1198..1213

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

          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

          Api has 40 functions (exceeds 20 allowed). Consider refactoring.
          Open

          const Api = {
            groupsPath: '/api/:version/groups.json',
            groupPath: '/api/:version/groups/:id',
            groupMembersPath: '/api/:version/groups/:id/members',
            subgroupsPath: '/api/:version/groups/:id/subgroups',
          Severity: Minor
          Found in app/assets/javascripts/api.js - About 5 hrs to fix

            Class RepositoryService has 40 methods (exceeds 20 allowed). Consider refactoring.
            Open

                class RepositoryService
                  include Gitlab::EncodingHelper
            
                  MAX_MSG_SIZE = 128.kilobytes
            
            
            Severity: Minor
            Found in lib/gitlab/gitaly_client/repository_service.rb - About 5 hrs to fix

              File qa.rb has 387 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              $: << File.expand_path(File.dirname(__FILE__))
              
              Encoding.default_external = 'UTF-8'
              
              require_relative '../lib/gitlab'
              Severity: Minor
              Found in qa/qa.rb - About 5 hrs to fix

                Function GitLabDropdown has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
                Open

                function GitLabDropdown(el1, options) {
                  let selector, self;
                  this.el = el1;
                  this.options = options;
                  this.updateLabel = this.updateLabel.bind(this);
                Severity: Minor
                Found in app/assets/javascripts/gl_dropdown.js - About 5 hrs 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 each_pair has 131 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        def each_pair
                          state = :key
                          key = StringIO.new
                          value = StringIO.new
                          hex_buffer = ""
                Severity: Major
                Found in lib/gitlab/auth/ldap/dn.rb - About 5 hrs to fix

                  File note.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

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

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

                          for (let i = 0; i < discussionIdsInScope.length; i += 1) {
                            const discussionId = discussionIdsInScope[i];
                            const discussion = discussions[discussionId];
                    
                            if (!discussion) {
                    app/assets/javascripts/vue_shared/components/date_time_picker/date_time_picker_lib.js on lines 56..68

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

                    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 merge_requests.rb has 383 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    module API
                      class MergeRequests < Grape::API
                        include PaginationParams
                    
                        before { authenticate_non_get! }
                    Severity: Minor
                    Found in lib/api/merge_requests.rb - About 5 hrs to fix

                      File group.rb has 382 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      require 'carrierwave/orm/activerecord'
                      
                      class Group < Namespace
                        include Gitlab::ConfigHelper
                        include AfterCommitQueue
                      Severity: Minor
                      Found in app/models/group.rb - About 5 hrs to fix

                        Class Environment has 39 methods (exceeds 20 allowed). Consider refactoring.
                        Open

                        class Environment < ApplicationRecord
                          include Gitlab::Utils::StrongMemoize
                          include ReactiveCaching
                        
                          self.reactive_cache_refresh_interval = 1.minute
                        Severity: Minor
                        Found in app/models/environment.rb - About 5 hrs to fix

                          File issuables_helper.rb has 381 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          module IssuablesHelper
                            include GitlabRoutingHelper
                          
                            def sidebar_gutter_toggle_icon
                              sidebar_gutter_collapsed? ? icon('angle-double-left', { 'aria-hidden': 'true' }) : icon('angle-double-right', { 'aria-hidden': 'true' })
                          Severity: Minor
                          Found in app/helpers/issuables_helper.rb - About 5 hrs to fix

                            Function tabShown has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
                            Open

                              tabShown(action, href) {
                                if (action !== this.currentTab && this.mergeRequestTabs) {
                                  this.currentTab = action;
                            
                                  if (this.mergeRequestTabPanesAll) {
                            Severity: Minor
                            Found in app/assets/javascripts/merge_request_tabs.js - About 5 hrs 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

                            File projects_controller.rb has 376 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            class ProjectsController < Projects::ApplicationController
                              include API::Helpers::RelatedResourcesHelpers
                              include IssuableCollections
                              include ExtractsPath
                              include PreviewMarkdown
                            Severity: Minor
                            Found in app/controllers/projects_controller.rb - About 5 hrs to fix

                              Function setupVueRepositoryList has 125 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              export default function setupVueRepositoryList() {
                                const el = document.getElementById('js-tree-list');
                                const { dataset } = el;
                                const { projectPath, projectShortPath, ref, fullName } = dataset;
                                const router = createRouter(projectPath, ref);
                              Severity: Major
                              Found in app/assets/javascripts/repository/index.js - About 5 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language