gitlabhq/gitlabhq

View on GitHub

Showing 2,852 of 2,852 total issues

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

export default function issueStatusSelect() {
  $('.js-issue-status').each((i, el) => {
    const fieldName = $(el).data('fieldName');
    return $(el).glDropdown({
      selectable: true,
Severity: Major
Found in app/assets/javascripts/issue_status_select.js and 1 other location - About 7 hrs to fix
app/assets/javascripts/subscription_select.js on lines 4..27

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

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

Function jumpToNextUnresolvedDiscussion has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

    jumpToNextUnresolvedDiscussion() {
      let discussionsSelector;
      let discussionIdsInScope;
      let firstUnresolvedDiscussionId;
      let nextUnresolvedDiscussionId;
Severity: Minor
Found in app/assets/javascripts/diff_notes/components/jump_to_discussion.js - About 7 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

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

  context 'Create' do
    describe 'Version control for personal snippets' do
      let(:new_file) { 'new_snippet_file' }
      let(:changed_content) { 'changes' }
      let(:commit_message) { 'Changes to snippets' }
qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_project_snippet_spec.rb on lines 4..96

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

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

  context 'Create' do
    describe 'Version control for project snippets' do
      let(:new_file) { 'new_snippet_file' }
      let(:changed_content) { 'changes' }
      let(:commit_message) { 'Changes to snippets' }
qa/qa/specs/features/browser_ui/3_create/snippet/clone_push_pull_personal_snippet_spec.rb on lines 4..97

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

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

Class MergeRequestDiff has 55 methods (exceeds 20 allowed). Consider refactoring.
Open

class MergeRequestDiff < ApplicationRecord
  include Sortable
  include Importable
  include ManualInverseAssociation
  include EachBatch
Severity: Major
Found in app/models/merge_request_diff.rb - About 7 hrs to fix

    Class GitAccess has 54 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class GitAccess
        include Gitlab::Utils::StrongMemoize
    
        ForbiddenError = Class.new(StandardError)
        NotFoundError = Class.new(StandardError)
    Severity: Major
    Found in lib/gitlab/git_access.rb - About 7 hrs to fix

      Function Keyboard has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

      const Keyboard = function() {
        var currentKey;
        var currentFocus;
        var isUpArrow = false;
        var isDownArrow = false;
      Severity: Minor
      Found in app/assets/javascripts/droplab/keyboard.js - About 7 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.rb has 482 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require_dependency 'declarative_policy'
      
      module API
        class Projects < Grape::API::Instance
          include PaginationParams
      Severity: Minor
      Found in lib/api/projects.rb - About 7 hrs to fix

        Api has 53 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: Major
        Found in app/assets/javascripts/api.js - About 7 hrs to fix

          Class Service has 53 methods (exceeds 20 allowed). Consider refactoring.
          Open

          class Service < ApplicationRecord
            include Sortable
            include Importable
            include ProjectServicesLoggable
            include DataFields
          Severity: Major
          Found in app/models/service.rb - About 7 hrs to fix

            File usage_data.rb has 473 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            module Gitlab
              class UsageData
                BATCH_SIZE = 100
            
                class << self
            Severity: Minor
            Found in lib/gitlab/usage_data.rb - About 7 hrs to fix

              Class Namespace has 52 methods (exceeds 20 allowed). Consider refactoring.
              Open

              class Namespace < ApplicationRecord
                include CacheMarkdownField
                include Sortable
                include Gitlab::VisibilityLevel
                include Routable
              Severity: Major
              Found in app/models/namespace.rb - About 7 hrs to fix

                Class Event has 52 methods (exceeds 20 allowed). Consider refactoring.
                Open

                class Event < ApplicationRecord
                  include Sortable
                  include FromUnion
                  include Presentable
                  include DeleteWithLimit
                Severity: Major
                Found in app/models/event.rb - About 7 hrs to fix

                  File sorting_helper.rb has 468 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module SortingHelper
                    def sort_options_hash
                      {
                        sort_value_created_date      => sort_title_created_date,
                        sort_value_downvotes         => sort_title_downvotes,
                  Severity: Minor
                  Found in app/helpers/sorting_helper.rb - About 7 hrs to fix

                    File notification_service.rb has 465 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    class NotificationService
                      class Async
                        attr_reader :parent
                        delegate :respond_to_missing, to: :parent
                    
                    
                    Severity: Minor
                    Found in app/services/notification_service.rb - About 7 hrs to fix

                      File api.js has 463 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import axios from './lib/utils/axios_utils';
                      import { joinPaths } from './lib/utils/url_utility';
                      import flash from '~/flash';
                      import { __ } from '~/locale';
                      
                      
                      Severity: Minor
                      Found in app/assets/javascripts/api.js - About 7 hrs to fix

                        File helpers.rb has 456 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        module API
                          module Helpers
                            include Gitlab::Utils
                            include Helpers::Pagination
                            include Helpers::PaginationStrategies
                        Severity: Minor
                        Found in lib/api/helpers.rb - About 6 hrs to fix

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

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

                            File merge_request_diff.rb has 449 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            class MergeRequestDiff < ApplicationRecord
                              include Sortable
                              include Importable
                              include ManualInverseAssociation
                              include EachBatch
                            Severity: Minor
                            Found in app/models/merge_request_diff.rb - About 6 hrs to fix

                              File merge_requests.rb has 445 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              module API
                                class MergeRequests < Grape::API::Instance
                                  include PaginationParams
                              
                                  CONTEXT_COMMITS_POST_LIMIT = 20
                              Severity: Minor
                              Found in lib/api/merge_requests.rb - About 6 hrs to fix
                                Severity
                                Category
                                Status
                                Source
                                Language