lib/formtastic/helpers/input_helper.rb
Method default_input_type
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
Open
def default_input_type(method, options = {}) # @private
if @object
return :select if reflection_for(method)
return :file if is_file?(method, options)
- Read upRead up
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
Open
def default_input_type(method, options = {}) # @private
if @object
return :select if reflection_for(method)
return :file if is_file?(method, options)
Avoid too many return
statements within this method. Open
Open
return :phone if method.to_s =~ /(phone|fax)/
Avoid too many return
statements within this method. Open
Open
return :date_select
Avoid too many return
statements within this method. Open
Open
return :select if reflection_for(method)
Avoid too many return
statements within this method. Open
Open
return :email if method.to_s =~ /email/
Avoid too many return
statements within this method. Open
Open
return :url if method.to_s =~ /^url$|^website$|_url$/
Avoid too many return
statements within this method. Open
Open
return :select if column.type == :string && options.key?(:collection)
Avoid too many return
statements within this method. Open
Open
return column.type
Avoid too many return
statements within this method. Open
Open
return :number
Avoid too many return
statements within this method. Open
Open
return :text
Avoid too many return
statements within this method. Open
Open
return :color if method.to_s =~ /color/
Avoid too many return
statements within this method. Open
Open
return :search if method.to_s =~ /^search$/
Avoid too many return
statements within this method. Open
Open
return :number
Avoid too many return
statements within this method. Open
Open
return :time_select
Avoid too many return
statements within this method. Open
Open
return :select if options.key?(:collection)
Avoid too many return
statements within this method. Open
Open
return :time_zone if method.to_s =~ /time_zone/
Avoid too many return
statements within this method. Open
Open
return :password if method.to_s =~ /password/
Avoid too many return
statements within this method. Open
Open
return :select if enum_for(method)
Avoid too many return
statements within this method. Open
Open
return :datetime_select
Avoid too many return
statements within this method. Open
Open
return :string
Avoid too many return
statements within this method. Open
Open
return :string