formtastic/formtastic

View on GitHub

Showing 57 of 57 total issues

Method validation_max has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def validation_max
          validation = validations? && validations.find do |validation|
            validation.kind == :numericality
          end
          if validation
Severity: Minor
Found in lib/formtastic/inputs/base/validations.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 create_or_show has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def create_or_show
      @attributes = reflected_attributes if @attributes.empty?

      engine = options[:template_engine]

Severity: Minor
Found in lib/generators/formtastic/form/form_generator.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(builder, template, object, object_name, method, options)
Severity: Minor
Found in lib/formtastic/inputs/base.rb - About 45 mins to fix

    Consider simplifying this complex logical expression.
    Open

              return raw_collection if (raw_collection.instance_of?(Array) || raw_collection.instance_of?(Range)) &&
                                   ([Array, String].include?(raw_collection.first.class) || raw_collection.first.is_a?(Integer)) &&
                                   !(options.include?(:member_label) || options.include?(:member_value))
    Severity: Major
    Found in lib/formtastic/inputs/base/collections.rb - About 40 mins to fix

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

            def semantic_errors(*args)
              html_options = args.extract_options!
              args = args - [:base]
              full_errors = args.inject([]) do |array, method|
                attribute = localized_string(method, method.to_sym, :label) || humanized_attribute_name(method)
      Severity: Minor
      Found in lib/formtastic/helpers/errors_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 collection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def collection
                # Return if we have a plain string
                return raw_collection if raw_collection.is_a?(String)
      
                # Return if we have an Array of strings, integers or arrays
      Severity: Minor
      Found in lib/formtastic/inputs/base/collections.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 validation_limit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def validation_limit
                validation = validations? && validations.find do |validation|
                  validation.kind == :length
                end
                if validation
      Severity: Minor
      Found in lib/formtastic/inputs/base/validations.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

      Avoid too many return statements within this method.
      Open

                  return :search    if method.to_s =~ /^search$/
      Severity: Major
      Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return :select    if reflection_for(method)
        Severity: Major
        Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return :datetime_select
          Severity: Major
          Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                        return :date_select
            Severity: Major
            Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                        return :select    if column.type == :string && options.key?(:collection)
              Severity: Major
              Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return :number
                Severity: Major
                Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                              return :time_select
                  Severity: Major
                  Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return :select    if enum_for(method)
                    Severity: Major
                    Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                return :string
                      Severity: Major
                      Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                    return :email     if method.to_s =~ /email/
                        Severity: Major
                        Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return :color     if method.to_s =~ /color/
                          Severity: Major
                          Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return :time_zone if method.to_s =~ /time_zone/
                            Severity: Major
                            Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return :url       if method.to_s =~ /^url$|^website$|_url$/
                              Severity: Major
                              Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language