rosa-abf/rosa-build

View on GitHub

Showing 210 of 210 total issues

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

def resolve_default_branch
return default_branch unless owner.is_a?(Group) && owner.default_branch.present?
return default_branch unless repo.branches.map(&:name).include?(owner.default_branch)
return owner.default_branch unless default_branch.present?
default_branch == 'master' ? owner.default_branch : default_branch
Severity: Minor
Found in app/models/concerns/project/default_branch.rb - About 55 mins to fix

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

def update
authorize @platform
@admin_id = params[:admin_id]
@admin_uname = params[:admin_uname]
 
 
Severity: Minor
Found in app/controllers/platforms/platforms_controller.rb - About 55 mins to fix

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

def update
authorize @project
params[:project].delete(:maintainer_id) if params[:project][:maintainer_id].blank?
respond_to do |format|
format.html do
Severity: Minor
Found in app/controllers/projects/projects_controller.rb - About 55 mins to fix

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

def self.find_by_platform(platform, path, term)
# Strip out the non-ascii character
path = sanitize_path(path)
 
if term =~ /^bl:\d+$/
Severity: Minor
Found in app/models/platform_content.rb - About 55 mins to fix

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

def perform
MassBuild.where(status: MassBuild::BUILD_PENDING).find_each do |mb|
next if mb.extra_mass_builds.blank?
emb = MassBuild.where(status: MassBuild::SUCCESS, id: mb.extra_mass_builds).to_a
next if emb.size != mb.extra_mass_builds.size
Severity: Minor
Found in app/jobs/run_extra_mass_builds_job.rb - About 55 mins to fix

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

def add_project
authorize @repository
if projects_list = params.try(:[], :repository).try(:[], :projects_list)
@repository.add_projects projects_list, current_user
redirect_to platform_repository_path(@platform, @repository), notice: t('flash.repository.projects_will_be_added')
Severity: Minor
Found in app/controllers/platforms/repositories_controller.rb - About 55 mins to fix

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

def unmodline(line)
set_line_number
"<tr class='changes unmodline'>
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
Severity: Major
Found in app/helpers/diff_helper.rb and 2 other locations - About 50 mins to fix
app/helpers/diff_helper.rb on lines 145..155
app/helpers/diff_helper.rb on lines 179..189

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

def nonewlineline(line)
set_line_number
"<tr class='changes'>
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
Severity: Major
Found in app/helpers/diff_helper.rb and 2 other locations - About 50 mins to fix
app/helpers/diff_helper.rb on lines 145..155
app/helpers/diff_helper.rb on lines 158..168

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

def modline(line)
set_line_number
"<tr class='changes line'>
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}L#{line.old_number}", line.old_number}
#{td_line_link "#{@diff_prefix}-F#{@diff_counter}R#{line.new_number}", line.new_number}
Severity: Major
Found in app/helpers/diff_helper.rb and 2 other locations - About 50 mins to fix
app/helpers/diff_helper.rb on lines 158..168
app/helpers/diff_helper.rb on lines 179..189

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

def title_object(object)
return object.advisory_id if object.class == Advisory
name = object.class == Group ? object.uname : object.name
object_name = t "activerecord.models.#{object.class.name.downcase}"
case object.class.name
Severity: Minor
Found in app/helpers/application_helper.rb - About 45 mins to fix

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

def fork_git_repo
dummy = Grit::Repo.new(path) rescue nil
# Do nothing if GIT repo already exist
unless dummy
if alias_from_id
Severity: Minor
Found in app/models/concerns/git.rb - About 45 mins to fix

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

def new
super do |resource|
if params[:invite_key].to_s.strip.empty?
resource.invite_key = ''
else
Severity: Minor
Found in app/controllers/users/registrations_controller.rb - About 45 mins to fix

Function setCookie has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

function setCookie (name, value, expires, path, domain, secure) {
Severity: Minor
Found in app/assets/javascripts/new_application.js - About 45 mins 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 branch_selector_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def branch_selector_options(project)
    p, tag_enabled = params.dup, !(controller_name == 'trees' && action_name == 'branches')
    p.delete(:path) if p[:path].present? # to root path
    p.merge!(project_id: project.id, treeish: project.resolve_default_branch).delete(:id) unless p[:treeish].present?
    current = url_for(p).split('?', 2).first
    Severity: Minor
    Found in app/helpers/git_helper.rb - About 45 mins to fix

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

    def init_variables
    case params[:range]
    when RANGE_TWENTY_FOUR_HOURS
    @range_end = Time.now.utc
    @range_start = @range_end - 1.day
    Severity: Minor
    Found in app/controllers/statistics_controller.rb - About 45 mins to fix

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

    def add_projects(list, user)
    list.lines.each do |line|
    begin
    line.chomp!; line.strip!
    owner, name = line.split('/')
    Severity: Minor
    Found in app/models/repository.rb - About 45 mins to fix

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

    def add_project
    if project = Project.where(id: params[:project_id]).first
    if policy(project).read?
    begin
    @repository.projects << project
    Severity: Minor
    Found in app/controllers/api/v1/repositories_controller.rb - About 45 mins to fix

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

    def update
    @issue.labelings.destroy_all if params[:update_labels] && policy(@project).write?
    if params[:issue] && status = params[:issue].delete(:status)
    @issue.set_close(current_user) if status == 'closed'
    @issue.set_open if status == 'open'
    Severity: Minor
    Found in app/controllers/api/v1/issues_controller.rb - About 45 mins to fix

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

    def bytes_to_size(bytes)
    sizes = [0, 1024, 1024*1024, 1024*1024*1024]
    names = ['B', 'KiB', 'MiB', 'GiB']
    sizes.each_with_index do |l, i|
    low, high = sizes[i], sizes[i+1]
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 45 mins to fix
    Severity
    Category
    Status
    Source
    Language