sharetribe/sharetribe

View on GitHub
app/assets/javascripts/stripe_form3.js

Summary

Maintainability
F
3 days
Test Coverage

File stripe_form3.js has 416 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* jshint sub: false */
/* Sripe API version 2019-02-19 */
window.ST = window.ST || {};
window.ST.stripe_form_i18n = window.ST.stripe_form_i18n || {
  'account_number' : 'Account number',
Severity: Minor
Found in app/assets/javascripts/stripe_form3.js - About 6 hrs to fix

    Function init has 120 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var init = function(options) {
        BANK_RULES = options.bank_rules;
        window.ST.stripe_test_api_mode = options.stripe_test_mode;
        stripeApi = Stripe(options.api_publishable_key);
        add_validators();
    Severity: Major
    Found in app/assets/javascripts/stripe_form3.js - About 4 hrs to fix

      Function prepareData has 79 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var prepareData = function(options) {
          var country = getValue('address_country'),
            firstName = getValue('first_name'),
            lastName = getValue('last_name'),
            address, person;
      Severity: Major
      Found in app/assets/javascripts/stripe_form3.js - About 3 hrs to fix

        Function submitHandler has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              submitHandler: function(form) {
                removeSpaces();
                stripeFormData = $(form).serializeArray();
                var data = prepareData(options),
                  documentFrontEl = $('#stripe_account_form_document_front'),
        Severity: Major
        Found in app/assets/javascripts/stripe_form3.js - About 2 hrs to fix

          Function stripeUploadFiles has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          var stripeUploadFiles = function stripeUploadFiles(options) {
            var uploadFiles = function uploadFiles() {
              var fileData, itemKey, fileForm, additionalFileForm, additionalFileData, fileResult;
              return regeneratorRuntime.async(function uploadFiles$(_context) {
                while (1) {
          Severity: Minor
          Found in app/assets/javascripts/stripe_form3.js - About 1 hr to fix

            Function add_validators has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              var add_validators = function() {
                function explain_regexp(value) {
                  var t = value;
                  t = t.replace(/-\[/g, ';'+i18n_label('a_dash', 'a dash')+';[');
                  t = t.replace(/\[0-9\]\{(\d+)}/g, ';$1 '+i18n_label('digits', 'digits')+';');
            Severity: Minor
            Found in app/assets/javascripts/stripe_form3.js - About 1 hr to fix

              Function uploadFiles has 42 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                var uploadFiles = function uploadFiles() {
                  var fileData, itemKey, fileForm, additionalFileForm, additionalFileData, fileResult;
                  return regeneratorRuntime.async(function uploadFiles$(_context) {
                    while (1) {
                      switch (_context.prev = _context.next) {
              Severity: Minor
              Found in app/assets/javascripts/stripe_form3.js - About 1 hr to fix

                Function uploadFiles$ has 39 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    return regeneratorRuntime.async(function uploadFiles$(_context) {
                      while (1) {
                        switch (_context.prev = _context.next) {
                          case 0:
                            fileData = {};
                Severity: Minor
                Found in app/assets/javascripts/stripe_form3.js - About 1 hr to fix

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

                        person = {
                          first_name_kana: getValue('first_name_kana'),
                          last_name_kana: getValue('last_name_kana'),
                          first_name_kanji: getValue('first_name_kanji'),
                          last_name_kanji: getValue('last_name_kanji'),
                  Severity: Major
                  Found in app/assets/javascripts/stripe_form3.js and 1 other location - About 1 hr to fix
                  client/app/components/sections/Topbar/Topbar.js on lines 58..65

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

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

                          address_kana: {
                            postal_code: getValue('address_kana_postal_code'),
                            state: getValue('address_kana_state'),
                            city: getValue('address_kana_city'),
                            town: getValue('address_kana_town'),
                  Severity: Major
                  Found in app/assets/javascripts/stripe_form3.js and 3 other locations - About 50 mins to fix
                  app/assets/javascripts/stripe_form3.js on lines 123..129
                  app/assets/javascripts/stripe_form3.js on lines 151..157
                  client/app/components/sections/Topbar/Topbar.story.js on lines 88..94

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

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

                          address_kanji: {
                            postal_code: getValue('address_kanji_postal_code'),
                            state: getValue('address_kanji_state'),
                            city: getValue('address_kanji_city'),
                            town: getValue('address_kanji_town'),
                  Severity: Major
                  Found in app/assets/javascripts/stripe_form3.js and 3 other locations - About 50 mins to fix
                  app/assets/javascripts/stripe_form3.js on lines 116..122
                  app/assets/javascripts/stripe_form3.js on lines 151..157
                  client/app/components/sections/Topbar/Topbar.story.js on lines 88..94

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

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

                          address: {
                            city: getValue('address_city'),
                            state: getValue('address_state'),
                            country: getValue('address_country'),
                            postal_code: getValue('address_postal_code'),
                  Severity: Major
                  Found in app/assets/javascripts/stripe_form3.js and 3 other locations - About 50 mins to fix
                  app/assets/javascripts/stripe_form3.js on lines 116..122
                  app/assets/javascripts/stripe_form3.js on lines 123..129
                  client/app/components/sections/Topbar/Topbar.story.js on lines 88..94

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

                  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