fatfreecrm/fat_free_crm

View on GitHub
app/helpers/application_helper.rb

Summary

Maintainability
C
1 day
Test Coverage

File application_helper.rb has 384 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module ApplicationHelper
  def tabs(tabs = nil)
    tabs ||= controller_path.match?(/admin/) ? FatFreeCRM::Tabs.admin : FatFreeCRM::Tabs.main
    if tabs
      @current_tab ||= tabs.first[:text] # Select first tab by default.
Severity: Minor
Found in app/helpers/application_helper.rb - About 5 hrs to fix

    Method view_buttons has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

      def view_buttons
        views = FatFreeCRM::ViewFactory.views_for(controller: controller.controller_name,
                                                  action: show_or_index_action)
        return nil unless views.size > 1
    
    
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method links_to_export has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

      def links_to_export(action = :index)
        token = current_user.authentication_token
        url_params = { action: action }
        url_params[:id] = params[:id] unless params[:id].blank?
        url_params[:query] = params[:query] unless params[:query].blank?
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 1 hr to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

      def col(title, value = nil, last = false, email = false, &_block)
        last_class = (last ? 'last' : nil)
        out = content_tag(:th, title, class: last_class)
        if block_given?
          out << content_tag(:td, class: last_class) do
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method col has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def col(title, value = nil, last = false, email = false, &_block)
    Severity: Minor
    Found in app/helpers/application_helper.rb - About 35 mins to fix

      Method web_presence_icons has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def web_presence_icons(person)
          %i[blog linkedin facebook twitter skype].map do |site|
            url = person.send(site)
            next if url.blank?
      
      
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method link_to_email has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def link_to_email(email, length = nil, &_block)
          name = (length ? truncate(email, length: length) : email)
          bcc = Setting&.email_dropbox
          mailto = if bcc && bcc[:address].present?
                     "#{email}?bcc=#{bcc[:address]}"
      Severity: Minor
      Found in app/helpers/application_helper.rb - About 35 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      There are no issues that match your filters.

      Category
      Status