wearefine/fae

View on GitHub

Showing 1,556 of 1,556 total issues

Method validate_each has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  def validate_each(record, attribute, value)
    raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base

    value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)

Severity: Minor
Found in lib/file_size_validator.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 set_globals has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def set_globals
      if attributes.present?
        attributes.each do |arg|
          # prevent these from being in attributes_flat or attribute_names as they are not real model generator field options
          if is_attachment(arg)
Severity: Minor
Found in lib/generators/fae/base_generator.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

Perceived complexity for filter is too high. [16/7]
Open

      def filter(params)
        # build conditions if specific params are present
        conditions = {}
        conditions[:user_id] = params['user'] if params['user'].present?
        conditions[:changeable_type] = params['model'] if params['model'].present?
Severity: Minor
Found in app/models/fae/change.rb by rubocop

This cop tries to produce a complexity score that's a measure of the complexity the reader experiences when looking at a method. For that reason it considers when nodes as something that doesn't add as much complexity as an if or a &&. Except if it's one of those special case/when constructs where there's no expression after case. Then the cop treats it as an if/elsif/elsif... and lets all the when nodes count. In contrast to the CyclomaticComplexity cop, this cop considers else nodes as adding complexity.

Example:

def my_method                   # 1
  if cond                       # 1
    case var                    # 2 (0.8 + 4 * 0.2, rounded)
    when 1 then func_one
    when 2 then func_two
    when 3 then func_three
    when 4..10 then func_other
    end
  else                          # 1
    do_something until a && b   # 2
  end                           # ===
end                             # 7 complexity points

Method has too many lines. [19/10]
Open

    def change_item_link(change)
      text = "#{change.changeable_type.gsub('Fae::','')}: "
      test_source_method = :data_source_exists?

      if change.changeable_type.exclude?('Fae') && change.changeable_type.exclude?('Page') && !ActiveRecord::Base.connection.send(test_source_method, change.changeable_type.tableize)

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for get is too high. [24.66/15]
Open

    def get(endpoint)
      begin
        uri = URI.parse(endpoint)
        request = Net::HTTP::Get.new(uri)
        set_headers(request)
Severity: Minor
Found in app/services/fae/netlify_api.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Function multiselectChosenActions has 67 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  multiselectChosenActions: function() {
    var query_input_select = '.input.select';
    // Ignore select elements with .multiselect classes, because these are used for a different widget
    var query_eligible_multiselects = query_input_select + ' select[multiple]:not(.multiselect)';
    var select_all_value = 'multiselect_action-select_all';
Severity: Major
Found in app/assets/javascripts/fae/form/inputs/_select.js - About 2 hrs to fix

    Assignment Branch Condition size for update_parent is too high. [23.96/15]
    Open

        def update_parent
          parent = self.try(:imageable) || self.try(:fileable) || self.try(:contentable)
          if parent.present?
            latest_change = parent.try(:tracked_changes).try(:first)
            if latest_change.present? && latest_change.change_type == 'updated' && latest_change.updated_at > 2.seconds.ago

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for clone_has_many_relationships is too high. [23.22/15]
    Open

        def clone_has_many_relationships(association)
          if @item.send(association).present?
            @item.send(association).reverse.each do |record|
              new_record = association.to_s.classify.constantize.find_by_id(record.id).dup
              new_record.send("#{@klass_singular}_id" + '=', @cloned_item.id) if new_record.send("#{@klass_singular}_id").present?

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Assignment Branch Condition size for setup_dynamic_singleton is too high. [22.2/15]
    Open

        def self.setup_dynamic_singleton
          return if @singleton_is_setup
    
          fae_fields.each do |name, value|
            type = value.is_a?(Hash) ? value[:type] : value
    Severity: Minor
    Found in app/models/fae/static_page.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [17/10]
    Open

        def self.setup_dynamic_singleton
          return if @singleton_is_setup
    
          fae_fields.each do |name, value|
            type = value.is_a?(Hash) ? value[:type] : value
    Severity: Minor
    Found in app/models/fae/static_page.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for fae_filter_form is too high. [22.41/15]
    Open

        def fae_filter_form(options = {}, &block)
          options = prepare_options_for_filter_form options
          return if options[:collection].blank?
    
          form_tag(options[:action], prepare_form_filter_hash(options)) do
    Severity: Minor
    Found in app/helpers/fae/view_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [17/10]
    Open

      def validate_each(record, attribute, value)
        raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
    
        value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
    
    
    Severity: Minor
    Found in lib/file_size_validator.rb by rubocop

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Method has too many lines. [16/10]
    Open

        def update_parent
          parent = self.try(:imageable) || self.try(:fileable) || self.try(:contentable)
          if parent.present?
            latest_change = parent.try(:tracked_changes).try(:first)
            if latest_change.present? && latest_change.change_type == 'updated' && latest_change.updated_at > 2.seconds.ago

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for update is too high. [21.31/15]
    Open

        def update
          if params[:form_manager].present?
            fields_serialized = params[:form_manager][:fields].to_json
            conditions = {
              form_manager_model_name: params[:form_manager][:form_manager_model_name],

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [16/10]
    Open

        def td_columns(params)
          attribute = params[:col]
          attributes = params[:cols]
          item = params[:item]
    
    

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for authorize_model is too high. [21.1/15]
    Open

        def authorize_model(model)
          return false if current_user.blank? || current_user.role.blank? || current_user.role.name.blank?
    
          users_role           = current_user.role.name.downcase
          tableized_model      = model.name.tableize

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [15/10]
    Open

        def add_update_change
          if has_parent?
            update_parent
          else
            return if legit_updated_attributes.blank?

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Function _setupField has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

      _setupField: function($container, overriddenLabel, overriddenHelper) {
        var _this = this;
        if ($container.length) {
          var $label                 = $container.find('label:first');
          var $helperTextContainerEl = $container.find('h6');
    Severity: Minor
    Found in app/assets/javascripts/fae/form/_form_manager.js - 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 clone_has_one_relationship has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def clone_has_one_relationship(association,type)
          old_record = @item.send(association)
    
          if old_record.present?
            new_record = old_record.dup
    Severity: Minor
    Found in app/controllers/concerns/fae/cloneable.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

    Assignment Branch Condition size for language_support is too high. [20.27/15]
    Open

        def language_support(f, attribute, options)
          return if Fae.languages.blank?
    
          attribute_array = attribute.to_s.split('_')
          language_suffix = attribute_array.pop
    Severity: Minor
    Found in app/helpers/fae/form_helper.rb by rubocop

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Severity
    Category
    Status
    Source
    Language