helpyio/helpy

View on GitHub
app/controllers/admin/topics_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

File topics_controller.rb has 418 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class Admin::TopicsController < Admin::BaseController

  include SearchConcern

  before_action :verify_agent
Severity: Minor
Found in app/controllers/admin/topics_controller.rb - About 6 hrs to fix

    Class TopicsController has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Admin::TopicsController < Admin::BaseController
    
      include SearchConcern
    
      before_action :verify_agent
    Severity: Minor
    Found in app/controllers/admin/topics_controller.rb - About 2 hrs to fix

      Method create_customer_conversation has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def create_customer_conversation
          @forum = Forum.find(1)
          @user = User.where("lower(email) = ?", params[:topic][:user][:email].downcase).first
      
          @topic = @forum.topics.new(
      Severity: Minor
      Found in app/controllers/admin/topics_controller.rb - About 1 hr to fix

        Method create_internal_ticket has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def create_internal_ticket
            @forum = Forum.find(1)
            @user = User.where("lower(email) = ?", params[:topic][:user][:email].downcase).first
        
            @topic = @forum.topics.new(
        Severity: Minor
        Found in app/controllers/admin/topics_controller.rb - About 1 hr to fix

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

            def ticketing_ui
              @updated_topics = @topics
              if params[:q].present?
                search_date_from_params
                search_topics
          Severity: Minor
          Found in app/controllers/admin/topics_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 split_topic has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def split_topic
              parent_topic = Topic.find(params[:topic_id])
              parent_post = Post.find(params[:post_id])
          
              @topic = Topic.new(
          Severity: Minor
          Found in app/controllers/admin/topics_controller.rb - About 1 hr to fix

            Method ticketing_ui has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def ticketing_ui
                @updated_topics = @topics
                if params[:q].present?
                  search_date_from_params
                  search_topics
            Severity: Minor
            Found in app/controllers/admin/topics_controller.rb - About 1 hr to fix

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

                def update_topic
              
                  bulk_post_attributes = []
                  if params[:change_status].present?
                    user_id = current_user.id || 2
              Severity: Minor
              Found in app/controllers/admin/topics_controller.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 create_internal_ticket has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def create_internal_ticket
                  @forum = Forum.find(1)
                  @user = User.where("lower(email) = ?", params[:topic][:user][:email].downcase).first
              
                  @topic = @forum.topics.new(
              Severity: Minor
              Found in app/controllers/admin/topics_controller.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 create_customer_conversation has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                def create_customer_conversation
                  @forum = Forum.find(1)
                  @user = User.where("lower(email) = ?", params[:topic][:user][:email].downcase).first
              
                  @topic = @forum.topics.new(
              Severity: Minor
              Found in app/controllers/admin/topics_controller.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 get_topics_cohort has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def get_topics_cohort
                  #  If affect is all, that means all matching tickets should be bulk updated
                  if params[:affect].present? && params[:affect] == "all"
                    if params[:status].present?
                      @topics = Topic.where(current_status: params[:status]).all
              Severity: Minor
              Found in app/controllers/admin/topics_controller.rb - About 25 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

              TODO found
              Open

                      # TODO probably can refactor this

              TODO found
              Open

                      # TODO probably can refactor this

              There are no issues that match your filters.

              Category
              Status