omegainteractive/comfypress

View on GitHub

Showing 40 of 80 total issues

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

    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

    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

    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

            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

                Method process_content has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.process_content(page, content = '', parent_tag = nil)
                    tokens = content.to_s.scan(TOKENIZER_REGEX)
                    tokens.collect do |tag_signature, text|
                      if tag_signature
                        if tag = self.initialize_tag(page, tag_signature)
                Severity: Minor
                Found in lib/comfypress/tag.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 export_pages has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.export_pages(from_site, to_folder = nil)
                    return unless site = Cms::Site.find_by_identifier(from_site)
                    path = File.join(ComfyPress.config.fixtures_path, (to_folder || site.identifier), 'pages')
                    FileUtils.rm_rf(path)
                    FileUtils.mkdir_p(path)
                Severity: Minor
                Found in lib/comfypress/fixtures.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 admin has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.admin(options = {})
                    options[:path] ||= 'cms-admin'
                    
                    Rails.application.routes.draw do
                      namespace :cms_admin, :path => options[:path], :except => :show do
                Severity: Minor
                Found in lib/comfypress/routing.rb - About 1 hr to fix

                  Method cms_snippet_content has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def cms_snippet_content(identifier, cms_site = nil)
                      unless cms_site
                        host, path = request.host.downcase, request.fullpath if respond_to?(:request) && request
                        cms_site ||= (@cms_site || Cms::Site.find_site(host, path))
                      end
                  Severity: Minor
                  Found in lib/comfypress/view_methods.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 import_snippets has 34 lines of code (exceeds 25 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 1 hr to fix

                    Method sync_mirror has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def sync_mirror
                          return if self.is_mirrored || !self.site.is_mirrored?
                          
                          (Cms::Site.mirrored - [self.site]).each do |site|
                            mirror = case self
                    Severity: Minor
                    Found in lib/comfypress/extensions/is_mirrored.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language