jbox-web/redmine_git_hosting

View on GitHub

Very high overall complexity: 652

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...
Found in Redmine::Scm::Adapters::XitoliteAdapter - About 5 days to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Very complex method in #revisions

        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]
Found in Redmine::Scm::Adapters::XitoliteAdapter - About 3 days to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Identical code found in 1 other location

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...
lib/redmine/scm/adapters/xitolite_adapter.rb on lines 299..307

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

Refactorings

Further Reading

Identical code found in 1 other location

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...
lib/redmine/scm/adapters/xitolite_adapter.rb on lines 245..253

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

Refactorings

Further Reading

Very complex method in #add_redmine_key

        def add_redmine_key
          # RedmineGitHosting key must be in RW+ group
          # If not create the RW+ group and add the key
          if perms.empty?
            logger.info("#{context} : No permissions set for '@all' repository, add RedmineGitHosting key")

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

High overall complexity: 209

require 'stringio'

module RedmineGitHosting
  class ShellRedirector

Found in RedmineGitHosting::ShellRedirector - About 1 day to fix

When classes take on too many responsibilities, they grow. A large number of instance variables or methods can make a class hard to understand. Large classes tend to have lower cohesion and higher churn.

Often large classes have methods that do not operate on all of the class state. Identifying the groups of data that are used together can point to seams to split out additional collaborator classes or value objects.

Another trick is to look for repeated prefixes or suffixes in method and variable names, or repeated parameter names, and use them to guide extractions.

Refactorings

Further Reading

Very complex method in #commits_per_author_with_aliases

    def commits_per_author_with_aliases
      return @commits_per_author_with_aliases if !@commits_per_author_with_aliases.nil?
      @commits_per_author_with_aliases = nil

      registered_committers = []
Found in RepositoryContributorsStats - About 1 day to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Similar code found in 1 other location

require 'json'
require 'net/http'
require 'net/https'
require 'uri'

Found in GitHosting::HttpHelper and 1 other location - About 1 day to fix
lib/redmine_git_hosting/utils/http.rb on lines 72..89

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

Refactorings

Further Reading

Similar code found in 1 other location

require 'json'
require 'net/http'
require 'net/https'
require 'uri'

Found in RedmineGitHosting::Utils::Http and 1 other location - About 1 day to fix
contrib/hooks/post-receive/lib/git_hosting_http_helper.rb on lines 106..122

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

Refactorings

Further Reading

Very complex method in #find_project_repository

        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

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Very complex method in #find_by_path

        def find_by_path(path, flags = {})
          parseit = path.match(/\A.*?(([^\/]+)\/)?([^\/]+?)(\.git)?\z/)
          return nil if parseit.nil?

          project = Project.find_by_identifier(parseit[3])
Found in Gitolitable::Cache - About 7 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Very complex method in #build_list_of_keys

  def build_list_of_keys(user_keys, other_keys, disabled_keys)
    option_array = [[l(:label_deployment_credential_select_deploy_key), -1]]
    option_array += user_keys.map { |key| [keylabel(key), key.id] }

    if !other_keys.empty?
Found in RepositoryDeploymentCredentialsHelper - About 7 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #entries

        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|
Found in Redmine::Scm::Adapters::XitoliteAdapter - About 7 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #diff_with_options

        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}"

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #create_member

    def create_member(ids, current_ids, klass, opts = {}, &block)
      destroy      = opts.fetch(:destroy, true)
      inherited_by = opts.fetch(:inherited_by, nil)

      ids = (ids || []).collect(&:to_i) - [0]
Found in RepositoryProtectedBranches::MemberManager - About 6 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex method in #sync_with_github

      def sync_with_github
        create_relation = false

        ## We don't have stored relation
        if github_issue.nil?
Found in RedmineHooks::GithubIssuesSync - About 5 hrs to fix

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Similar code found in 1 other location

module Repositories
  class ExecuteHooks

    attr_reader :repository
    attr_reader :hook_type
Found in Repositories::ExecuteHooks and 1 other location - About 5 hrs to fix
app/use_cases/repositories/execute_hooks.rb on lines 43..57

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

Refactorings

Further Reading

Similar code found in 1 other location

module Repositories
  class ExecuteHooks

    attr_reader :repository
    attr_reader :hook_type
Found in Repositories::ExecuteHooks and 1 other location - About 5 hrs to fix
app/use_cases/repositories/execute_hooks.rb on lines 61..75

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

Refactorings

Further Reading

Complex method in #watchers_list_with_git_hosting

      def watchers_list_with_git_hosting(object, &block)
        remove_allowed = User.current.allowed_to?("delete_#{object.class.name.underscore}_watchers".gsub('/', '_').to_sym, object.project)
        content = ''.html_safe
        lis = object.watcher_users.collect do |user|
          s = ''.html_safe

Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

Refactorings

Read More

Complex class definition

module PluginSettingsValidation
  module GitoliteConfig
    extend ActiveSupport::Concern

    included do
Found in PluginSettingsValidation::GitoliteConfig - About 4 hrs to fix

    Similar code found in 1 other location

    module PermissionsBuilder
      class Standard < Base
    
        attr_reader :permissions
    
    
    Found in PermissionsBuilder::Standard and 1 other location - About 4 hrs to fix
    app/services/permissions_builder/standard.rb on lines 41..48

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

    Refactorings

    Further Reading

    Similar code found in 1 other location

    module PermissionsBuilder
      class Standard < Base
    
        attr_reader :permissions
    
    
    Found in PermissionsBuilder::Standard and 1 other location - About 4 hrs to fix
    app/services/permissions_builder/standard.rb on lines 52..59

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

    Refactorings

    Further Reading

    Complex method in #remove_redmine_key

            def remove_redmine_key
              # RedmineGitHosting key must be in [RW+][''] group
              # Return if those groups are absent : it means that our key is not here
              return if perms.empty? || !perms[0]['RW+'].include?('')
    
    

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #create_repository

            def create_repository
              admin.transaction do
                create_gitolite_repository(repository)
                gitolite_admin_repo_commit(repository.gitolite_repository_name)
    
    

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #create_redmine_issue

          def create_redmine_issue
            logger.info('Github Issues Sync : create new issue')
    
            issue             = project.issues.new
            issue.tracker_id  = project.trackers.first.try(:id)
    Found in RedmineHooks::GithubIssuesSync - About 4 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #lastrev

            def lastrev(path, rev)
              return nil if path.nil?
              cmd_args = %w|log --no-color --encoding=UTF-8 --date=iso --pretty=fuller --no-merges -n 1|
              cmd_args << rev if rev
              cmd_args << "--" << path unless path.empty?
    Found in Redmine::Scm::Adapters::XitoliteAdapter - About 4 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Similar code found in 1 other location

    module RedmineGitHosting
      module GitoliteHandlers
        module Repositories
          class MoveRepository < Base
    
    
    lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb on lines 194..201

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

    Refactorings

    Further Reading

    Similar code found in 1 other location

    module RedmineGitHosting
      module GitoliteHandlers
        module Repositories
          class MoveRepository < Base
    
    
    lib/redmine_git_hosting/gitolite_handlers/repositories/move_repository.rb on lines 173..180

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

    Refactorings

    Further Reading

    Complex method in #annotate

            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
    Found in Redmine::Scm::Adapters::XitoliteAdapter - About 3 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #call

            def call
              repo_key = find_gitolite_key(key.owner, key.location)
    
              # Add it if not found
              if repo_key.nil?

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Complex method in #git_config

        def git_config
          repo_conf = {}
    
          # This is needed for all Redmine repositories
          repo_conf['redminegitolite.projectid']     = project.identifier.to_s
    Found in Gitolitable::Config - About 3 hrs to fix

    Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

    Refactorings

    Read More

    Similar code found in 2 other locations

    module RedmineGitHosting
      module GitoliteHandlers
        module Repositories
          class Base
    
    
    lib/redmine_git_hosting/gitolite_handlers/repositories/base.rb on lines 109..111
    lib/redmine_git_hosting/gitolite_handlers/repositories/base.rb on lines 121..123

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

    Refactorings

    Further Reading

    Similar code found in 2 other locations

    module RedmineGitHosting
      module GitoliteHandlers
        module Repositories
          class Base
    
    
    lib/redmine_git_hosting/gitolite_handlers/repositories/base.rb on lines 109..111
    lib/redmine_git_hosting/gitolite_handlers/repositories/base.rb on lines 115..117

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

    Refactorings

    Further Reading

    Similar code found in 2 other locations

    module RedmineGitHosting
      module GitoliteHandlers
        module Repositories
          class Base
    
    
    lib/redmine_git_hosting/gitolite_handlers/repositories/base.rb on lines 115..117
    lib/redmine_git_hosting/gitolite_handlers/repositories/base.rb on lines 121..123

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

    Refactorings

    Further Reading

    Complex class definition

    module PluginSettingsValidation
      module SshConfig
        extend ActiveSupport::Concern
    
        included do
    Found in PluginSettingsValidation::SshConfig - About 3 hrs to fix

      Complex method in #execute_action

            def execute_action(action, object, options = {})
              begin
                admin = gitolite_admin
              rescue Rugged::SshError => e
                logger.error 'Invalid Gitolite Admin SSH Keys'
      Found in RedmineGitHosting::GitoliteWrapper - About 3 hrs to fix

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Similar code found in 3 other locations

      module RedmineGitHosting
        module GitoliteAccessor
          extend self
      
          module Methods
      Found in RedmineGitHosting::GitoliteAccessor and 3 other locations - About 3 hrs to fix
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 41..43
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 47..49
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 59..61

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

      Refactorings

      Further Reading

      Similar code found in 3 other locations

      module RedmineGitHosting
        module GitoliteAccessor
          extend self
      
          module Methods
      Found in RedmineGitHosting::GitoliteAccessor and 3 other locations - About 3 hrs to fix
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 47..49
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 53..55
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 59..61

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

      Refactorings

      Further Reading

      Similar code found in 3 other locations

      module RedmineGitHosting
        module GitoliteAccessor
          extend self
      
          module Methods
      Found in RedmineGitHosting::GitoliteAccessor and 3 other locations - About 3 hrs to fix
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 41..43
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 47..49
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 53..55

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

      Refactorings

      Further Reading

      Similar code found in 3 other locations

      module RedmineGitHosting
        module GitoliteAccessor
          extend self
      
          module Methods
      Found in RedmineGitHosting::GitoliteAccessor and 3 other locations - About 3 hrs to fix
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 41..43
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 53..55
      lib/redmine_git_hosting/gitolite_accessor.rb on lines 59..61

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

      Refactorings

      Further Reading

      Complex method in #branches

              def branches
                return @branches if !@branches.nil?
                @branches = []
                cmd_args = %w|branch --no-color --verbose --no-abbrev|
                git_cmd(cmd_args) do |io|
      Found in Redmine::Scm::Adapters::XitoliteAdapter - About 3 hrs to fix

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Similar code found in 1 other location

      module RedmineHooks
        class CallWebservices < Base
      
          include HttpHelper
      
      
      Found in RedmineHooks::CallWebservices and 1 other location - About 2 hrs to fix
      app/services/redmine_hooks/update_mirrors.rb on lines 4..10

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

      Refactorings

      Further Reading

      Similar code found in 1 other location

      module RedmineHooks
        class UpdateMirrors < Base
      
          def call
            execute_hook do |out|
      Found in RedmineHooks::UpdateMirrors and 1 other location - About 2 hrs to fix
      app/services/redmine_hooks/call_webservices.rb on lines 17..23

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

      Refactorings

      Further Reading

      Complex method in #execute

            def execute(cmd_str, repo_id, options = {}, &block)
              if !options[:write_stdin] && out = RedmineGitHosting::Cache.get_cache(repo_id, cmd_str)
                # Simple case -- have cached result that depends only on cmd_str
                block.call(out)
                retio = out
      Found in RedmineGitHosting::ShellRedirector - About 2 hrs to fix

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Complex method in #check_ref_spec

            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
      Found in RedmineHooks::UpdateMirrors - About 2 hrs to fix

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Complex method in #handle_settings_update

              def handle_settings_update
                # Create FormObject
                settings_form = PluginSettingsForm.new(@plugin)
      
                # Strip *rescue* hash from params as we don't want to save them

      Long or complex methods can make code harder to understand. In most circumstances, methods are best as a small chunk of code (the "how") with a clear, understandable name (the "what"). Long methods can also lead to duplication, as it's harder to reuse logic that is tightly coupled to surrounding code.

      Refactorings

      Read More

      Similar code found in 1 other location

      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...
      lib/redmine/scm/adapters/xitolite_adapter.rb on lines 286..290

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

      Refactorings

      Further Reading

      Similar code found in 1 other location

      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...
      lib/redmine/scm/adapters/xitolite_adapter.rb on lines 279..283

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

      Refactorings

      Further Reading

      Similar code found in 1 other location

      module RedmineGitHosting
        module Config
          module GitoliteHooks
            extend self
      
      
      lib/redmine_git_hosting/config/gitolite_hooks.rb on lines 45..50

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

      Refactorings

      Further Reading

      Similar code found in 1 other location

      module RedmineGitHosting
        module Config
          module GitoliteHooks
            extend self
      
      
      lib/redmine_git_hosting/config/gitolite_hooks.rb on lines 54..59

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

      Refactorings

      Further Reading