rosa-abf/rosa-build

View on GitHub
app/helpers/git_helper.rb

Summary

Maintainability
C
1 day
Test Coverage

Showing 6 of 6 total issues

Method blame_highlight has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def blame_highlight(blob, path, text)
return if blob.nil? || text.blank?
rugged = blob.repo.rugged
lazy = Linguist::LazyBlob.new(rugged, blob.id, path, blob.mode)
language = lazy.language
Severity: Minor
Found in app/helpers/git_helper.rb - About 4 hrs to fix

Method blob_highlight has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def blob_highlight(blob, path)
return if blob.nil? || blob.size == 0
rugged = blob.repo.rugged
lazy = Linguist::LazyBlob.new(rugged, blob.id, path, blob.mode)
language = lazy.language
Severity: Minor
Found in app/helpers/git_helper.rb - About 3 hrs to fix

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

def render_path
# TODO: Looks ugly, rewrite with clear mind.
if @path.present?
if @treeish == @project.resolve_default_branch
res = "#{link_to @project.name, tree_path(@project)} / "
Severity: Minor
Found in app/helpers/git_helper.rb - About 1 hr 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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if language
lexer = Rouge::Lexer.find(language.name)
if !lexer
language.aliases.each do |al|
lexer = Rouge::Lexer.find(al)
Severity: Minor
Found in app/helpers/git_helper.rb and 1 other location - About 30 mins to fix
app/helpers/git_helper.rb on lines 141..149

Identical blocks of code found in 2 locations. Consider refactoring.
Open

if language
lexer = Rouge::Lexer.find(language.name)
if !lexer
language.aliases.each do |al|
lexer = Rouge::Lexer.find(al)
Severity: Minor
Found in app/helpers/git_helper.rb and 1 other location - About 30 mins to fix
app/helpers/git_helper.rb on lines 115..123
Category
Status