refinery/refinerycms

View on GitHub

Showing 72 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

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

                        if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
                            this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
                        else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
                            this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
    Severity: Major
    Found in core/app/assets/javascripts/refinery/nestedsortables.js and 1 other location - About 6 hrs to fix
    core/app/assets/javascripts/refinery/nestedsortables.js on lines 69..72

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

    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

                        if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
                            this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
                        else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
                            this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
    Severity: Major
    Found in core/app/assets/javascripts/refinery/nestedsortables.js and 1 other location - About 6 hrs to fix
    core/app/assets/javascripts/refinery/nestedsortables.js on lines 64..67

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

    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

                        if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
                            scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
                        else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
                            scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
    Severity: Major
    Found in core/app/assets/javascripts/refinery/nestedsortables.js and 1 other location - About 5 hrs to fix
    core/app/assets/javascripts/refinery/nestedsortables.js on lines 81..84

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

    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

                        if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
                            scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
                        else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
                            scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
    Severity: Major
    Found in core/app/assets/javascripts/refinery/nestedsortables.js and 1 other location - About 5 hrs to fix
    core/app/assets/javascripts/refinery/nestedsortables.js on lines 76..79

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

    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

    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

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

                  if (nextItem != null) {
                    while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) {
                      if (nextItem[0].nextSibling) {
                        nextItem = $(nextItem[0].nextSibling);
                      } else {
            Severity: Major
            Found in core/app/assets/javascripts/refinery/nestedsortables.js and 1 other location - About 4 hrs to fix
            core/app/assets/javascripts/refinery/nestedsortables.js on lines 144..153

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

            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

                        if (previousItem != null) {
                            while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) {
                                if (previousItem[0].previousSibling) {
                                    previousItem = $(previousItem[0].previousSibling);
                                } else {
            Severity: Major
            Found in core/app/assets/javascripts/refinery/nestedsortables.js and 1 other location - About 4 hrs to fix
            core/app/assets/javascripts/refinery/nestedsortables.js on lines 157..166

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

            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 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
                        Severity
                        Category
                        Status
                        Source
                        Language