sharetribe/sharetribe

View on GitHub
app/assets/javascripts/admin/custom_fields.js

Summary

Maintainability
D
2 days
Test Coverage

Function createOptionOrder has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  var createOptionOrder = function(rowSelector) {

    /**
      Fetch all custom field rows and save them to a variable
    */
Severity: Major
Found in app/assets/javascripts/admin/custom_fields.js - About 2 hrs to fix

    Function createOrder has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      var createOrder = function() {
        /**
          Fetch all custom field rows and save them to a variable
        */
        var fieldMap = $(".custom-field-list-row").map(function(id, row) {
    Severity: Minor
    Found in app/assets/javascripts/admin/custom_fields.js - About 1 hr to fix

      Function initMainForm has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        var initMainForm = function(options) {
          translate_validation_messages(options.locale);
      
          var form_id = "#custom_field_form";
          var $form = $(form_id);
      Severity: Minor
      Found in app/assets/javascripts/admin/custom_fields.js - About 1 hr to fix

        Function removeLinkEnabledState has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var removeLinkEnabledState = function(initialCount, minCount, containerSelector, linkSelector) {
            var enabled;
            var count = initialCount;
            update();
        
        
        Severity: Minor
        Found in app/assets/javascripts/admin/custom_fields.js - About 1 hr to fix

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

              var fieldMap = $(rowSelector).map(function(id, row) {
                return {
                  id: $(row).data("field-id"),
                  element: $(row),
                  sortPriority: Number($(row).find(".custom-field-hidden-sort-priority").val()),
          Severity: Major
          Found in app/assets/javascripts/admin/custom_fields.js and 1 other location - About 3 hrs to fix
          app/assets/javascripts/admin/landing_page_editor.js on lines 16..24

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

          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

              var ajaxRequest = orderManager.order.changes().debounce(800).map(".order")
                .skipDuplicates(_.isEqual)
                .map(function(order) {
                return {
                  type: "POST",
          Severity: Major
          Found in app/assets/javascripts/admin/custom_fields.js and 1 other location - About 3 hrs to fix
          app/assets/javascripts/admin/listing_shapes.js on lines 16..24

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

          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

            var initSelectionClickHandlers = function() {
              $(".select-all").click(function() {
                $(".custom-field-category-checkbox").prop("checked", true);
              });
              $(".deselect-all").click(function() {
          Severity: Major
          Found in app/assets/javascripts/admin/custom_fields.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/admin/categories.js on lines 4..11

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

          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

                errorPlacement: function(error, element) {
                  // Custom placement for checkbox group
                  if (element.attr("name") === CATEGORY_CHECKBOX_NAME) {
                    var container = $("#custom-field-categories-container");
                    error.insertAfter(container);
          Severity: Major
          Found in app/assets/javascripts/admin/custom_fields.js and 1 other location - About 1 hr to fix
          app/assets/javascripts/kassi.js on lines 720..728

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

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

              ajaxStatus.loading.onValue(function() {
                $("#custom-field-ajax-saving").show();
                $("#custom-field-ajax-error").hide();
                $("#custom-field-ajax-success").hide();
              });
          Severity: Major
          Found in app/assets/javascripts/admin/custom_fields.js and 2 other locations - About 1 hr to fix
          app/assets/javascripts/admin/categories.js on lines 63..67
          app/assets/javascripts/admin/listing_shapes.js on lines 29..33

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

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

              ajaxStatus.success.onValue(function() {
                $("#custom-field-ajax-saving").hide();
                $("#custom-field-ajax-success").show();
              });
          Severity: Major
          Found in app/assets/javascripts/admin/custom_fields.js and 5 other locations - About 40 mins to fix
          app/assets/javascripts/admin/categories.js on lines 69..72
          app/assets/javascripts/admin/categories.js on lines 74..77
          app/assets/javascripts/admin/custom_fields.js on lines 62..65
          app/assets/javascripts/admin/listing_shapes.js on lines 35..38
          app/assets/javascripts/admin/listing_shapes.js on lines 40..43

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

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

              ajaxStatus.error.onValue(function() {
                $("#custom-field-ajax-saving").hide();
                $("#custom-field-ajax-error").show();
              });
          Severity: Major
          Found in app/assets/javascripts/admin/custom_fields.js and 5 other locations - About 40 mins to fix
          app/assets/javascripts/admin/categories.js on lines 69..72
          app/assets/javascripts/admin/categories.js on lines 74..77
          app/assets/javascripts/admin/custom_fields.js on lines 57..60
          app/assets/javascripts/admin/listing_shapes.js on lines 35..38
          app/assets/javascripts/admin/listing_shapes.js on lines 40..43

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

          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

              var nextSortPriority = (function(startValue) {
                var i = startValue;
                return function() {
                  i += 1;
                  return i;
          Severity: Minor
          Found in app/assets/javascripts/admin/custom_fields.js and 1 other location - About 35 mins to fix
          app/assets/javascripts/admin/landing_page_editor.js on lines 33..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 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

          There are no issues that match your filters.

          Category
          Status