jbox-web/redmine_git_hosting

View on GitHub

Showing 72 of 72 total issues

Method lastrev has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

        def lastrev(path, rev)
          return if path.nil?

          cmd_args = %w[log --no-color --encoding=UTF-8 --date=iso --pretty=fuller --no-merges -n 1]
          cmd_args << '--no-renames' if self.class.client_version_above? [2, 9]
Severity: Minor
Found in lib/redmine/scm/adapters/xitolite_adapter.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 commits_per_author_with_aliases has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def commits_per_author_with_aliases
    return @commits_per_author_with_aliases unless @commits_per_author_with_aliases.nil?

    @commits_per_author_with_aliases = nil

Severity: Minor
Found in app/reports/repository_contributors_stats.rb - About 1 hr to fix

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

        def validate_revision
          commit = nil
    
          # is the revision a branch?
          repository.branches.each do |x|
    Severity: Minor
    Found in app/use_cases/repositories/download_revision.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 annotate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def annotate(path, identifier = nil)
              identifier = 'HEAD' if identifier.blank?
              cmd_args = %w[blame --encoding=UTF-8]
              cmd_args << '-p' << identifier << '--' << scm_iconv(@path_encoding, 'UTF-8', path)
              blame = Annotate.new
    Severity: Minor
    Found in lib/redmine/scm/adapters/xitolite_adapter.rb - About 1 hr to fix

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

            def diff_with_options
              if params[:format] == 'diff'
                @diff = @repository.diff @path, @rev, @rev_to, bypass_cache: true
                return show_error_not_found unless @diff
      
      
      Severity: Minor
      Found in lib/redmine_git_hosting/patches/repositories_controller_patch.rb - About 1 hr to fix

        Method entries has 29 lines of code (exceeds 25 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 1 hr to fix

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

            def check_xitolite_permissions
              case action_name
              when 'index', 'show'
                perm = "view_#{controller_name}".to_sym
                render_403 unless User.current.git_allowed_to? perm, @repository
          Severity: Minor
          Found in app/controllers/redmine_git_hosting_controller.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 create_member has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def create_member(ids, current_ids, klass, destroy: true, inherited_by: nil, &block)
                ids = (ids || []).collect(&:to_i) - [0]
                new_ids = ids - current_ids
                new_ids.each do |id|
                  object = klass.find_by id: id
          Severity: Minor
          Found in app/use_cases/repository_protected_branches/member_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 diff has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  def diff(path, identifier_from, identifier_to = nil, **opts)
                    path ||= ''
                    cmd_args = []
                    if identifier_to
                      cmd_args << 'diff' << '--no-color' << identifier_to << identifier_from
          Severity: Minor
          Found in lib/redmine/scm/adapters/xitolite_adapter.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 annotate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                  def annotate(path, identifier = nil)
                    identifier = 'HEAD' if identifier.blank?
                    cmd_args = %w[blame --encoding=UTF-8]
                    cmd_args << '-p' << identifier << '--' << scm_iconv(@path_encoding, 'UTF-8', path)
                    blame = Annotate.new
          Severity: Minor
          Found in lib/redmine/scm/adapters/xitolite_adapter.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 sync_with_github has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def sync_with_github
                create_relation = false
          
                ## We don't have stored relation
                if github_issue.nil?
          Severity: Minor
          Found in app/services/redmine_hooks/github_issues_sync.rb - About 1 hr to fix

            Method git_config has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def git_config
                  repo_conf = {}
            
                  # This is needed for all Redmine repositories
                  repo_conf['redminegitolite.projectid']     = project.identifier.to_s
            Severity: Minor
            Found in app/models/concerns/gitolitable/config.rb - About 1 hr to fix

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

                    def temp_dir_writeable?(reset: false)
                      @temp_dir_writeable = reset
              
                      unless @temp_dir_writeable
                        file_logger.debug "Testing if Gitolite Admin directory '#{create_temp_dir}' is writeable ..."
              Severity: Minor
              Found in lib/redmine_git_hosting/config/gitolite_config_tests.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 branches has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def branches
                        return @branches if @branches
              
                        @branches = []
                        cmd_args = %w[branch --no-color --verbose --no-abbrev]
              Severity: Minor
              Found in lib/redmine/scm/adapters/xitolite_adapter.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 authorized_request? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                    def authorized_request?
                      case git_cmd
                      when *RedmineGitHosting::GitAccess::DOWNLOAD_COMMANDS
                        if @user
                          RedmineGitHosting::GitAccess.new.download_access_check(@user, repository, ssl: is_ssl?).allowed?
              Severity: Minor
              Found in lib/redmine_git_hosting/patches/grack_auth_patch.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 mirror_configuration has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                def mirror_configuration
                  if mirror_mode?
                    reset_fields
                  elsif include_all_branches? && include_all_tags?
                    mutual_exclusion_error
              Severity: Minor
              Found in app/models/repository_mirror.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 sync_with_github has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def sync_with_github
                    create_relation = false
              
                    ## We don't have stored relation
                    if github_issue.nil?
              Severity: Minor
              Found in app/services/redmine_hooks/github_issues_sync.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 get_cache has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                      def get_cache(repo_id, command)
                        cached = GitCache.find_by repo_identifier: repo_id, command: command
                        if cached
                          if valid_cache_entry? cached.created_at
                            # Update updated_at flag
              Severity: Minor
              Found in lib/redmine_git_hosting/cache/database.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 auth! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                    def auth!
                      if @auth.provided?
                        return bad_request unless @auth.basic?
              
                        # Authentication with username and password
              Severity: Minor
              Found in lib/redmine_git_hosting/patches/grack_auth_patch.rb - About 45 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 additional_constraints_on_identifier has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def additional_constraints_on_identifier
                    if identifier.present? && (new_record? || identifier_changed?)
                      errors.add :identifier, :cannot_equal_project if Project.find_by identifier: identifier
              
                      # See if a repo for another project has the same identifier (existing validations already check for current project)
              Severity: Minor
              Found in app/models/concerns/gitolitable/validations.rb - About 45 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