wearefine/fae

View on GitHub

Showing 1,556 of 1,556 total issues

Assignment Branch Condition size for page_title_piece is too high. [20.83/15]
Open

    def page_title_piece
      return @page_title_piece if @page_title_piece.present?

      action = params[:action].humanize.titleize unless params[:action] == 'index'
      controller = controller_title unless params[:controller] == 'fae/pages'

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 clone_has_one_relationship(association,type)
      old_record = @item.send(association)

      if old_record.present?
        new_record = old_record.dup

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.

Cyclomatic complexity for label_and_hint is too high. [11/6]
Open

    def label_and_hint(attribute, options)
      hint = options[:hint]

      options[:helper_text] = attempt_common_helper_text(attribute) if options[:helper_text].blank?

Severity: Minor
Found in app/helpers/fae/form_helper.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Assignment Branch Condition size for create is too high. [20.32/15]
Open

    def create
      return create_from_existing(params[:from_existing]) if params[:from_existing].present?

      @item = @klass.new(item_params)

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 sort is too high. [20.42/15]
Open

    def sort
      if request.xhr?
        ids = params[params[:object]]
        klass = params[:object].gsub('fae_', 'fae/').gsub('__', '/').classify.constantize
        items = klass.find(ids)

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

deploy has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

Fae.deploy = {

  ready: function() {
    if (!$('body').hasClass('deploy')) return false;
    this.$deployButtons  = $('.js-run-deploy');
Severity: Minor
Found in app/assets/javascripts/fae/_deploy.js - About 2 hrs to fix

    Class BaseGenerator has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class BaseGenerator < Rails::Generators::NamedBase
        source_root ::File.expand_path('../templates', __FILE__)
        argument :attributes, type: :array, default: [], banner: "field[:type][:index] field[:type][:index]"
        class_option :namespace, type: :string, default: 'admin', desc: 'Sets the namespace of the generator'
        class_option :template, type: :string, default: 'slim', desc: 'Sets the template engine of the generator'
    Severity: Minor
    Found in lib/generators/fae/base_generator.rb - About 2 hrs to fix

      Cyclomatic complexity for fae_pulldown is too high. [10/6]
      Open

          def fae_pulldown(f, attribute, options={})
            raise "Fae::MissingRequiredOption: fae_pulldown requires a 'collection' when using it on an ActiveRecord attribute." if !options.has_key?(:collection) && f.object.attribute_names.include?(attribute.to_s)
            raise "Fae::ImproperOptionValue: The value #{options[:size]} is not a valid option for 'size'. Please use 'short' or 'long'." if options[:size].present? && ['short','long'].include?(options[:size]) == false
            raise "Fae::ImproperOptionValue: The value #{options[:search]} is not a valid option for 'search'. Please use a Boolean." if options[:search].present? && !!options[:search] != options[:search]
      
      
      Severity: Minor
      Found in app/helpers/fae/form_helper.rb by rubocop

      This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

      An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

      Perceived complexity for label_and_hint is too high. [11/7]
      Open

          def label_and_hint(attribute, options)
            hint = options[:hint]
      
            options[:helper_text] = attempt_common_helper_text(attribute) if options[:helper_text].blank?
      
      
      Severity: Minor
      Found in app/helpers/fae/form_helper.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

      Assignment Branch Condition size for col_name_or_image is too high. [19.34/15]
      Open

          def col_name_or_image(item, attribute)
            value = item.send(attribute)
            return if value.blank?
            # if item is an image
            if value.class.name == 'Fae::Image'

      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. [14/10]
      Open

          def graphql_type(type)
            case type.to_s
            when 'integer'
              'Integer'
            when 'boolean'

      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. [14/10]
      Open

        def change
          create_table(:fae_images) do |t|
            t.string :name
            t.string :asset
            t.references :imageable, polymorphic: true, index: true

      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 applyCookies has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

        applyCookies: function() {
          var cookie_key = $('.js-filter-form').attr('data-cookie-key');
      
          if (cookie_key) {
            var cookie = Cookies.getJSON(cookie_key);
      Severity: Minor
      Found in app/assets/javascripts/fae/form/_filtering.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

      Function htmlListeners has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        htmlListeners: function() {
          $('#js-main-content, .login-form > form, #simplemodal-data')
      
            /**
             * For the delete button on file input
      Severity: Major
      Found in app/assets/javascripts/fae/form/_ajax.js - About 2 hrs to fix

        File _tables.js has 251 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /* global Fae, FCH, Cookies */
        
        /**
         * Fae tables
         * @namespace tables
        Severity: Minor
        Found in app/assets/javascripts/fae/_tables.js - About 2 hrs to fix

          Assignment Branch Condition size for fae_sort is too high. [18.28/15]
          Open

                def fae_sort(params)
                  return all unless params.present? && params[:sort_by].present?
          
                  attr_parts = params[:sort_by].split('.')
          
          
          Severity: Minor
          Found in app/models/concerns/fae/sortable.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

          Assignment Branch Condition size for index is too high. [18.14/15]
          Open

              def index
                if use_pagination
                  @items = @klass.for_fae_index.page(params[:page])
                else
                  @items = @klass.for_fae_index

          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 fae_multiselect is too high. [18.44/15]
          Open

              def fae_multiselect(f, attribute, options={})
                raise "Fae::'#{attribute}' must be an association of #{f.object}" if !is_association?(f, attribute)
                raise "Fae::ImproperOptionValue: The value '#{options[:two_pane]}' is not a valid option for 'two_pane'. Please use a Boolean." if options[:two_pane].present? && !!options[:two_pane] != options[:two_pane]
          
                options.update(input_class: "#{options[:input_class]} multiselect") if options[:two_pane] == true
          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

          Perceived complexity for td_columns is too high. [10/7]
          Open

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

          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

          Assignment Branch Condition size for set_maxlength is too high. [18.17/15]
          Open

              def set_maxlength(f, attribute, options)
                column = f.object.class.columns_hash[attribute.to_s]
                if column.present? && (column.sql_type.include?('varchar') || column.sql_type == 'text')
                  # Rails 4.1 supports column.limit, 4.2 supports column.cast_type.limit
                  limit = column.try(:limit) || column.try(:cast_type).try(:limit)
          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