Skip to content
41 changes: 30 additions & 11 deletions lib/sigbit_admin_rails/helpers/sidebar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,45 @@ def sidebar(*args, &block)
options = args.extract_options!
if block_given?
content_tag :div, id: 'sidebar-wrapper' do
html = link_to '', options[:brand_url], class: 'sidebar-brand hidden-sm-down'
html << content_tag(:ul, class: 'sidebar-nav') do
concat(link_to '', options[:brand_url], class: 'sidebar-brand hidden-sm-down')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add parentheses to nested method call link_to '', options[:brand_url], class: 'sidebar-brand hidden-sm-down'.
Line is too long. [88/80]

concat(content_tag(:ul, class: 'sidebar-nav') do
yield
end
html.html_safe
end)
end
end
end

def sidebar_item(title, url, &block)
def sidebar_item(title, url = nil, &block)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assignment Branch Condition size for sidebar_item is too high. [16.16/15]
Method has too many lines. [13/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [11/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [14/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method has too many lines. [17/10]
Unused method argument - block. If it's necessary, use _ or _block as an argument name to indicate that it won't be used.

if block_given?
url = "##{generate_random_id}" unless url.present?
content_tag :li do
html = link_to("#{title} <i class='fa fa-chevron-right'></i>".html_safe, url, data: { toggle: 'collapse' })
html << content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do
concat(link_to("#{ title } #{ arrow_icon }".html_safe, url, data: { toggle: 'collapse' }))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside string interpolation detected.
Line is too long. [100/80]

concat(content_tag(:ul, class: 'submenu collapse', id: url.delete('#')) do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [84/80]

yield
end
html.html_safe
end)
end
else
"<li>#{link_to title, url}</li>".html_safe
smart_link_to title, url, class: 'nav-link'
end
end end
end

def smart_link_to(title, url, options = {})
content_tag :li, class: 'nav-item' do
if defined?(ActiveLinkTo)
active_link_to(title, url, options)
else
link_to title, url, options
end
end
end

def arrow_icon
content_tag :i, class: 'fa fa-chevron-right' do
end
end

def generate_random_id
(0...20).map { ('a'..'z').to_a.sample }.join
end
end
end