crewmate/crewmate

View on GitHub
app/helpers/activities_helper.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method activity_title has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def activity_title(activity, plain = false, mobile = false)
    values = mobile ? { :user => (plain ? h(activity.user.short_name) : "<span class='user'>#{h activity.user.short_name}</span>") } :
                      { :user => link_to_unless(plain, h(activity.user.name), activity.user) }

    case activity
Severity: Major
Found in app/helpers/activities_helper.rb - About 2 hrs to fix

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

      def activity_title(activity, plain = false, mobile = false)
        values = mobile ? { :user => (plain ? h(activity.user.short_name) : "<span class='user'>#{h activity.user.short_name}</span>") } :
                          { :user => link_to_unless(plain, h(activity.user.name), activity.user) }
    
        case activity
    Severity: Minor
    Found in app/helpers/activities_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 activities_paginate_link has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def activities_paginate_link(*args)
        options = args.extract_options!
    
        if location_name == 'index_projects' or location_name == 'show_activities'
          url = show_more_path(options[:last_activity].id)
    Severity: Minor
    Found in app/helpers/activities_helper.rb - About 55 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 activity_target_url has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def activity_target_url(activity)
        if activity.target_type == 'Task'
          task = activity.target
          project_task_url(activity.project, task)
        elsif activity.comment_target_type == 'Task'
    Severity: Minor
    Found in app/helpers/activities_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 show_threaded_activity has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def show_threaded_activity(activity)
        if activity.thread_id.starts_with? "Task_" or activity.thread_id.starts_with? "Conversation_"
          mode = %w(projects activities).include?(controller.controller_name) ? "short" : "full"
          Rails.cache.fetch("#{mode}-thread/#{activity.thread_id}/#{current_user.locale}") do
            render('activities/thread', :activity => activity).to_s
    Severity: Minor
    Found in app/helpers/activities_helper.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

    There are no issues that match your filters.

    Category
    Status