activemerchant/active_merchant

View on GitHub
lib/active_merchant/billing/gateways/pay_hub.rb

Summary

Maintainability
A
3 hrs
Test Coverage

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

      STANDARD_ERROR_CODE_MAPPING = {
        '14' => STANDARD_ERROR_CODE[:invalid_number],
        '80' => STANDARD_ERROR_CODE[:invalid_expiry_date],
        '82' => STANDARD_ERROR_CODE[:invalid_cvc],
        '54' => STANDARD_ERROR_CODE[:expired_card],
Severity: Major
Found in lib/active_merchant/billing/gateways/pay_hub.rb and 3 other locations - About 1 hr to fix
lib/active_merchant/billing/gateways/firstdata_e4.rb on lines 45..63
lib/active_merchant/billing/gateways/firstdata_e4_v27.rb on lines 37..55
lib/active_merchant/billing/gateways/usa_epay_transaction.rb on lines 23..39

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

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

      AVS_CODE_TRANSLATOR = {
        '0' =>  'Approved, Address verification was not requested.',
        'A' =>  'Approved, Address matches only.',
        'B' =>  'Address Match. Street Address math for international transaction Postal Code not verified because of incompatible formats (Acquirer sent both street address and Postal Code)',
        'C' =>  'Serv Unavailable. Street address and Postal Code not verified for international transaction because of incompatible formats (Acquirer sent both street and Postal Code).',
Severity: Major
Found in lib/active_merchant/billing/gateways/pay_hub.rb and 1 other location - About 1 hr to fix
lib/active_merchant/billing/avs_result.rb on lines 11..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 54.

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 authorize(amount, creditcard, options = {})
        post = setup_post('auth')
        add_creditcard(post, creditcard)
        add_amount(post, amount)
        add_address(post, (options[:address] || options[:billing_address]))
Severity: Minor
Found in lib/active_merchant/billing/gateways/pay_hub.rb and 1 other location - About 20 mins to fix
lib/active_merchant/billing/gateways/pay_hub.rb on lines 85..92

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

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 purchase(amount, creditcard, options = {})
        post = setup_post('sale')
        add_creditcard(post, creditcard)
        add_amount(post, amount)
        add_address(post, (options[:address] || options[:billing_address]))
Severity: Minor
Found in lib/active_merchant/billing/gateways/pay_hub.rb and 1 other location - About 20 mins to fix
lib/active_merchant/billing/gateways/pay_hub.rb on lines 75..82

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

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