pagseguro/ruby

View on GitHub

Showing 60 of 60 total issues

Method xml_serialize_credit_card has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def xml_serialize_credit_card(xml)
        return unless transaction_request.is_a?(PagSeguro::CreditCardTransactionRequest)

        xml.send(:creditCard) do
          xml.send(:token, transaction_request.credit_card_token)
Severity: Minor
Found in lib/pagseguro/transaction_request/request_serializer.rb - About 1 hr to fix

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

          def serialize_items(data)
            data[:items] = []
    
            xml.css("items > item").each do |node|
              item = {}
    Severity: Major
    Found in lib/pagseguro/transaction/serializer.rb and 1 other location - About 1 hr to fix
    lib/pagseguro/transaction_request/response_serializer.rb on lines 50..60

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

    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

          def serialize_items(data)
            data[:items] = []
    
            xml.css("items > item").each do |node|
              item = {}
    Severity: Major
    Found in lib/pagseguro/transaction_request/response_serializer.rb and 1 other location - About 1 hr to fix
    lib/pagseguro/transaction/serializer.rb on lines 98..108

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

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

          def serialize_sender(xml, sender)
            return unless sender
    
            xml.send(:sender) {
              xml.send(:name, sender.name) if sender.name
    Severity: Minor
    Found in lib/pagseguro/subscription/request_serializer.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

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

          def serialize_amounts(data)
            data[:gross_amount] = BigDecimal(xml.css("grossAmount").text.to_f.to_s)
            data[:discount_amount] = BigDecimal(xml.css("discountAmount").text.to_f.to_s)
            data[:net_amount] = BigDecimal(xml.css("netAmount").text.to_f.to_s)
            data[:extra_amount] = BigDecimal(xml.css("extraAmount").text.to_f.to_s)
    Severity: Major
    Found in lib/pagseguro/transaction/serializer.rb and 1 other location - About 1 hr to fix
    lib/pagseguro/transaction_request/response_serializer.rb on lines 42..47

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

    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 serialize_amounts(data)
            data[:gross_amount] = BigDecimal(xml.css("grossAmount").text.to_f.to_s)
            data[:discount_amount] = BigDecimal(xml.css("discountAmount").text.to_f.to_s)
            data[:net_amount] = BigDecimal(xml.css("netAmount").text.to_f.to_s)
            data[:extra_amount] = BigDecimal(xml.css("extraAmount").text.to_f.to_s)
    Severity: Major
    Found in lib/pagseguro/transaction_request/response_serializer.rb and 1 other location - About 1 hr to fix
    lib/pagseguro/transaction/serializer.rb on lines 61..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 50.

    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

          def serialize_address(data)
            data[:address] = {
              street: address_node.css("> street").text,
              number: address_node.css("> number").text,
              complement: address_node.css("> complement").text,
    Severity: Minor
    Found in lib/pagseguro/transaction/serializer.rb and 1 other location - About 55 mins to fix
    lib/pagseguro/transaction_request/response_serializer.rb on lines 99..108

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

    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

          def serialize_address(data)
            data[:address] = {
              street: address_node.css("> street").text,
              number: address_node.css("> number").text,
              complement: address_node.css("> complement").text,
    Severity: Minor
    Found in lib/pagseguro/transaction_request/response_serializer.rb and 1 other location - About 55 mins to fix
    lib/pagseguro/transaction/serializer.rb on lines 147..156

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

    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 serialize_shipping_address(address)
            return unless address
    
            params[:shippingAddressCountry] = address.country
            params[:shippingAddressState] = address.state
    Severity: Minor
    Found in lib/pagseguro/transaction_request/request_serializer.rb and 1 other location - About 55 mins to fix
    lib/pagseguro/transaction_request/request_serializer.rb on lines 83..93

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

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

        def params
          {}.tap do |param|
            param[:credentials] = options[:credentials]
            param[:page] = page unless page.zero?
            param[:maxPageResults] = options[:per_page]
    Severity: Minor
    Found in lib/pagseguro/subscription/subscription_search.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 serialize_account has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

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

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

          def serialize_billing_address(address)
            return unless address
    
            params[:billingAddressCountry] = address.country
            params[:billingAddressState] = address.state
    Severity: Minor
    Found in lib/pagseguro/transaction_request/request_serializer.rb and 1 other location - About 55 mins to fix
    lib/pagseguro/transaction_request/request_serializer.rb on lines 132..142

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

    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 TransactionCancellation
        class Response
          def initialize(response, object)
            @response = response
            @object = object
    Severity: Minor
    Found in lib/pagseguro/transaction_cancellation/response.rb and 1 other location - About 50 mins to fix
    lib/pagseguro/transaction_refund/response.rb on lines 2..31

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

    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 TransactionRefund
        class Response
          def initialize(response, object)
            @response = response
            @object = object
    Severity: Minor
    Found in lib/pagseguro/transaction_refund/response.rb and 1 other location - About 50 mins to fix
    lib/pagseguro/transaction_cancellation/response.rb on lines 2..31

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

    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 SubscriptionPlan
        class Response
          # The http response.
          attr_reader :response
    
    
    Severity: Minor
    Found in lib/pagseguro/subscription_plan/response.rb and 1 other location - About 45 mins to fix
    lib/pagseguro/manual_subscription_charger/response.rb on lines 2..32

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

    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 ManualSubscriptionCharger
        class Response
          # The http response.
          attr_reader :response
    
    
    Severity: Minor
    Found in lib/pagseguro/manual_subscription_charger/response.rb and 1 other location - About 45 mins to fix
    lib/pagseguro/subscription_plan/response.rb on lines 2..32

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

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

          def xml_serialize_credit_card(xml)
            return unless transaction_request.is_a?(PagSeguro::CreditCardTransactionRequest)
    
            xml.send(:creditCard) do
              xml.send(:token, transaction_request.credit_card_token)
    Severity: Minor
    Found in lib/pagseguro/transaction_request/request_serializer.rb - About 45 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 serialize_company has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def serialize_company(xml, company)
            return unless company
    
            xml.send(:company) {
              xml.send(:name, company.name) if company.name
    Severity: Minor
    Found in lib/pagseguro/authorization_request/request_serializer.rb - About 45 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 post_xml has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def post_xml(path, api_version, credentials, data = '', options={})
    Severity: Minor
    Found in lib/pagseguro/request.rb - About 35 mins to fix

      Method execute has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def execute(request_method, path, api_version, data, headers) # :nodoc:
      Severity: Minor
      Found in lib/pagseguro/request.rb - About 35 mins to fix
        Severity
        Category
        Status
        Source
        Language