sharetribe/sharetribe

View on GitHub
app/helpers/transaction_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

File transaction_helper.rb has 460 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module TransactionHelper

  def icon_for(status)
    case status
    when "confirmed"
Severity: Minor
Found in app/helpers/transaction_helper.rb - About 7 hrs to fix

    Method conversation_icon_and_status has 154 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def conversation_icon_and_status(status, is_author, other_party_name, waiting_feedback, status_meta)
        icon_waiting_you = icon_tag("alert", ["icon-fix-rel", "waiting-you"])
        icon_waiting_other = icon_tag("clock", ["icon-fix-rel", "waiting-other"])
    
        # Split "confirmed" status into "waiting_feedback" and "completed"
    Severity: Major
    Found in app/helpers/transaction_helper.rb - About 6 hrs to fix

      Method get_conversation_statuses has 132 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def get_conversation_statuses(conversation, is_author)
          statuses = if conversation.listing && !conversation.status.eql?("free")
            status_hash = {
              paid: -> { {
                both: [
      Severity: Major
      Found in app/helpers/transaction_helper.rb - About 5 hrs to fix

        Method get_conversation_statuses has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          def get_conversation_statuses(conversation, is_author)
            statuses = if conversation.listing && !conversation.status.eql?("free")
              status_hash = {
                paid: -> { {
                  both: [
        Severity: Minor
        Found in app/helpers/transaction_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 conversation_icon_and_status has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

          def conversation_icon_and_status(status, is_author, other_party_name, waiting_feedback, status_meta)
            icon_waiting_you = icon_tag("alert", ["icon-fix-rel", "waiting-you"])
            icon_waiting_other = icon_tag("clock", ["icon-fix-rel", "waiting-other"])
        
            # Split "confirmed" status into "waiting_feedback" and "completed"
        Severity: Minor
        Found in app/helpers/transaction_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 conversation_icon_and_status has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def conversation_icon_and_status(status, is_author, other_party_name, waiting_feedback, status_meta)
        Severity: Minor
        Found in app/helpers/transaction_helper.rb - About 35 mins to fix

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

            def waiting_for_current_user_to_confirm(conversation)
              status_links([
                {
                  link_href: confirm_person_message_path(@current_user, :id => conversation.id),
                  link_classes: "confirm",
          Severity: Minor
          Found in app/helpers/transaction_helper.rb and 1 other location - About 40 mins to fix
          app/helpers/transaction_helper.rb on lines 442..456

          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 38.

          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

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

            def waiting_for_current_user_to_accept_preauthorized(transaction)
              status_links([
                {
                  link_href: accept_preauthorized_person_message_path(@current_user, :id => transaction.id),
                  link_classes: "accept_preauthorized",
          Severity: Minor
          Found in app/helpers/transaction_helper.rb and 1 other location - About 40 mins to fix
          app/helpers/transaction_helper.rb on lines 425..439

          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 38.

          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

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

                    when Some("verify")
                      {
                        author: [
                          status_info(t("conversations.status.pending_external.paypal.verify", paypal_url: link_to("https://www.paypal.com", "https://www.paypal.com")).html_safe, icon_classes: icon_for("pending_ext"))
                        ],
          Severity: Minor
          Found in app/helpers/transaction_helper.rb and 1 other location - About 25 mins to fix
          app/helpers/transaction_helper.rb on lines 271..280

          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 31.

          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

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

                    when Some("intl")
                      {
                        author: [
                          status_info(t("conversations.status.pending_external.paypal.intl", paypal_url: link_to("https://www.paypal.com", "https://www.paypal.com")).html_safe, icon_classes: icon_for("pending_ext"))
                        ],
          Severity: Minor
          Found in app/helpers/transaction_helper.rb and 1 other location - About 25 mins to fix
          app/helpers/transaction_helper.rb on lines 281..290

          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 31.

          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