udongo/udongo

View on GitHub

Showing 18 of 1,029 total issues

Function udongo_autocomplete has 116 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  $.fn.udongo_autocomplete = function(options) {
    var original_input = this;
    var settings = $.extend({
      minLength: 2,
      on_add: function(item) { return true; },
Severity: Major
Found in app/assets/javascripts/backend/plugins/autocomplete.js - About 4 hrs to fix

    Function udongo_tagbox has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      $.fn.udongo_tagbox = function(options) {
        var settings = $.extend({
          items: 'items-path',
          limit: null,
          minLength: 2,
    Severity: Minor
    Found in app/assets/javascripts/backend/plugins/tagbox.js - About 1 hr to fix

      Method resize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def resize(path)
              gravity = @options.key?(:gravity) ? @options[:gravity] : 'Center'
      
              img = MiniMagick::Image.open(@file)
              cols, rows = img[:dimensions]
      Severity: Minor
      Found in lib/udongo/image_manipulation/resize_to_fill.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 contextmenu_items has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        contextmenu_items: function(node) {
          return {
            make_invisible: {
              separator_before: true,
              separator_after: false,
      Severity: Minor
      Found in app/assets/javascripts/backend/tree.js - About 1 hr to fix

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

          init: function() {
            $('#content-rows .cards').sortable({
              axis: 'y',
              handle: '.card-header',
              update: sortable.update_position_listener,
        Severity: Minor
        Found in app/assets/javascripts/backend/flexible_content.js - About 1 hr to fix

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

                def url(width = nil, height = nil, options = {})
                  options[:action] = :resize_to_limit unless options.key?(:action)
          
                  if width.nil? && height.nil?
                    return "/uploads/assets/#{main_dir}/#{second_dir}/#{@asset.actual_filename}"
          Severity: Minor
          Found in lib/udongo/assets/resizer.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 address has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def address(category = nil)
                category = self.class.address_config.default unless category.present?
          
                unless self.class.address_config.allowed?(category)
                  raise "You can't select the '#{category}' address because it's not an allowed category"
          Severity: Minor
          Found in app/models/concerns/addressable.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 replace_vars has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def replace_vars(content, vars, conditionals_allowed = true, prefix: nil)
              vars.each do |key, value|
                key = "#{prefix}.#{key}" if prefix.present?
          
                if value.respond_to?(:each)
          Severity: Minor
          Found in lib/udongo/email_vars_parser.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

          Function dnd_check_callback has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            dnd_check_callback: function(operation, node, node_parent, node_position, more) {
          Severity: Minor
          Found in app/assets/javascripts/backend/tree.js - About 35 mins to fix

            Method init_values has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def init_values
                    stores.pluck(:name, :value).each do |field, value|
                      next unless @config.allowed?(field)
                      next if @config.fields[field.to_sym][:type].to_s.include?('Uploader')
                      send "#{field}=", value
            Severity: Minor
            Found in app/models/concerns/storable/collection.rb - About 35 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 resize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def resize(path)
                    gravity = @options.key?(:gravity) ? @options[:gravity] : 'Center'
                    background = @options.key?(:background) ? @options[:background] : :transparant
            
                    img = MiniMagick::Image.open(@file)
            Severity: Minor
            Found in lib/udongo/image_manipulation/resize_and_pad.rb - About 35 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 has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def update(categories, default: nil)
                    unless categories.respond_to?(:each) && categories.any?
                      raise 'Please provide an array with address categories'
                    end
            
            
            Severity: Minor
            Found in app/models/concerns/addressable/config.rb - About 35 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 object_label has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def object_label(value, locale)
                obj = Udongo::ObjectPath.remove_symbols(value)
                obj = obj.last if obj.is_a?(Array)
            
                I18n.with_locale(locale) do
            Severity: Minor
            Found in app/helpers/link_helper.rb - About 35 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 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                admin = Admin.find_by(email: params[:session][:email])
            
                if admin && admin.authenticate(params[:session][:password])
                  session[:admin_id] = admin.id
            Severity: Minor
            Found in app/controllers/backend/sessions_controller.rb - About 25 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 add_stylesheets_to_precompile_list has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def add_stylesheets_to_precompile_list(path)
                    glob_files(path) do |f|
                      filepath = f.split('stylesheets/').last
                      filename = filepath.split('.').join('.')
                      next if filename.split('/').last[0] == '_'
            Severity: Minor
            Found in lib/udongo/assets/precompiler.rb - About 25 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 parents has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def parents(instance: nil, list: [], include_self: true)
                  instance = self unless instance.present?
                  list << instance if include_self
                  instance.parent ? parents(instance: instance.parent, list: list) : list
                end
            Severity: Minor
            Found in app/models/concerns/parentable.rb - About 25 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 search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def search
                  return [] unless term.valid?
            
                  ::SearchTerm.create!(locale: controller.locale, term: term.value)
            
            
            Severity: Minor
            Found in lib/udongo/search/frontend.rb - About 25 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 save_flexible_content_search_indices! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def save_flexible_content_search_indices!
                    content_rows.each do |row|
                      row.columns.each do |column|
                        next unless column.content.is_a?(ContentText)
                        key = "flexible_content:#{column.content_id}"
            Severity: Minor
            Found in app/models/concerns/searchable.rb - About 25 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