refinery/refinerycms

View on GitHub

Showing 52 of 73 total issues

Method page_title has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def page_title(options = {})
      object = options.fetch(:object, @meta)
      options.delete(:object)
      options = Refinery::Pages.page_title.merge(options)

Severity: Minor
Found in core/app/helpers/refinery/meta_helper.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 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def create
        @images = []
        begin
          if params[:image].present? && params[:image][:image].is_a?(Array)
            params[:image][:image].each do |image|
Severity: Minor
Found in images/app/controllers/refinery/admin/images_controller.rb - About 1 hr to fix

    Function onload has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    window.onload = function () {
      'use strict';
    
      const image = document.getElementById('crop');
      const ratios = document.getElementById('ratios');
    Severity: Minor
    Found in core/app/assets/javascripts/refinery/image_crop.js - 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 insert has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

          def insert
            self.new if @resource.nil?
            @url_override = refinery.admin_resources_path(request.query_parameters.merge(insert: true))
    
            if params[:conditions].present?
    Severity: Minor
    Found in resources/app/controllers/refinery/admin/resources_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 sanity_check_heroku_application_name! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def sanity_check_heroku_application_name!
          if heroku? && options[:heroku].to_s.include?('_') || options[:heroku].to_s.length > 30
            message = ["\nThe application name '#{options[:heroku]}' that you specified is invalid for Heroku."]
            suggested_name = options[:heroku].dup.to_s
            if suggested_name.include?('_')
    Severity: Minor
    Found in core/lib/generators/refinery/cms/cms_generator.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

    Consider simplifying this complex logical expression.
    Open

                if (!o.isAllowed(this.currentItem, parentItem) ||
                    parentItem && parentItem.hasClass(o.disableNesting) ||
                    o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) {
                        this.placeholder.addClass(o.errorClass);
                        if (maxLevels < levels && maxLevels != 0) {
    Severity: Critical
    Found in core/app/assets/javascripts/refinery/nestedsortables.js - About 1 hr to fix

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

            def link_to
              # Get the switch_local variable to determine the locale we're currently editing
              # Set up Mobility with our current locale
              Mobility.locale = if params[:switch_locale].present? && Refinery::I18n.built_in_locales.keys.map(&:to_s).include?(params[:switch_locale])
                Mobility.locale = params[:switch_locale]
      Severity: Minor
      Found in pages/app/controllers/refinery/admin/pages_dialogs_controller.rb - About 1 hr to fix

        Method update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

              def update
                if @page.update(page_params)
                  flash.notice = t('refinery.crudify.updated', what: "'#{@page.title}'")
        
                  if from_dialog?
        Severity: Minor
        Found in pages/app/controllers/refinery/admin/pages_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 update has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def update
                @image.attributes = image_params
                if @image.valid? && @image.save
                  flash.notice = t('refinery.crudify.updated', what: "'#{@image.title}'")
        
        
        Severity: Minor
        Found in images/app/controllers/refinery/admin/images_controller.rb - About 1 hr to fix

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

              def uncrudify(controller, action)
                unless (controller_name = controller).present? && (action = action).present?
                  abort <<-HELPDOC.strip_heredoc
                    You didn't specify anything to uncrudify. Here's some examples:
                    rake refinery:uncrudify controller=refinery/admin/pages action=create
          Severity: Minor
          Found in core/lib/refinery/cli.rb - About 1 hr to fix

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

                  def update
                    if @page.update(page_params)
                      flash.notice = t('refinery.crudify.updated', what: "'#{@page.title}'")
            
                      if from_dialog?
            Severity: Minor
            Found in pages/app/controllers/refinery/admin/pages_controller.rb - About 1 hr to fix

              Method insert has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                    def insert
                      self.new if @image.nil?
                      @url_override = refinery.admin_images_path(request.query_parameters.merge(insert: true))
              
                      if params[:conditions].present?
              Severity: Minor
              Found in images/app/controllers/refinery/admin/images_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 pagination_css_class has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  def pagination_css_class
                    if request.xhr? and params[:from_page].present?
                      "frame_#{params[:from_page] > (params[:page] ? params[:page] : "1") ? 'left' : 'right'}"
                    else
                      "frame_center"
              Severity: Minor
              Found in core/app/helpers/refinery/pagination_helper.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 page_title has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def page_title(options = {})
                    object = options.fetch(:object, @meta)
                    options.delete(:object)
                    options = Refinery::Pages.page_title.merge(options)
              
              
              Severity: Minor
              Found in core/app/helpers/refinery/meta_helper.rb - About 1 hr to fix

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

                    def prepare_database!
                      unless self.options[:skip_migrations]
                        command = %w[railties:install:migrations]
                        unless self.options[:skip_db]
                          command |= %w[db:create db:migrate]
                Severity: Minor
                Found in core/lib/generators/refinery/cms/cms_generator.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 route_for_model has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                Open

                    def route_for_model(klass, options = {})
                      options = {:plural => false, :admin => true}.merge options
                
                      klass = klass.constantize if klass.respond_to?(:constantize)
                      active_name = ::ActiveModel::Name.new(
                Severity: Minor
                Found in core/lib/refinery.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 run_additional_generators! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                    def run_additional_generators!
                      generator_args = []
                      generator_args << '--quiet' if self.options[:quiet]
                      generator_args << '--skip-migrations' if self.options[:skip_migrations]
                      Refinery::CoreGenerator.start generator_args
                Severity: Minor
                Found in core/lib/generators/refinery/cms/cms_generator.rb - About 45 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 create has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                      def create
                        @resources = Resource.create_resources(resource_params)
                        @resource = @resources.detect { |r| !r.valid? }
                
                        if params[:insert]
                Severity: Minor
                Found in resources/app/controllers/refinery/admin/resources_controller.rb - About 45 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

                Consider simplifying this complex logical expression.
                Open

                            if (parentItem != null && nextItem == null &&
                                    (o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
                                    !o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
                                parentItem.after(this.placeholder[0]);
                                this._clearEmpty(parentItem[0]);
                Severity: Major
                Found in core/app/assets/javascripts/refinery/nestedsortables.js - About 40 mins to fix

                  Method action_icon_label has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def action_icon_label(action, url, title, options={}, label = true)
                  Severity: Minor
                  Found in core/app/helpers/refinery/tag_helper.rb - About 35 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language