catarse/catarse_paypal_express

View on GitHub

Showing 6 of 12 total issues

Function validateCnpj has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

  validateCnpj: function(cnpj) {
    var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
    digitos_iguais = 1;
    if (cnpj.length < 14 && cnpj.length < 15)
      return false;
Severity: Minor
Found in app/assets/javascripts/catarse_paypal_express/user_document.js - About 3 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

Function onUserDocumentKeyup has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  onUserDocumentKeyup: function(e){
    var $documentField = $(e.currentTarget);

    var documentNumber = $documentField.val();
    $documentField.prop('maxlength', 18);
Severity: Minor
Found in app/assets/javascripts/catarse_paypal_express/user_document.js - 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

Function validateCnpj has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  validateCnpj: function(cnpj) {
    var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
    digitos_iguais = 1;
    if (cnpj.length < 14 && cnpj.length < 15)
      return false;
Severity: Minor
Found in app/assets/javascripts/catarse_paypal_express/user_document.js - About 1 hr to fix

    Method process_paypal_message has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def process_paypal_message(data)
        extra_data = (data['charset'] ? JSON.parse(data.to_json.force_encoding(data['charset']).encode('utf-8')) : data)
        PaymentEngines.create_payment_notification contribution_id: contribution.id, extra_data: extra_data
    
        if data["checkout_status"] == 'PaymentActionCompleted'
    Severity: Minor
    Found in app/controllers/catarse_paypal_express/paypal_express_controller.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

    Avoid too many return statements within this function.
    Open

              return false;
    Severity: Major
    Found in app/assets/javascripts/catarse_paypal_express/user_document.js - About 30 mins to fix

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

        def ipn
          if contribution && notification.acknowledge && (contribution.payment_method == 'PayPal' || contribution.payment_method.nil?)
            process_paypal_message params
            contribution.update_attributes({
              :payment_service_fee => params['mc_fee'],
      Severity: Minor
      Found in app/controllers/catarse_paypal_express/paypal_express_controller.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

      Severity
      Category
      Status
      Source
      Language