gitlabhq/gitlabhq

View on GitHub

Showing 1,717 of 1,717 total issues

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

Class File has 54 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

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

      File pipeline.rb has 475 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 ApplicationController has 49 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

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

                class Commit
                  include Gitlab::EncodingHelper
            
                  attr_accessor :raw_commit, :head
            
            
            Severity: Minor
            Found in lib/gitlab/git/commit.rb - About 6 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 1204..1222

              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 1222..1240

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

              class IssuableFinder
                prepend FinderWithCrossProjectAccess
                include FinderMethods
                include CreatedAtFilter
              
              
              Severity: Minor
              Found in app/finders/issuable_finder.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, 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 */
                /* 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

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

                  export default function projectAvatar() {
                    $('.js-choose-project-avatar-button').bind('click', function onClickAvatar() {
                      const form = $(this).closest('form');
                      return form.find('.js-project-avatar-input').click();
                    });
                  app/assets/javascripts/group_avatar.js on lines 3..14

                  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

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

                  module ProjectsHelper
                    def link_to_project(project)
                      link_to [project.namespace.becomes(Namespace), project], title: h(project.name) do
                        title = content_tag(:span, project.name, class: 'project-name')
                  
                  
                  Severity: Minor
                  Found in app/helpers/projects_helper.rb - About 6 hrs to fix

                    File projects.rb has 419 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

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

                      Function GitLabDropdown has 149 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        function GitLabDropdown(el1, options) {
                          var searchFields, selector, self;
                          this.el = el1;
                          this.options = options;
                          this.updateLabel = this.updateLabel.bind(this);
                      Severity: Major
                      Found in app/assets/javascripts/gl_dropdown.js - About 5 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language