omegainteractive/comfypress

View on GitHub
app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js

Summary

Maintainability
F
6 days
Test Coverage

File bootstrap-wysihtml5.js has 438 lines of code (exceeds 250 allowed). Consider refactoring.
Open

!function($, wysi) {
    "use strict";

    var tpl = {
        "font-styles": function(locale, options) {
Severity: Minor
Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js - About 6 hrs to fix

    Function initInsertLink has 49 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            initInsertLink: function(toolbar) {
                var self = this;
                var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
                var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
                var insertButton = insertLinkModal.find('a.btn-primary');
    Severity: Minor
    Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js - About 1 hr to fix

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

              createToolbar: function(el, options) {
                  var self = this;
                  var toolbar = $("<ul/>", {
                      'class' : "wysihtml5-toolbar",
                      'style': "display:none"
      Severity: Minor
      Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js - About 1 hr to fix

        Function initInsertImage has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                initInsertImage: function(toolbar) {
                    var self = this;
                    var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
                    var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
                    var insertButton = insertImageModal.find('a.btn-primary');
        Severity: Minor
        Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js - About 1 hr to fix

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

                  "image": function(locale, options) {
                      var size = (options && options.size) ? ' btn-'+options.size : '';
                      return "<li>" +
                        "<div class='bootstrap-wysihtml5-insert-image-modal modal hide fade'>" +
                          "<div class='modal-header'>" +
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 7 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 43..61

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

          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

                  "link": function(locale, options) {
                      var size = (options && options.size) ? ' btn-'+options.size : '';
                      return "<li>" +
                        "<div class='bootstrap-wysihtml5-insert-link-modal modal hide fade'>" +
                          "<div class='modal-header'>" +
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 7 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 63..81

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

          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

                      return "<li class='dropdown'>" +
                        "<a class='btn dropdown-toggle" + size + "' data-toggle='dropdown' href='#'>" +
                        "<i class='icon-font'></i>&nbsp;<span class='current-font'>" + locale.font_styles.normal + "</span>&nbsp;<b class='caret'></b>" +
                        "</a>" +
                        "<ul class='dropdown-menu'>" +
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 94..103

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

          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

                      return "<li class='dropdown'>" +
                        "<a class='btn dropdown-toggle" + size + "' data-toggle='dropdown' href='#' tabindex='-1'>" +
                          "<span class='current-color'>" + locale.colours.black + "</span>&nbsp;<b class='caret'></b>" +
                        "</a>" +
                        "<ul class='dropdown-menu'>" +
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 4 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 7..17

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

          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

                      return "<li>" +
                        "<div class='btn-group'>" +
                          "<a class='btn" + size + "' data-wysihtml5-command='bold' title='CTRL+B' tabindex='-1'>" + locale.emphasis.bold + "</a>" +
                          "<a class='btn" + size + "' data-wysihtml5-command='italic' title='CTRL+I' tabindex='-1'>" + locale.emphasis.italic + "</a>" +
                          "<a class='btn" + size + "' data-wysihtml5-command='underline' title='CTRL+U' tabindex='-1'>" + locale.emphasis.underline + "</a>" +
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 33..38

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

          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

                      return "<li>" +
                        "<div class='btn-group'>" +
                          "<a class='btn" + size + "' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "' tabindex='-1'><i class='icon-list'></i></a>" +
                          "<a class='btn" + size + "' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "' tabindex='-1'><i class='icon-th-list'></i></a>" +
                          "<a class='btn" + size + "' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "' tabindex='-1'><i class='icon-indent-right'></i></a>" +
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 22..28

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

          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

                      toolbar.find("a[data-wysihtml5-command='foreColor']").click(function(e) {
                          var target = e.target || e.srcElement;
                          var el = $(target);
                          self.toolbar.find('.current-color').text(el.html());
                      });
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 199..203

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

          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

                      toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
                          var target = e.target || e.srcElement;
                          var el = $(target);
                          self.toolbar.find('.current-font').text(el.html());
                      });
          Severity: Major
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 2 hrs to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 205..209

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

          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

                      urlInput.keypress(function(e) {
                          if(e.which == 13) {
                              insertImage();
                              insertImageModal.modal('hide');
                          }
          Severity: Minor
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 301..306

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

          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

                      urlInput.keypress(function(e) {
                          if(e.which == 13) {
                              insertLink();
                              insertLinkModal.modal('hide');
                          }
          Severity: Minor
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 40 mins to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 242..247

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

          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

                  resetDefaults: function() {
                      $.fn.wysihtml5.defaultOptions = $.extend(true, {}, $.fn.wysihtml5.defaultOptionsCache);
                  },
          Severity: Minor
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 30 mins to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 442..444

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

          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

              if (typeof $.fn.wysihtml5.defaultOptionsCache === 'undefined') {
                  $.fn.wysihtml5.defaultOptionsCache = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
              }
          Severity: Minor
          Found in app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js and 1 other location - About 30 mins to fix
          app/assets/javascripts/comfypress/lib/bootstrap-wysihtml5.js on lines 339..341

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

          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