gitlabhq/gitlabhq

View on GitHub

Showing 111 of 111 total issues

Function inWords has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    inWords: function(distanceMillis) {
      var $l = this.settings.strings;
      var prefix = $l.prefixAgo;
      var suffix = $l.suffixAgo;
      if (this.settings.allowFuture) {
Severity: Minor
Found in app/assets/javascripts/lib/jquery.timeago.js - About 1 hr to fix

    Method execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def execute
          @issues = @project.issues
    
          @issues = case params[:state]
                    when 'all' then @issues
    Severity: Minor
    Found in app/contexts/issues/list_context.rb - About 1 hr 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 4 locations. Consider refactoring.
    Open

      var _HH = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_H(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
      };
    Severity: Major
    Found in app/assets/javascripts/lib/md5.js and 3 other locations - About 1 hr to fix
    app/assets/javascripts/lib/md5.js on lines 52..55
    app/assets/javascripts/lib/md5.js on lines 57..60
    app/assets/javascripts/lib/md5.js on lines 67..70

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

    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 execute has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def execute
          project = @from_project.dup
          project.name = @from_project.name
          project.path = @from_project.path
          project.namespace = current_user.namespace
    Severity: Minor
    Found in app/contexts/projects/fork_context.rb - About 1 hr 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 4 locations. Consider refactoring.
    Open

      var _II = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_I(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
      };
    Severity: Major
    Found in app/assets/javascripts/lib/md5.js and 3 other locations - About 1 hr to fix
    app/assets/javascripts/lib/md5.js on lines 52..55
    app/assets/javascripts/lib/md5.js on lines 57..60
    app/assets/javascripts/lib/md5.js on lines 62..65

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

    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 4 locations. Consider refactoring.
    Open

      var _FF = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_F(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
      };
    Severity: Major
    Found in app/assets/javascripts/lib/md5.js and 3 other locations - About 1 hr to fix
    app/assets/javascripts/lib/md5.js on lines 57..60
    app/assets/javascripts/lib/md5.js on lines 62..65
    app/assets/javascripts/lib/md5.js on lines 67..70

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

    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 4 locations. Consider refactoring.
    Open

      var _GG = function (a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(_G(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
      };
    Severity: Major
    Found in app/assets/javascripts/lib/md5.js and 3 other locations - About 1 hr to fix
    app/assets/javascripts/lib/md5.js on lines 52..55
    app/assets/javascripts/lib/md5.js on lines 62..65
    app/assets/javascripts/lib/md5.js on lines 67..70

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

    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 unpack has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def unpack
          Dir.chdir(Gitlab.config.backup.path)
    
          # check for existing backups in the backup dir
          file_list = Dir.glob("*_gitlab_backup.tar").each.map { |f| f.split(/_/).first.to_i }
    Severity: Minor
    Found in lib/backup/manager.rb - About 1 hr 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 post_receive_data has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def post_receive_data(oldrev, newrev, ref)
        # Total commits count
        push_commits_count = push_commits.size
    
        # Get latest 20 commits ASC
    Severity: Minor
    Found in app/services/git_push_service.rb - About 1 hr to fix

      Method restore has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def restore
            if File.exists?(repos_path)
              # Move repos dir to 'repositories.old' dir
              bk_repos_path = File.join(repos_path, '..', 'repositories.old.' + Time.now.to_i.to_s)
              FileUtils.mv(repos_path, bk_repos_path)
      Severity: Minor
      Found in lib/backup/repository.rb - About 1 hr to fix

        Method build_event_data has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self.build_event_data(model, event)
            data = {
              event_name: build_event_name(model, event),
              created_at: model.created_at
            }
        Severity: Minor
        Found in app/services/system_hooks_service.rb - About 1 hr to fix

          Method event_feed_url has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def event_feed_url(event)
              if event.issue?
                project_issue_url(event.project, event.issue)
              elsif event.merge_request?
                project_merge_request_url(event.project, event.merge_request)
          Severity: Minor
          Found in app/helpers/events_helper.rb - About 1 hr 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 count_to_display_commit_in_center has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def count_to_display_commit_in_center
                offset = -1
                skip = 0
                while offset == -1
                  tmp_commits = find_commits(skip)
          Severity: Minor
          Found in app/models/network/graph.rb - About 1 hr 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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def execute
              merge_requests = @project.merge_requests
          
              merge_requests = case params[:state]
                               when 'all' then merge_requests
          Severity: Minor
          Found in app/contexts/merge_requests_load_context.rb - About 1 hr 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 extract_ref has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def extract_ref(id)
              pair = ['', '']
          
              return pair unless @project
          
          
          Severity: Minor
          Found in lib/extracts_path.rb - About 1 hr 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 execute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def execute
                update_data = params[:update]
          
                issues_ids   = update_data[:issues_ids].split(",")
                milestone_id = update_data[:milestone_id]
          Severity: Minor
          Found in app/contexts/issues/bulk_update_context.rb - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                if @project && @project.repository.exists? && @project.repository.root_ref
                  project_nav = [
                    { label: "#{simple_sanitize(@project.name_with_namespace)} - Files",    url: project_tree_path(@project, @ref || @project.repository.root_ref) },
                    { label: "#{simple_sanitize(@project.name_with_namespace)} - Commits",  url: project_commits_path(@project, @ref || @project.repository.root_ref) },
                    { label: "#{simple_sanitize(@project.name_with_namespace)} - Network",  url: project_network_path(@project, @ref || @project.repository.root_ref) },
            Severity: Major
            Found in app/helpers/application_helper.rb - About 1 hr to fix

              Method project_abilities has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def project_abilities(user, project)
                    rules = []
              
                    team = project.team
              
              
              Severity: Minor
              Found in app/models/ability.rb - About 55 mins 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 merge! has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def merge!
                      in_locked_and_timed_satellite do |merge_repo|
                        prepare_satellite!(merge_repo)
                        if merge_in_satellite!(merge_repo)
                          # push merge back to Gitolite
              Severity: Minor
              Found in lib/gitlab/satellite/merge_action.rb - About 55 mins 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 parse_references has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_references(text)
                    # parse reference links
                    text.gsub!(REFERENCE_PATTERN) do |match|
                      prefix     = $~[:prefix]
                      suffix     = $~[:suffix]
              Severity: Minor
              Found in lib/gitlab/markdown.rb - About 55 mins 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

              Severity
              Category
              Status
              Source
              Language