fatfreecrm/fat_free_crm

View on GitHub

Showing 76 of 93 total issues

File application_helper.rb has 374 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 get_list_of_records has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

      def get_list_of_records(options = {})
        options[:query]  ||= params[:query]                        if params[:query]
        self.current_page  = options[:page]                        if options[:page]
        query, tags        = parse_query_and_tags(options[:query])
        self.current_query = query
    Severity: Minor
    Found in app/controllers/entities_controller.rb - About 3 hrs 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

    Class ApplicationController has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class ApplicationController < ActionController::Base
      protect_from_forgery with: :exception
    
      before_action :configure_devise_parameters, if: :devise_controller?
      before_action :authenticate_user!
    Severity: Minor
    Found in app/controllers/application_controller.rb - About 2 hrs to fix

      Class EntitiesController has 25 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class EntitiesController < ApplicationController
        before_action :set_current_tab, only: %i[index show]
        before_action :set_view, only: %i[index show redraw]
      
        before_action :set_options, only: :index
      Severity: Minor
      Found in app/controllers/entities_controller.rb - About 2 hrs to fix

        Method create_for has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

          def self.create_for(model, account, opportunity, params)
            attributes = {
              lead_id:     model.id,
              user_id:     params[:account][:user_id] || account.user_id,
              assigned_to: params[:account][:assigned_to],
        Severity: Minor
        Found in app/models/entities/contact.rb - About 2 hrs 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 task_summary has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def task_summary(task)
            summary = [task.category.blank? ? t(:other) : t(task.category)]
            if @view != "completed"
              if @view == "pending" && task.user != current_user
                summary << t(:task_from, task.user.full_name)
        Severity: Minor
        Found in app/helpers/tasks_helper.rb - About 2 hrs 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 create has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @comment_body = params[:comment_body]
            respond_with(@opportunity) do |_format|
              if @opportunity.save_with_account_and_permissions(params.permit!)
                @opportunity.add_comment_by_user(@comment_body, current_user)
        Severity: Minor
        Found in app/controllers/entities/opportunities_controller.rb - About 2 hrs 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 timeline has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

          def timeline
            state = params[:state].to_s
            if %w[Collapsed Expanded].include?(state)
              if (model_type = params[:type].to_s).present?
                if %w[comment email].include?(model_type)
        Severity: Minor
        Found in app/controllers/home_controller.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 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 respond_to_destroy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def respond_to_destroy(method)
            if method == :ajax
              if called_from_index_page? # Called from Leads index.
                get_data_for_sidebar
                @leads = get_leads
        Severity: Minor
        Found in app/controllers/entities/leads_controller.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 plain_text_body has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

              def plain_text_body(email)
                # Extract all parts including nested
                parts = if email.multipart?
                          email.parts.map { |p| p.multipart? ? p.parts : p }.flatten
                        else
        Severity: Minor
        Found in lib/fat_free_crm/mail_processor/base.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 lead_summary has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def lead_summary(lead)
            summary = []
            summary << (lead.status ? t(lead.status) : t(:other))
        
            if lead.company? && lead.title?
        Severity: Minor
        Found in app/helpers/leads_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 create has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def create
            @comment_body = params[:comment_body]
            respond_with(@contact) do |_format|
              if @contact.save_with_account_and_permissions(params.permit!)
                @contact.add_comment_by_user(@comment_body, current_user)
        Severity: Minor
        Found in app/controllers/entities/contacts_controller.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 respond_to_destroy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def respond_to_destroy(method)
            if method == :ajax
              if called_from_index_page?
                @contacts = get_contacts
                if @contacts.blank?
        Severity: Minor
        Found in app/controllers/entities/contacts_controller.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 respond_to_destroy has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def respond_to_destroy(method)
            if method == :ajax
              if called_from_index_page?
                get_data_for_sidebar
                @opportunities = get_opportunities
        Severity: Minor
        Found in app/controllers/entities/opportunities_controller.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 opportunity_revenue_message has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

          def opportunity_revenue_message(opportunity, detailed = false)
            msg = []
            won_or_lost = %w[won lost].include?(opportunity.stage)
        
            msg << content_tag(:b, number_to_currency(opportunity.weighted_amount, precision: 0)) if opportunity.weighted_amount != 0
        Severity: Minor
        Found in app/helpers/opportunities_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 attach has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def attach(email, asset, strip_first_line = false)
                # If 'sent_to' email cannot be found, default to Dropbox email address
                to = email.to.blank? ? @settings[:address] : email.to.join(", ")
                cc = email.cc.blank? ? nil : email.cc.join(", ")
        
        
        Severity: Minor
        Found in lib/fat_free_crm/mail_processor/dropbox.rb - About 1 hr to fix

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

            def update
              respond_with(@opportunity) do |_format|
                if @opportunity.update_with_account_and_permissions(params.permit!)
                  if called_from_index_page?
                    get_data_for_sidebar
          Severity: Minor
          Found in app/controllers/entities/opportunities_controller.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 setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def setup
                  log "connecting to #{@settings[:server]}..."
                  connect!(setup: true) || (return nil)
                  log "logged in to #{@settings[:server]}, checking folders..."
                  folders = [@settings[:scan_folder]]
          Severity: Minor
          Found in lib/fat_free_crm/mail_processor/base.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

          Severity
          Category
          Status
          Source
          Language