refinery/refinerycms

View on GitHub

Showing 52 of 73 total issues

Method crudify has 222 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def crudify(model_name, options = {})
        options = ::Refinery::Crud.default_options(model_name).merge(options)
        class_name = options[:class_name]
        singular_name = options[:singular_name]
        plural_name = options[:plural_name]
Severity: Major
Found in core/lib/refinery/crud.rb - About 1 day to fix

    Function create_sortable_list has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    var create_sortable_list = function(options){
        ordered_list = {
            initialised: false
            , init: function(options) {
                if(!this.initialised){
    Severity: Minor
    Found in core/app/assets/javascripts/refinery/sortable_list.js - 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

    Function create_sortable_list has 125 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    var create_sortable_list = function(options){
        ordered_list = {
            initialised: false
            , init: function(options) {
                if(!this.initialised){
    Severity: Major
    Found in core/app/assets/javascripts/refinery/sortable_list.js - About 5 hrs to fix

      Class Page has 37 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Page < Core::BaseModel
          extend Mobility
          translates :title, :menu_title, :custom_slug, :slug, :browser_title, :meta_description
      
          after_save { translations.in_locale(Mobility.locale).seo_meta.save! }
      Severity: Minor
      Found in pages/app/models/refinery/page.rb - About 4 hrs to fix

        File extension_generation.rb has 362 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Refinery
          module ExtensionGeneration
        
            def self.included(base)
              base.class_eval do
        Severity: Minor
        Found in core/lib/refinery/extension_generation.rb - About 4 hrs to fix

          Function _mouseDrag has 115 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  _mouseDrag: function(event) {
          
                      //Compute the helpers position
                      this.position = this._generatePosition(event);
                      this.positionAbs = this._convertPositionTo("absolute");
          Severity: Major
          Found in core/app/assets/javascripts/refinery/nestedsortables.js - About 4 hrs to fix

            File nestedsortables.js has 304 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            /*
             * jQuery UI Nested Sortable
             * v 1.3.5 / 21 jun 2012
             * http://mjsarfatti.com/code/nestedSortable
             *
            Severity: Minor
            Found in core/app/assets/javascripts/refinery/nestedsortables.js - About 3 hrs to fix

              Class CmsGenerator has 27 methods (exceeds 20 allowed). Consider refactoring.
              Open

                class CmsGenerator < Rails::Generators::Base
                  source_root Pathname.new(File.expand_path('../templates', __FILE__))
              
                  class_option :update,  :type => :boolean, :aliases => nil, :group => :runtime,
                                         :desc => "Update an existing Refinery CMS based application"
              Severity: Minor
              Found in core/lib/generators/refinery/cms/cms_generator.rb - About 3 hrs to fix

                Function onload has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                window.onload = function () {
                  'use strict';
                
                  const image = document.getElementById('crop');
                  const ratios = document.getElementById('ratios');
                Severity: Major
                Found in core/app/assets/javascripts/refinery/image_crop.js - About 3 hrs to fix

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

                        def configure!(extension)
                          ::ActiveRecord::Base.extend ::Dragonfly::Model
                          ::ActiveRecord::Base.extend ::Dragonfly::Model::Validations
                  
                          ::Dragonfly.app(extension.dragonfly_name).configure do
                  Severity: Minor
                  Found in dragonfly/lib/refinery/dragonfly/dragonfly.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

                  File crud.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  module Refinery
                    module Crud
                  
                      def self.default_options(model_name)
                        class_name = "#{model_name.to_s.camelize.gsub('/', '::')}".gsub('::::', '::')
                  Severity: Minor
                  Found in core/lib/refinery/crud.rb - About 2 hrs to fix

                    File cms_generator.rb has 258 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    require 'pathname'
                    require 'mkmf'
                    
                    module Refinery
                      class CmsGenerator < Rails::Generators::Base
                    Severity: Minor
                    Found in core/lib/generators/refinery/cms/cms_generator.rb - About 2 hrs to fix

                      Method create has a Cognitive Complexity of 16 (exceeds 5 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 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 change has 51 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def change
                          create_table :refinery_page_parts do |t|
                            t.integer  :refinery_page_id
                            t.string   :title
                            t.text     :body
                      Severity: Major
                      Found in pages/db/migrate/20100913234708_create_refinerycms_pages_schema.rb - About 2 hrs to fix

                        Method configure! has 50 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                              def configure!(extension)
                                ::ActiveRecord::Base.extend ::Dragonfly::Model
                                ::ActiveRecord::Base.extend ::Dragonfly::Model::Validations
                        
                                ::Dragonfly.app(extension.dragonfly_name).configure do
                        Severity: Minor
                        Found in dragonfly/lib/refinery/dragonfly/dragonfly.rb - About 2 hrs to fix

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

                          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 link_to has a Cognitive Complexity of 14 (exceeds 5 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

                          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 toArray has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                  toArray: function(options) {
                          
                                      var o = $.extend({}, this.options, options),
                                          sDepth = o.startDepthCount || 0,
                                          ret = [],
                          Severity: Minor
                          Found in core/app/assets/javascripts/refinery/nestedsortables.js - About 1 hr to fix

                            Function serializelist has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              $.fn.serializelist = function(options) {
                                var defaults = {
                                    attributes: ['id'],
                                    allow_nest: true,
                                    prepend: 'ul',
                            Severity: Minor
                            Found in core/app/assets/javascripts/refinery/serializelist.js - About 1 hr to fix

                              Function init has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                      , init: function(options) {
                                          if(!this.initialised){
                                              this.update_url = options.update_url;
                                              this.sortable_list = $(options.sortable_list);
                                              this.tree = options.tree;
                              Severity: Minor
                              Found in core/app/assets/javascripts/refinery/sortable_list.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language