jbox-web/redmine_git_hosting

View on GitHub

Showing 79 of 79 total issues

Method revisions has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
Open

        def revisions(path, identifier_from, identifier_to, options = {})
          revs = Revisions.new
          cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents --stdin|
          cmd_args << "--reverse" if options[:reverse]
          cmd_args << "-n" << "#{options[:limit].to_i}" if options[:limit]
Severity: Minor
Found in lib/redmine/scm/adapters/xitolite_adapter.rb - 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

Method entries has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

        def entries(path = nil, identifier = nil, options = {})
          path ||= ''
          p = scm_iconv(@path_encoding, 'UTF-8', path)
          entries = Entries.new
          cmd_args = %w|ls-tree -l|
Severity: Minor
Found in lib/redmine/scm/adapters/xitolite_adapter.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

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

require 'redmine/scm/adapters/abstract_adapter'

# XitoliteAdapter inherits from GitAdapter but some classes which are define directly in GitAdapter are not inherited
# (GitBranch, ScmCommandAborted and maybe others) so it raises NameError exception.
# To fix this I had to reimplement (copy/past) the whole GitAdapter class in XitoliteAdapter...
Severity: Minor
Found in lib/redmine/scm/adapters/xitolite_adapter.rb - About 6 hrs to fix

    Class XitoliteAdapter has 35 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class XitoliteAdapter < AbstractAdapter
    
            # Git executable name
            XITOLITE_BIN = Redmine::Configuration['scm_git_command'] || "git"
    
    
    Severity: Minor
    Found in lib/redmine/scm/adapters/xitolite_adapter.rb - About 4 hrs to fix

      Method revisions has 106 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def revisions(path, identifier_from, identifier_to, options = {})
                revs = Revisions.new
                cmd_args = %w|log --no-color --encoding=UTF-8 --raw --date=iso --pretty=fuller --parents --stdin|
                cmd_args << "--reverse" if options[:reverse]
                cmd_args << "-n" << "#{options[:limit].to_i}" if options[:limit]
      Severity: Major
      Found in lib/redmine/scm/adapters/xitolite_adapter.rb - About 4 hrs to fix

        Method diff_with_options has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

              def diff_with_options
                if params[:format] == 'diff'
                  @diff = @repository.diff(@path, @rev, @rev_to, bypass_cache: true)
                  (show_error_not_found; return) unless @diff
                  filename = "changeset_r#{@rev}"
        Severity: Minor
        Found in lib/redmine_git_hosting/patches/repositories_controller_patch.rb - About 3 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 find_project_repository has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

              def find_project_repository
                @project = Project.find(params[:id])
                if params[:repository_id].present?
                  @repository = @project.repositories.find_by_identifier_param(params[:repository_id])
                else
        Severity: Minor
        Found in lib/redmine_git_hosting/patches/repositories_controller_patch.rb - About 2 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 bootstrap_tooltip.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* ===========================================================
         * bootstrap-tooltip.js v2.3.2
         * http://getbootstrap.com/2.3.2/javascript.html#tooltips
         * Inspired by the original jQuery.tipsy by Jason Frame
         * ===========================================================
        Severity: Minor
        Found in assets/javascripts/bootstrap/bootstrap_tooltip.js - About 2 hrs to fix

          Class ShellRedirector has 21 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class ShellRedirector
          
              # Redirector states
              WAIT_TO_CHECK = 0
              RUNNING_SHELL = 1
          Severity: Minor
          Found in lib/redmine_git_hosting/shell_redirector.rb - About 2 hrs to fix

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

              $.get($(element).attr('href'), function(data){
                $('#ajax-modal').html(data);
                $('#ajax-modal').dialog('option', 'title', title);
                $('#ajax-modal').dialog('open');
              });
            Severity: Major
            Found in assets/javascripts/plugin.js and 1 other location - About 2 hrs to fix
            assets/javascripts/bootstrap/bootstrap_modal.js on lines 32..36

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

            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

              $.get($(element).attr('href'), function(data){
                $('#modal-box').html(data);
                $('#modal-box').dialog('option', 'title', title);
                $('#modal-box').dialog('open');
              });
            Severity: Major
            Found in assets/javascripts/bootstrap/bootstrap_modal.js and 1 other location - About 2 hrs to fix
            assets/javascripts/plugin.js on lines 19..23

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

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

                  def merge_permissions(current_permissions, old_permissions)
                    merge_permissions = {}
                    merge_permissions['RW+'] = {}
                    merge_permissions['RW'] = {}
                    merge_permissions['R'] = {}
            Severity: Minor
            Found in app/services/permissions_builder/standard.rb - About 2 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 extract_permissions has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def extract_permissions(current_permissions)
                    old_permissions = {}
            
                    current_permissions.each do |perm, branch_settings|
                      old_permissions[perm] = {}
            Severity: Minor
            Found in app/models/concerns/gitolitable/permissions.rb - About 2 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 check_ref_spec has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

                  def check_ref_spec
                    refspec_parse = RedmineGitHosting::Validators.valid_git_refspec?(mirror.explicit_refspec)
                    payloads.each do |payload|
                      if splitpath = RedmineGitHosting::Utils::Git.parse_refspec(payload[:ref])
                        return true if payload[:ref] == refspec_parse[1]  # Explicit Reference Spec complete path
            Severity: Minor
            Found in app/services/redmine_hooks/update_mirrors.rb - About 2 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 find_by_path has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                    def find_by_path(path, flags = {})
                      parseit = path.match(/\A.*?(([^\/]+)\/)?([^\/]+?)(\.git)?\z/)
                      return nil if parseit.nil?
            
                      project = Project.find_by_identifier(parseit[3])
            Severity: Minor
            Found in app/models/concerns/gitolitable/cache.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 3 locations. Consider refactoring.
            Open

            function key_mode_change(element) {
              if (!element) return;
              var idx = element.selectedIndex;
              if (idx == 0) {
                $('#new_key_window').show();
            Severity: Major
            Found in assets/javascripts/application.js and 2 other locations - About 1 hr to fix
            assets/javascripts/application.js on lines 1..9
            assets/javascripts/application.js on lines 11..19

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

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

            function push_mode_change(element) {
              if (!element) return;
              var idx = element.selectedIndex;
              if (idx == 0) {
                $('#ref_spec_options').hide();
            Severity: Major
            Found in assets/javascripts/application.js and 2 other locations - About 1 hr to fix
            assets/javascripts/application.js on lines 1..9
            assets/javascripts/application.js on lines 21..29

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

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

            function post_mode_change(element) {
              if (!element) return;
              var idx = element.selectedIndex;
              if (idx == 0) {
                $('#payload_options').show();
            Severity: Major
            Found in assets/javascripts/application.js and 2 other locations - About 1 hr to fix
            assets/javascripts/application.js on lines 11..19
            assets/javascripts/application.js on lines 21..29

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

            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 show has 42 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              , show: function () {
                  var $tip
                    , pos
                    , actualWidth
                    , actualHeight
            Severity: Minor
            Found in assets/javascripts/bootstrap/bootstrap_tooltip.js - About 1 hr to fix

              Function createAreaChart has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function createAreaChart(element){
                $(element.target).highcharts({
                  chart: {
                    type: 'areaspline'
                  },
              Severity: Minor
              Found in assets/javascripts/set_highcharts.js - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language