rosa-abf/rosa-build

View on GitHub
app/models/pull_request.rb

Summary

Maintainability
B
6 hrs
Test Coverage

Showing 6 of 6 total issues

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

class PullRequest < ActiveRecord::Base
STATUSES = [
STATUS_OPEN = 'open',
STATUS_READY = 'ready',
STATUS_ALREADY = 'already',
Severity: Minor
Found in app/models/pull_request.rb - About 2 hrs to fix

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

    def check(do_transaction = true)
    if do_transaction && !valid?
    issue.set_close nil
    issue.save(validate: false) # FIXME remove this hack
    return false
    Severity: Minor
    Found in app/models/pull_request.rb - About 1 hr to fix

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

    def clone
    return if from_project.nil?
    git = Grit::Git.new(path)
    if new_record? || !git.exist?
    #~ FileUtils.mkdir_p(path)
    Severity: Minor
    Found in app/models/pull_request.rb - About 1 hr to fix

    Method check_ref has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    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)
    Severity: Minor
    Found in app/models/pull_request.rb - About 45 mins to fix

    Method clean has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    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|
    Severity: Minor
    Found in app/models/pull_request.rb - About 25 mins to fix

    Method merge! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    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}\""
    Severity: Minor
    Found in app/models/pull_request.rb - About 25 mins to fix
    Category
    Status