Noosfero/noosfero

View on GitHub
app/helpers/profile_image_helper.rb

Summary

Maintainability
C
1 day
Test Coverage

Method profile_image_link has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def profile_image_link(profile, size = :portrait, tag = "li", extra_info = nil)
    if content = @plugins.dispatch_first(:profile_image_link, profile, size, tag, extra_info)
      return instance_exec(&content)
    end

Severity: Minor
Found in app/helpers/profile_image_helper.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

Method profile_image_link has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def profile_image_link(profile, size = :portrait, tag = "li", extra_info = nil)
    if content = @plugins.dispatch_first(:profile_image_link, profile, size, tag, extra_info)
      return instance_exec(&content)
    end

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

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

      def profile_icon(profile, size = :portrait, return_mimetype = false)
        filename, mimetype = "", "image/png"
        if profile.image.present?
          filename = profile.image.public_filename(size)
          mimetype = profile.image.content_type
    Severity: Minor
    Found in app/helpers/profile_image_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 profile_sex_icon has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def profile_sex_icon(profile)
        return "" unless profile.is_a?(Person)
        return "" unless !environment.enabled?("disable_gender_icon")
    
        sex = (profile.sex ? profile.sex.to_s() : "undef")
    Severity: Minor
    Found in app/helpers/profile_image_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_for_balloon has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def links_for_balloon(profile)
        if environment.enabled?(:show_balloon_with_profile_links_when_clicked)
          if profile.kind_of?(Person)
            return [
              { _("Wall") => { href: url_for(profile.public_profile_url) } },
    Severity: Minor
    Found in app/helpers/profile_image_helper.rb - About 1 hr to fix

      Method links_for_balloon has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def links_for_balloon(profile)
          if environment.enabled?(:show_balloon_with_profile_links_when_clicked)
            if profile.kind_of?(Person)
              return [
                { _("Wall") => { href: url_for(profile.public_profile_url) } },
      Severity: Minor
      Found in app/helpers/profile_image_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 profile_pic has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def profile_pic(profile)
          if profile.image
            filename = profile.image.public_filename
          else
            pic = if profile.organization?
      Severity: Minor
      Found in app/helpers/profile_image_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 profile_image has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def profile_image(profile, size = :portrait, opt = {})
          return "" if profile.nil?
      
          opt[:alt]   ||= profile.name()
          opt[:title] ||= ""
      Severity: Minor
      Found in app/helpers/profile_image_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