pagseguro/ruby

View on GitHub

Showing 60 of 60 total issues

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

if transaction.errors.any?
  puts transaction.errors.join("\n")
else
  puts "=> Transaction"
  puts "  code: #{transaction.code}"
examples/checkout/search/search_transaction_by_code.rb on lines 18..75

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

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 transaction.errors.any?
  puts transaction.errors.join("\n")
else
  puts "=> Transaction"
  puts "  code: #{transaction.code}"
Severity: Major
Found in examples/checkout/search/search_transaction_by_code.rb and 1 other location - About 1 day to fix
examples/checkout/search/search_transaction_by_notification_code.rb on lines 18..75

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

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 payment.errors.any?
  puts "=> ERRORS"
  puts payment.errors.join("\n")
else
  puts "=> Transaction"
Severity: Major
Found in examples/direct/create_transaction_using_online_debit.rb and 1 other location - About 6 hrs to fix
examples/direct/create_transaction_using_boleto.rb on lines 56..99

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

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 payment.errors.any?
  puts "=> ERRORS"
  puts payment.errors.join("\n")
else
  puts "=> Transaction"
Severity: Major
Found in examples/direct/create_transaction_using_boleto.rb and 1 other location - About 6 hrs to fix
examples/direct/create_transaction_using_online_debit.rb on lines 60..103

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

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 has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
Open

      def build
        Nokogiri::XML::Builder.new(encoding: PagSeguro.encoding) do |xml|
          xml.send(:paymentMethod) {
            xml.send(:type, 'CREDITCARD')

Severity: Minor
Found in lib/pagseguro/subscription_change_payment/request_serializer.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

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

if subscription.errors.empty?
  puts "Subscription:"
  puts "  code: #{subscription.code}"
  puts "  name: #{subscription.name}"
  puts "  date: #{subscription.date}"
Severity: Major
Found in examples/preapproval/search/search_by_subscription_code.rb and 1 other location - About 4 hrs to fix
examples/preapproval/search/search_by_notification_code.rb on lines 16..49

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

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 subscription.errors.empty?
  puts "Subscription:"
  puts "  code: #{subscription.code}"
  puts "  name: #{subscription.name}"
  puts "  date: #{subscription.date}"
Severity: Major
Found in examples/preapproval/search/search_by_notification_code.rb and 1 other location - About 4 hrs to fix
examples/preapproval/search/search_by_subscription_code.rb on lines 16..49

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

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

Class RequestSerializer has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

    class RequestSerializer
      # The transaction request that will be serialized.
      attr_reader :transaction_request

      def initialize(transaction_request)
Severity: Minor
Found in lib/pagseguro/transaction_request/request_serializer.rb - About 2 hrs to fix

    Method serialize_address has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def serialize_address(xml, address)
            return unless address
    
            xml.send(:address) {
              xml.send(:street, address.street) if address.street
    Severity: Minor
    Found in lib/pagseguro/subscription/request_serializer.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 serialize_billing_address has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def serialize_billing_address(xml, address)
            return unless address
    
            xml.send(:billingAddress) {
              xml.send(:street, address.street) if address.street
    Severity: Minor
    Found in lib/pagseguro/subscription/request_serializer.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 serialize_address has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def serialize_address(xml, address)
            return unless address
    
            xml.send(:address) {
              xml.send(:postalCode, address.postal_code) if address.postal_code
    Severity: Minor
    Found in lib/pagseguro/authorization_request/request_serializer.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

    Class Transaction has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Transaction
        ONE_DAY_IN_SECONDS = 86400
        FIFTEEN_MINUTES_IN_SECONDS = 900
    
        include Extensions::MassAssignment
    Severity: Minor
    Found in lib/pagseguro/transaction.rb - About 2 hrs to fix

      Method xml_builder has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def xml_builder
              Nokogiri::XML::Builder.new(encoding: PagSeguro.encoding) do |xml|
                xml.send(:preApprovalRequest) {
                  xml.send(:redirectURL, object.redirect_url)
                  xml.send(:reviewURL, object.review_url)
      Severity: Minor
      Found in lib/pagseguro/subscription_plan/request_serializer.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

      File request_serializer.rb has 253 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      module PagSeguro
        class TransactionRequest
          class RequestSerializer
            # The transaction request that will be serialized.
            attr_reader :transaction_request
      Severity: Minor
      Found in lib/pagseguro/transaction_request/request_serializer.rb - About 2 hrs to fix

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

              def serialize_address(xml, address)
                return unless address
        
                xml.send(:address) {
                  xml.send(:street, address.street) if address.street
        Severity: Major
        Found in lib/pagseguro/subscription/request_serializer.rb and 2 other locations - About 1 hr to fix
        lib/pagseguro/authorization_request/request_serializer.rb on lines 89..100
        lib/pagseguro/subscription/request_serializer.rb on lines 70..81

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

        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 3 locations. Consider refactoring.
        Open

              def serialize_billing_address(xml, address)
                return unless address
        
                xml.send(:billingAddress) {
                  xml.send(:street, address.street) if address.street
        Severity: Major
        Found in lib/pagseguro/subscription/request_serializer.rb and 2 other locations - About 1 hr to fix
        lib/pagseguro/authorization_request/request_serializer.rb on lines 89..100
        lib/pagseguro/subscription/request_serializer.rb on lines 55..66

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

        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 3 locations. Consider refactoring.
        Open

              def serialize_address(xml, address)
                return unless address
        
                xml.send(:address) {
                  xml.send(:postalCode, address.postal_code) if address.postal_code
        Severity: Major
        Found in lib/pagseguro/authorization_request/request_serializer.rb and 2 other locations - About 1 hr to fix
        lib/pagseguro/subscription/request_serializer.rb on lines 55..66
        lib/pagseguro/subscription/request_serializer.rb on lines 70..81

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

        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 has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def build
                Nokogiri::XML::Builder.new(encoding: PagSeguro.encoding) do |xml|
                  xml.send(:paymentMethod) {
                    xml.send(:type, 'CREDITCARD')
        
        
        Severity: Minor
        Found in lib/pagseguro/subscription_change_payment/request_serializer.rb - About 1 hr to fix

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

              report.subscriptions.each_with_index do |subscription, index|
                puts "Subscription #{index+1}/#{report.results}:"
                puts "  code: #{subscription.code}"
                puts "  name: #{subscription.name}"
                puts "  date: #{subscription.date}"
          Severity: Major
          Found in examples/preapproval/search/search_by_date_interval.rb and 1 other location - About 1 hr to fix
          examples/preapproval/search/search_by_days_interval.rb on lines 28..37

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

          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

              report.subscriptions.each_with_index do |subscription, index|
                puts "Subscription #{index+1}/#{report.results}:"
                puts "  code: #{subscription.code}"
                puts "  name: #{subscription.name}"
                puts "  date: #{subscription.date}"
          Severity: Major
          Found in examples/preapproval/search/search_by_days_interval.rb and 1 other location - About 1 hr to fix
          examples/preapproval/search/search_by_date_interval.rb on lines 28..37

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

          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