Class PullRequest
has 21 methods (exceeds 20 allowed). Consider refactoring.
class PullRequest < ActiveRecord::Base
STATUSES = [
STATUS_OPEN = 'open',
STATUS_READY = 'ready',
STATUS_ALREADY = 'already',
Method check
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def check(do_transaction = true)
if do_transaction && !valid?
issue.set_close nil
issue.save(validate: false)
return false
Method clone
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
def clone
return if from_project.nil?
git = Grit::Git.new(path)
if new_record? || !git.exist?
Method check_ref
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
def self.check_ref(record, attr, value)
project = attr == :from_ref ? record.from_project : record.to_project
return if project.blank?
if record.to_project.repo.branches.count > 0
record.errors.add attr, I18n.t('projects.pull_requests.wrong_ref') unless project.repo.branches_and_tags.map(&:name).include?(value)
Method clean
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def clean
to_project.repo.branches.each {|branch| system 'git', 'checkout', branch.name}
system 'git', '-C', path, 'checkout', to_ref
to_project.repo.branches.each do |branch|
Method merge!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
def merge!(who)
return false unless can_merging?
old_commit = to_project.repo.commits(to_ref).first
commit = repo.commits(to_ref).first
system "git -C #{path} config user.name \"#{who.uname}\" && git -C #{path} config user.email \"#{who.email}\""
There are no issues that match your filters.