omegainteractive/comfypress

View on GitHub

Showing 80 of 80 total issues

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

            Method sync_mirror has a Cognitive Complexity of 11 (exceeds 5 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

            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 create has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                @slides = []
            
                # Sometimes params[:file] comes in as a single file object
                unless params[:file].is_a?(Hash)
            Severity: Minor
            Found in app/controllers/cms_admin/slides_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 create has 31 lines of code (exceeds 25 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

              Method initialize has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def initialize
                  @cms_title            = 'ComfyPress CMS Engine'
                  @admin_auth           = 'ComfyPress::HttpAuth'
                  @public_auth          = 'ComfyPress::DummyAuth'
                  @seed_data_path       = nil
              Severity: Minor
              Found in lib/comfypress/configuration.rb - About 1 hr to fix

                Method create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def create
                    @slides = []
                
                    # Sometimes params[:file] comes in as a single file object
                    unless params[:file].is_a?(Hash)
                Severity: Minor
                Found in app/controllers/cms_admin/slides_controller.rb - About 1 hr to fix

                  Method render has 26 lines of code (exceeds 25 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

                    Method initialize_tag has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize_tag(page, tag_signature)
                          if match = tag_signature.match(regex_tag_signature)
                            
                            params = begin
                              (CSV.parse_line(match[2].to_s, :col_sep => ':') || []).compact
                    Severity: Minor
                    Found in lib/comfypress/tag.rb - About 55 mins 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 7 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def self.import_pages(to_site, from_folder = nil, path = nil, root = true, parent = nil, page_ids = [], force_import = false)
                    Severity: Major
                    Found in lib/comfypress/fixtures.rb - About 50 mins to fix

                      Method import_layouts has 7 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def self.import_layouts(to_site, from_folder = nil, path = nil, root = true, parent = nil, layout_ids = [], force_import = false)
                      Severity: Major
                      Found in lib/comfypress/fixtures.rb - About 50 mins to fix

                        Method options_for_select has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def self.options_for_select(site, page = nil, current_page = nil, depth = 0, exclude_self = true, spacer = '. . ')
                        Severity: Minor
                        Found in app/models/cms/page.rb - About 45 mins to fix

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

                            def update
                              @slide.update_attributes!(params[:file])
                              flash[:success] = I18n.t('cms.slides.updated')
                              redirect_to :action => :edit, :id => @slide
                            rescue ActiveRecord::RecordInvalid
                          Severity: Major
                          Found in app/controllers/cms_admin/slides_controller.rb and 6 other locations - About 45 mins to fix
                          app/controllers/cms_admin/files_controller.rb on lines 66..74
                          app/controllers/cms_admin/layouts_controller.rb on lines 29..37
                          app/controllers/cms_admin/menu_items_controller.rb on lines 29..37
                          app/controllers/cms_admin/menus_controller.rb on lines 28..36
                          app/controllers/cms_admin/snippets_controller.rb on lines 29..37
                          app/controllers/cms_admin/tabs_controller.rb on lines 29..37

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

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

                            def update
                              @tab.update_attributes!(params[:tab])
                              flash[:success] = I18n.t('cms.tabs.updated')
                              redirect_to :action => :edit, :id => @tab
                            rescue ActiveRecord::RecordInvalid
                          Severity: Major
                          Found in app/controllers/cms_admin/tabs_controller.rb and 6 other locations - About 45 mins to fix
                          app/controllers/cms_admin/files_controller.rb on lines 66..74
                          app/controllers/cms_admin/layouts_controller.rb on lines 29..37
                          app/controllers/cms_admin/menu_items_controller.rb on lines 29..37
                          app/controllers/cms_admin/menus_controller.rb on lines 28..36
                          app/controllers/cms_admin/slides_controller.rb on lines 65..73
                          app/controllers/cms_admin/snippets_controller.rb on lines 29..37

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

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language