formtastic/formtastic

View on GitHub
lib/formtastic/helpers/input_helper.rb

Summary

Maintainability
D
2 days
Test Coverage

Method default_input_type has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

      def default_input_type(method, options = {}) # @private
        if @object
          return :select  if reflection_for(method)

          return :file    if is_file?(method, options)
Severity: Minor
Found in lib/formtastic/helpers/input_helper.rb - About 7 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 default_input_type has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def default_input_type(method, options = {}) # @private
        if @object
          return :select  if reflection_for(method)

          return :file    if is_file?(method, options)
Severity: Minor
Found in lib/formtastic/helpers/input_helper.rb - About 1 hr to fix

    Avoid too many return statements within this method.
    Open

                return :phone     if method.to_s =~ /(phone|fax)/
    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 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 :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 :url       if method.to_s =~ /^url$|^website$|_url$/
            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 column.type
                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 :text
                    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 :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 :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 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 :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 :password  if method.to_s =~ /password/
                                  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 :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 :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 :string
                                          Severity: Major
                                          Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                                            There are no issues that match your filters.

                                            Category
                                            Status