gitlabhq/gitlabhq

View on GitHub

Showing 1,689 of 1,689 total issues

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

    const localeRemaining = function getLocaleRemaining(number, index) {
      return [
        [s__('Timeago|less than a minute ago'), s__('Timeago|right now')],
        [s__('Timeago|less than a minute ago'), s__('Timeago|%s seconds remaining')],
        [s__('Timeago|about a minute ago'), s__('Timeago|1 minute remaining')],
Severity: Major
Found in app/assets/javascripts/lib/utils/datetime_utility.js and 1 other location - About 7 hrs to fix
app/assets/javascripts/lib/utils/datetime_utility.js on lines 98..115

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

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 Note has 55 methods (exceeds 20 allowed). Consider refactoring.
Open

class Note < ActiveRecord::Base
  extend ActiveModel::Naming
  include Participable
  include Mentionable
  include Awardable
Severity: Major
Found in app/models/note.rb - About 7 hrs to fix

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

    export default class DockerfileSelector extends FileTemplateSelector {
      constructor({ mediator }) {
        super(mediator);
        this.config = {
          key: 'dockerfile',
    app/assets/javascripts/blob/template_selectors/ci_yaml_selector.js on lines 5..32

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

    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

    export default class BlobCiYamlSelector extends FileTemplateSelector {
      constructor({ mediator }) {
        super(mediator);
        this.config = {
          key: 'gitlab-ci-yaml',
    app/assets/javascripts/blob/template_selectors/dockerfile_selector.js on lines 5..32

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

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

    Method inject_rblineprof has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

          def inject_rblineprof
            ret = nil
            profile = lineprof(rblineprof_profiler_regex) do
              ret = yield
            end
    Severity: Minor
    Found in lib/peek/rblineprof/custom_controller_helpers.rb - 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

    Class NotificationService has 53 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 7 hrs to fix

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

      module Gitlab
        module Database
          module MigrationHelpers
            include Gitlab::Database::ArelMethods
      
      
      Severity: Minor
      Found in lib/gitlab/database/migration_helpers.rb - About 7 hrs to fix

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

            class File
              attr_reader :diff, :repository, :diff_refs, :fallback_diff_refs
        
              delegate :new_file?, :deleted_file?, :renamed_file?,
                :old_path, :new_path, :a_mode, :b_mode, :mode_changed?,
        Severity: Major
        Found in lib/gitlab/diff/file.rb - About 7 hrs to fix

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

          module Ci
            class Pipeline < ActiveRecord::Base
              extend Gitlab::Ci::Model
              include HasStatus
              include Importable
          Severity: Minor
          Found in app/models/ci/pipeline.rb - About 7 hrs to fix

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

            class Event < ActiveRecord::Base
              include Sortable
              include IgnorableColumn
              default_scope { reorder(nil) }
            
            
            Severity: Minor
            Found in app/models/event.rb - About 7 hrs to fix

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

              class Group < Namespace
                include Gitlab::ConfigHelper
                include AfterCommitQueue
                include AccessRequestable
                include Avatarable
              Severity: Minor
              Found in app/models/group.rb - About 7 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 6 hrs to fix
                app/assets/javascripts/notes.js on lines 1324..1342

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

                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 6 hrs to fix
                app/assets/javascripts/notes.js on lines 1342..1360

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

                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

                Method each_pair has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
                Open

                              def each_pair
                                state = :key
                                key = StringIO.new
                                value = StringIO.new
                                hex_buffer = ""
                Severity: Minor
                Found in lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb - About 6 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 a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
                Open

                        def each_pair
                          state = :key
                          key = StringIO.new
                          value = StringIO.new
                          hex_buffer = ""
                Severity: Minor
                Found in lib/gitlab/auth/ldap/dn.rb - About 6 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

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

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

                  File commit.rb has 434 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Gitlab
                    module Git
                      class Commit
                        include Gitlab::EncodingHelper
                  
                  
                  Severity: Minor
                  Found in lib/gitlab/git/commit.rb - About 6 hrs to fix

                    File labels_select.js has 433 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    /* eslint-disable no-useless-return, func-names, space-before-function-paren, wrap-iife, no-var, no-underscore-dangle, prefer-arrow-callback, max-len, one-var, no-unused-vars, one-var-declaration-per-line, prefer-template, no-new, consistent-return, object-shorthand, comma-dangle, no-shadow, no-param-reassign, brace-style, vars-on-top, quotes, no-lonely-if, no-else-return, dot-notation, no-empty, no-return-assign, camelcase, prefer-spread */
                    /* global Issuable */
                    /* global ListLabel */
                    
                    import $ from 'jquery';
                    Severity: Minor
                    Found in app/assets/javascripts/labels_select.js - About 6 hrs to fix

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

                      export default function groupAvatar() {
                        $('.js-choose-group-avatar-button').on('click', function onClickGroupAvatar() {
                          const form = $(this).closest('form');
                          return form.find('.js-group-avatar-input').click();
                        });
                      Severity: Major
                      Found in app/assets/javascripts/group_avatar.js and 1 other location - About 6 hrs to fix
                      app/assets/javascripts/pages/projects/shared/project_avatar.js on lines 3..15

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

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language