salesking/sepa_king

View on GitHub

Showing 16 of 16 total issues

Method build_transaction has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

    def build_transaction(builder, transaction)
      builder.DrctDbtTxInf do
        builder.PmtId do
          if transaction.instruction.present?
            builder.InstrId(transaction.instruction)
Severity: Minor
Found in lib/sepa_king/message/direct_debit.rb - About 1 day 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 build_transaction has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
Open

    def build_transaction(builder, transaction)
      builder.CdtTrfTxInf do
        builder.PmtId do
          if transaction.instruction.present?
            builder.InstrId(transaction.instruction)
Severity: Minor
Found in lib/sepa_king/message/credit_transfer.rb - About 6 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

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

  class CreditorAddress
    include ActiveModel::Validations
    extend Converter

    attr_accessor :street_name,
Severity: Major
Found in lib/sepa_king/account/creditor_address.rb and 1 other location - About 2 hrs to fix
lib/sepa_king/account/debtor_address.rb on lines 3..33

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

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

  class DebtorAddress
    include ActiveModel::Validations
    extend Converter

    attr_accessor :street_name,
Severity: Major
Found in lib/sepa_king/account/debtor_address.rb and 1 other location - About 2 hrs to fix
lib/sepa_king/account/creditor_address.rb on lines 3..33

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

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

Method build_transaction has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def build_transaction(builder, transaction)
      builder.DrctDbtTxInf do
        builder.PmtId do
          if transaction.instruction.present?
            builder.InstrId(transaction.instruction)
Severity: Major
Found in lib/sepa_king/message/direct_debit.rb - About 2 hrs to fix

    Method build_payment_informations has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_payment_informations(builder, schema_name)
          # Build a PmtInf block for every group of transactions
          grouped_transactions.each do |group, transactions|
            # All transactions with the same requested_date are placed into the same PmtInf block
            builder.PmtInf do
    Severity: Minor
    Found in lib/sepa_king/message/credit_transfer.rb - About 2 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 build_transaction has 56 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def build_transaction(builder, transaction)
          builder.CdtTrfTxInf do
            builder.PmtId do
              if transaction.instruction.present?
                builder.InstrId(transaction.instruction)
    Severity: Major
    Found in lib/sepa_king/message/credit_transfer.rb - About 2 hrs to fix

      Method build_payment_informations has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def build_payment_informations(builder, schema_name)
            # Build a PmtInf block for every group of transactions
            grouped_transactions.each do |group, transactions|
              builder.PmtInf do
                builder.PmtInfId(payment_information_identification(group))
      Severity: Major
      Found in lib/sepa_king/message/direct_debit.rb - About 2 hrs to fix

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

                builder.Cdtr do
                  builder.Nm(transaction.name)
                  if transaction.creditor_address
                    builder.PstlAdr do
                      # Only set the fields that are actually provided.
        Severity: Major
        Found in lib/sepa_king/message/credit_transfer.rb and 1 other location - About 2 hrs to fix
        lib/sepa_king/message/direct_debit.rb on lines 153..189

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

        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

                builder.Dbtr do
                  builder.Nm(transaction.name)
                  if transaction.debtor_address
                    builder.PstlAdr do
                      # Only set the fields that are actually provided.
        Severity: Major
        Found in lib/sepa_king/message/direct_debit.rb and 1 other location - About 2 hrs to fix
        lib/sepa_king/message/credit_transfer.rb on lines 91..127

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

        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

        Method build_payment_informations has 47 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def build_payment_informations(builder, schema_name)
              # Build a PmtInf block for every group of transactions
              grouped_transactions.each do |group, transactions|
                # All transactions with the same requested_date are placed into the same PmtInf block
                builder.PmtInf do
        Severity: Minor
        Found in lib/sepa_king/message/credit_transfer.rb - About 1 hr to fix

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

              def build_amendment_informations(builder, transaction)
                builder.AmdmntInd(true)
                builder.AmdmntInfDtls do
                  if transaction.original_debtor_account
                    builder.OrgnlDbtrAcct do
          Severity: Minor
          Found in lib/sepa_king/message/direct_debit.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 build_amendment_informations has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def build_amendment_informations(builder, transaction)
                builder.AmdmntInd(true)
                builder.AmdmntInfDtls do
                  if transaction.original_debtor_account
                    builder.OrgnlDbtrAcct do
          Severity: Minor
          Found in lib/sepa_king/message/direct_debit.rb - About 1 hr to fix

            Method build_payment_informations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def build_payment_informations(builder, schema_name)
                  # Build a PmtInf block for every group of transactions
                  grouped_transactions.each do |group, transactions|
                    builder.PmtInf do
                      builder.PmtInfId(payment_information_identification(group))
            Severity: Minor
            Found in lib/sepa_king/message/direct_debit.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

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

                def creation_date_time=(value)
                  raise ArgumentError.new('creation_date_time must be a string!') unless value.is_a?(String)
            
                  regex = /[0-9]{4}[-][0-9]{2,2}[-][0-9]{2,2}(?:\s|T)[0-9]{2,2}[:][0-9]{2,2}[:][0-9]{2,2}/
                  raise ArgumentError.new("creation_date_time does not match #{regex}!") unless value.match?(regex)
            Severity: Minor
            Found in lib/sepa_king/message.rb and 1 other location - About 15 mins to fix
            lib/sepa_king/message.rb on lines 74..80

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

            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 message_identification=(value)
                  raise ArgumentError.new('message_identification must be a string!') unless value.is_a?(String)
            
                  regex = /\A([A-Za-z0-9]|[\+|\?|\/|\-|\:|\(|\)|\.|\,|\'|\ ]){1,35}\z/
                  raise ArgumentError.new("message_identification does not match #{regex}!") unless value.match?(regex)
            Severity: Minor
            Found in lib/sepa_king/message.rb and 1 other location - About 15 mins to fix
            lib/sepa_king/message.rb on lines 90..96

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

            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

            Severity
            Category
            Status
            Source
            Language