omegainteractive/comfypress

View on GitHub

Showing 80 of 80 total issues

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

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

    Method import_layouts has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.import_layouts(to_site, from_folder = nil, path = nil, root = true, parent = nil, layout_ids = [], force_import = false)
        site = Cms::Site.find_or_create_by_identifier(to_site)
        unless path ||= find_fixtures_path((from_folder || to_site), 'layouts')
          ComfyPress.logger.warn('Cannot find Layout fixtures')
          return []
    Severity: Minor
    Found in lib/comfypress/fixtures.rb - About 5 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

    Method import_pages has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.import_pages(to_site, from_folder = nil, path = nil, root = true, parent = nil, page_ids = [], force_import = false)
        site = Cms::Site.find_or_create_by_identifier(to_site)
        unless path ||= find_fixtures_path((from_folder || to_site), 'pages')
          ComfyPress.logger.warn('Cannot find Page fixtures')
          return []
    Severity: Minor
    Found in lib/comfypress/fixtures.rb - About 5 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

    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

    Method render has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def render(options = {}, locals = {}, &block)
          
          if options.is_a?(Hash) && identifier = options.delete(:cms_site)
            unless @cms_site = Cms::Site.find_by_identifier(identifier)
              raise ComfyPress::MissingSite.new(identifier)
    Severity: Minor
    Found in lib/comfypress/render_methods.rb - 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

    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

    Method import_snippets has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.import_snippets(to_site, from_folder = nil, force_import = false)
        site = Cms::Site.find_or_create_by_identifier(to_site)
        unless path = find_fixtures_path((from_folder || to_site), 'snippets')
          ComfyPress.logger.warn('Cannot find Snippet fixtures')
          return []
    Severity: Minor
    Found in lib/comfypress/fixtures.rb - 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

    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

    Method import_pages has 60 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.import_pages(to_site, from_folder = nil, path = nil, root = true, parent = nil, page_ids = [], force_import = false)
        site = Cms::Site.find_or_create_by_identifier(to_site)
        unless path ||= find_fixtures_path((from_folder || to_site), 'pages')
          ComfyPress.logger.warn('Cannot find Page fixtures')
          return []
    Severity: Major
    Found in lib/comfypress/fixtures.rb - About 2 hrs to fix

      Method import_layouts has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.import_layouts(to_site, from_folder = nil, path = nil, root = true, parent = nil, layout_ids = [], force_import = false)
          site = Cms::Site.find_or_create_by_identifier(to_site)
          unless path ||= find_fixtures_path((from_folder || to_site), 'layouts')
            ComfyPress.logger.warn('Cannot find Layout fixtures')
            return []
      Severity: Major
      Found in lib/comfypress/fixtures.rb - About 2 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

          Method included has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def self.included(base)
              
              # If application controller doesn't have template associated with it
              # CMS will attempt to find one. This is so you don't have to explicitly
              # call render :cms_page => '/something'
          Severity: Minor
          Found in lib/comfypress/render_methods.rb - About 1 hr to fix

            Method create has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @files = []
                
                # Sometimes params[:file] comes in as a single file object
                unless params[:file].is_a?(Hash)
            Severity: Minor
            Found in app/controllers/cms_admin/files_controller.rb - About 1 hr 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

            Method render has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def render
                file = block.files.first
                case self.type
                when 'url'
                  return '' unless file
            Severity: Minor
            Found in lib/comfypress/tags/page_file.rb - About 1 hr 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

            Method render has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              def render
                files = block.files
                case self.type
                when 'url'
                  return '' if files.blank?
            Severity: Minor
            Found in lib/comfypress/tags/page_files.rb - About 1 hr 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