Showing 1,501 of 1,501 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
def authorize(money, payment, options = {})
MultiResponse.run do |r|
r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
options[:card_token] = r.authorization.split('|').first
r.process { commit('authorize', 'payments', authorize_request(money, payment, options)) }
- Read upRead up
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 37.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method commit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def commit(action, post, options, authorization = nil, method = :post)
Method add_auth_invoice_data
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_auth_invoice_data(action, post, money, authorization, options)
Method perform_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def perform_request(action, post, options, authorization = nil, method = :post)
Method generate_hash_data
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def generate_hash_data(order_id, terminal_id, credit_card_number, amount, security_data)
Method log_with_retry_details
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def log_with_retry_details(logger, attempts, time, message, tag)
Method response
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def response(action, succeeded, response, options = {}, source_id = nil)
Method execute_3ds_flow
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def execute_3ds_flow(post, money, payment, transaction_type, options = {})
Method add_reference
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_reference(post, orderid, transactionid, transaction_reference, reference_key = :reference)
Method build_authorized_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_authorized_request(action, money, authorization, credit_card, options)
Method add_auth_purchase_params
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_auth_purchase_params(post, money, card, action, options)
Method add_customerdetails
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_customerdetails(xml, creditcard, address, options, shipTo = false)
Method add_transaction_details
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_transaction_details(xml, amount, authorization, type, options = {})
Method add_address
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_address(xml, creditcard, address, options, shipTo = false)
Method add_address
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_address(post, payment_method, address, options, address_type)
Method commit
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def commit(action, options, verb = :post, payment_method_details = PaymentMethodDetails.new(), &block)
Method add_cim_auth_purchase
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_cim_auth_purchase(xml, transaction_type, amount, payment, options)
Method add_auth_purchase
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_auth_purchase(xml, transaction_type, amount, payment, options)
Method build_field_value_array
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_field_value_array(soap, tag_name, type, custom_data, fields)
Method build_void_request
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def build_void_request(money, transaction_id, approval, token, options)