bborn/communityengine

View on GitHub
app/helpers/base_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

Method page_title has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def page_title
    divider = " | ".html_safe

    app_base = configatron.community_name
    tagline = " #{divider} #{configatron.community_tagline}"
Severity: Minor
Found in app/helpers/base_helper.rb - About 5 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 container_title has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

  def container_title
    app_base = configatron.community_name
    title = app_base

    case controller.controller_name
Severity: Minor
Found in app/helpers/base_helper.rb - About 4 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

File base_helper.rb has 310 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'digest/md5'

# Methods added to this helper will be available to all templates in the application.
module BaseHelper
  include ActsAsTaggableOn::TagsHelper
Severity: Minor
Found in app/helpers/base_helper.rb - About 3 hrs to fix

    Method page_title has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def page_title
        divider = " | ".html_safe
    
        app_base = configatron.community_name
        tagline = " #{divider} #{configatron.community_tagline}"
    Severity: Major
    Found in app/helpers/base_helper.rb - About 2 hrs to fix

      Method container_title has 55 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def container_title
          app_base = configatron.community_name
          title = app_base
      
          case controller.controller_name
      Severity: Major
      Found in app/helpers/base_helper.rb - About 2 hrs to fix

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

          def search_user_posts_path(rss = false)
            options = params[:q].blank? ? {} : {:q => params[:q]}
            options[:format] = :rss if rss
            [[:user, :user_id], [:forum, :forum_id]].each do |(route_key, param_key)|
              return send("#{route_key}_sb_posts_path", options.update(param_key => params[param_key])) if params[param_key]
        Severity: Minor
        Found in app/helpers/base_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 search_posts_title has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          def search_posts_title
            (params[:q].blank? ? :recent_posts.l : :searching_for.l+" '#{h params[:q]}'").tap do |title|
              title << " by #{h User.find(params[:user_id]).display_name}" if params[:user_id]
              title << " in #{h Forum.find(params[:forum_id]).name}"       if params[:forum_id]
            end
        Severity: Minor
        Found in app/helpers/base_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 commentable_url has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          def commentable_url(comment)
            if comment.recipient && comment.commentable
              if comment.commentable_type != "User"
                polymorphic_url([comment.recipient, comment.commentable])+"#comment-#{comment.id}"
              elsif comment
        Severity: Minor
        Found in app/helpers/base_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

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                    if params[:type]
                      title = I18n.translate('all_' + params[:type].downcase.pluralize + '_tagged', :tag_name => @tags.map(&:name).join(', '))
                    else
                      title = :posts_photos_and_bookmarks.l(:name => @tags.map(&:name).join(', '))
        Severity: Minor
        Found in app/helpers/base_helper.rb and 1 other location - About 35 mins to fix
        app/helpers/base_helper.rb on lines 151..154

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

                    if params[:type]
                      title = I18n.translate('all_' + params[:type].downcase.pluralize + '_tagged', :tag_name => @tags.map(&:name).join(', '))
                    else
                      title = :posts_photos_and_bookmarks.l(:name => @tags.map(&:name).join(', '))
        Severity: Minor
        Found in app/helpers/base_helper.rb and 1 other location - About 35 mins to fix
        app/helpers/base_helper.rb on lines 213..216

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 35.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        There are no issues that match your filters.

        Category
        Status