artirix/browsercms

View on GitHub

Showing 119 of 119 total issues

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

  config.wrappers :append, tag: 'div', class: "control-group", error_class: 'error' do |b|
    b.use :html5
    b.use :placeholder
    b.use :label
    b.wrapper tag: 'div', class: 'input-append' do |append|
Severity: Major
Found in lib/cms/configure_simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
lib/cms/configure_simple_form_bootstrap.rb on lines 31..40

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

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

  config.wrappers :prepend, tag: 'div', class: "control-group", error_class: 'error' do |b|
    b.use :html5
    b.use :placeholder
    b.use :label
    b.wrapper tag: 'div', class: 'input-prepend' do |prepend|
Severity: Major
Found in lib/cms/configure_simple_form_bootstrap.rb and 1 other location - About 1 hr to fix
lib/cms/configure_simple_form_bootstrap.rb on lines 42..51

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

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

Method publish! has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def publish!
          did_publish = false
          if new_record?
            ActiveSupport::Deprecation.warn "Calling .publish! on a new record no longer saves the record. Call '.save' to persist and publish the record.", caller
          else
Severity: Minor
Found in lib/cms/behaviors/publishing.rb - About 1 hr to fix

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

        def update
          content_block = Content.find_draft(params[:content_name], params[:id])
          content_block.update_attributes(filtered_content(content_block))
          @page = Page.find_draft(params[:page_id].to_i)
          if (!@page.live?)
    Severity: Minor
    Found in app/controllers/cms/inline_content_controller.rb - About 1 hr to fix

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

          init:function (editor) {
              editor.ui.addButton('DeleteContent', {
                  label:'Remove this content from the page (It will remain in Content Library)',
                  command:'deleteContent',
                  toolbar:'tools'
      Severity: Minor
      Found in app/assets/javascripts/ckeditor/plugins/delete_content/plugin.js - About 1 hr to fix

        Function saveChanges has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            saveChanges: function(currentEditor, afterSave) {
              var block_id = currentEditor.name;
              var block = $("#" + block_id);
              var attribute = block.data('attribute');
              var content_name = block.data('content-name');
        Severity: Minor
        Found in app/assets/javascripts/cms/page_editor.js - About 1 hr to fix

          Method is_versioned has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  def is_versioned(options={})
                    @is_versioned = true
          
                    @version_table_name = (options[:version_table_name] || "#{table_name.singularize}_versions").to_s
          
          
          Severity: Minor
          Found in lib/cms/behaviors/versioning.rb - About 1 hr to fix

            Method acts_as_content_block has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                    def acts_as_content_block(options={})
                      defaults = {
                          # Set default values here.
                          allow_attachments: true,
                          content_module: true,
            Severity: Minor
            Found in lib/cms/acts/content_block.rb - About 1 hr to fix

              Method input has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def input(_wrapper_options = nil)
                  # New blocks will not have their attachments created yet.
                  object.ensure_attachment_exists if object.respond_to?(:ensure_attachment_exists)
              
                  # Need to explictly use correct id (i.e. image_block_file) rather than the autogenerated one (i.e. image_block_attachments_attributes_0_attachment_name)
              Severity: Minor
              Found in app/inputs/file_picker_input.rb - About 1 hr to fix

                Method inherited has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    def self.inherited(subclass)
                      super if defined? super
                    ensure
                      subclass.class_eval do
                        extend Cms::PolymorphicSingleTableInheritance
                Severity: Minor
                Found in app/models/cms/portlet.rb - About 1 hr to fix

                  Method copy_connectors has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def copy_connectors(options={})
                      logger.debug { "Copying connectors from Page #{id} v#{options[:from_version_number]} to v#{options[:to_version_number]}." }
                  
                      c_found = connectors.for_page_version(options[:from_version_number]).order("#{Cms::Connector.table_name}.container, #{Cms::Connector.table_name}.position").to_a
                      logger.debug { "Found connectors #{c_found}" }
                  Severity: Minor
                  Found in app/models/cms/page.rb - About 1 hr to fix

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

                        def index
                          @have_external_users = Cms::ExternalUser.count > 0
                    
                          query, conditions = [], []
                    
                    
                    Severity: Minor
                    Found in app/controllers/cms/users_controller.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 update_connected_pages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def update_connected_pages
                              # If this is versioned, then we need make new versions of all the pages this is connected to
                              if self.class.versioned?
                                #logger.info "..... Updating connected pages for #{self.class} #{id} v#{version}"
                    
                    
                    Severity: Minor
                    Found in lib/cms/behaviors/connecting.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

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

                      config.wrappers :bootstrap, tag: 'div', class: 'control-group row-fluid', error_class: 'error' do |b|
                        b.use :html5
                        b.use :placeholder
                        b.use :label
                        b.use :input
                    Severity: Minor
                    Found in lib/cms/configure_simple_form_bootstrap.rb and 1 other location - About 55 mins to fix
                    lib/cms/configure_simple_form_bootstrap.rb on lines 12..19

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

                    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

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

                      def move_connector(connector, direction)
                        transaction do
                          raise "Connector is nil" unless connector
                          raise "Direction is nil" unless direction
                          orientation = direction[/_/] ? "#{direction.sub('_', ' the ')} of" : "#{direction} within"
                    Severity: Minor
                    Found in app/models/cms/page.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 assign_parent_if_needed has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def assign_parent_if_needed
                            unless parent || parent_id
                              new_parent = Cms::Section.with_path(self.class.path).first
                    
                              unless new_parent
                    Severity: Minor
                    Found in lib/cms/concerns/can_be_addressable.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 render_portlet has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def render_portlet(name)
                          portlets = Portlet.all(:conditions => ["name = ?", name.to_s])
                          if portlets.size > 1
                            edit_mode? ? "ERROR: Multiple Portlets with name '#{name}'" : nil
                          elsif portlets.empty?
                    Severity: Minor
                    Found in app/helpers/cms/page_helper.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

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

                      config.wrappers :browsercms, tag: 'div', class: 'control-group row-fluid', error_class: 'error' do |b|
                        b.use :html5
                        b.use :placeholder
                        b.use :label
                        b.use :input
                    Severity: Minor
                    Found in lib/cms/configure_simple_form_bootstrap.rb and 1 other location - About 55 mins to fix
                    lib/cms/configure_simple_form_bootstrap.rb on lines 3..10

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

                    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

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

                      def self.set_template(args)
                        if args.include?("-m")
                          index = args.index("-m")
                          if args[index + 1] == "demo"
                            args[index + 1] = template("demo.rb")
                    Severity: Minor
                    Found in lib/command_line.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 menu_button has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def menu_button(label, path, options={})
                          return '' unless path.present?
                    
                          defaults = {
                              enabled: true,
                    Severity: Minor
                    Found in app/helpers/cms/ui_elements_helper.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

                    Severity
                    Category
                    Status
                    Source
                    Language