gitlabhq/gitlabhq

View on GitHub

Showing 2,147 of 2,147 total issues

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

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

Doorkeeper gem does not revoke token for public clients
Open

    doorkeeper (4.3.2)
Severity: Minor
Found in Gemfile.lock by bundler-audit

Advisory: CVE-2018-1000211

URL: https://blog.justinbull.ca/cve-2018-1000211-public-apps-cant-revoke-tokens-in-doorkeeper/

Solution: upgrade to >= 4.4.0, >= 5.0.0.rc2

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

export default function subscriptionSelect() {
  $('.js-subscription-event').each((i, element) => {
    const fieldName = $(element).data('fieldName');

    return $(element).glDropdown({
Severity: Major
Found in app/assets/javascripts/subscription_select.js and 1 other location - About 1 day to fix
app/assets/javascripts/issue_status_select.js on lines 4..26

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

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 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 1 day 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 196.

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

    class Commit
      include Gitlab::EncodingHelper
      prepend Gitlab::Git::RuggedImpl::Commit
      extend Gitlab::Git::WrapsGitalyErrors

Severity: Major
Found in lib/gitlab/git/commit.rb - About 7 hrs to fix

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

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

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

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

        Function GitLabDropdown has 173 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 6 hrs to fix

          Function bindEvents has 171 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const bindEvents = () => {
            const $newProjectForm = $('#new_project');
            const $projectImportUrl = $('#project_import_url');
            const $projectPath = $('.tab-pane.active #project_path');
            const $useTemplateBtn = $('.template-button > input');
          Severity: Major
          Found in app/assets/javascripts/projects/project_new.js - About 6 hrs to fix

            Function types.SET_LINE_DISCUSSIONS_FOR_FILE has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
            Open

              [types.SET_LINE_DISCUSSIONS_FOR_FILE](state, { discussion, diffPositionByLineCode, hash }) {
                const { latestDiff } = state;
            
                const discussionLineCode = discussion.line_code;
                const fileHash = discussion.diff_file.file_hash;
            Severity: Minor
            Found in app/assets/javascripts/diffs/store/mutations.js - 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

            File sorting_helper.rb has 433 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 6 hrs to fix

              File create_merge_request_dropdown.js has 426 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /* eslint-disable no-new */
              import _ from 'underscore';
              import axios from './lib/utils/axios_utils';
              import Flash from './flash';
              import DropLab from './droplab/drop_lab';
              Severity: Minor
              Found in app/assets/javascripts/create_merge_request_dropdown.js - About 6 hrs to fix

                Function insertMarkdownText has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
                Open

                export function insertMarkdownText({
                  textArea,
                  text,
                  tag,
                  cursorOffset,
                Severity: Minor
                Found in app/assets/javascripts/lib/utils/text_markdown.js - 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

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

                /* eslint-disable no-return-assign, one-var, no-var, no-unused-vars, consistent-return, object-shorthand, prefer-template, class-methods-use-this, no-lonely-if, vars-on-top */
                
                import $ from 'jquery';
                import { escape, throttle } from 'underscore';
                import { s__, __, sprintf } from '~/locale';
                Severity: Minor
                Found in app/assets/javascripts/search_autocomplete.js - About 6 hrs to fix

                  File utils.js has 418 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  import _ from 'underscore';
                  import { truncatePathMiddleToLength } from '~/lib/utils/text_utility';
                  import { diffModes, diffViewerModes } from '~/ide/constants';
                  import {
                    LINE_POSITION_LEFT,
                  Severity: Minor
                  Found in app/assets/javascripts/diffs/store/utils.js - About 6 hrs to fix

                    boardsStore has 44 functions (exceeds 20 allowed). Consider refactoring.
                    Open

                    const boardsStore = {
                      disabled: false,
                      timeTracking: {
                        limitToHours: false,
                      },
                    Severity: Minor
                    Found in app/assets/javascripts/boards/stores/boards_store.js - About 6 hrs to fix

                      Class Member has 44 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      class Member < ApplicationRecord
                        include AfterCommitQueue
                        include Sortable
                        include Importable
                        include Expirable
                      Severity: Minor
                      Found in app/models/member.rb - About 6 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language