formtastic/formtastic

View on GitHub

Showing 51 of 57 total issues

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

            Method errors has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def errors
                      errors = []
                      if object && object.respond_to?(:errors)
                        error_keys.each do |key| 
                          errors << object.errors[key] unless object.errors[key].blank?
            Severity: Minor
            Found in lib/formtastic/inputs/base/errors.rb - About 25 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 save_to_clipboard has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def save_to_clipboard(data)
                  return unless data
            
                  begin
                    case RUBY_PLATFORM
            Severity: Minor
            Found in lib/generators/formtastic/form/form_generator.rb - About 25 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 humanized_attribute_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def humanized_attribute_name(method)
                  if @object && @object.class.respond_to?(:human_attribute_name)
                    humanized_name = @object.class.human_attribute_name(method.to_s)
                    if humanized_name == method.to_s.send(:humanize)
                      method.to_s.send(label_str_method)
            Severity: Minor
            Found in lib/formtastic/html_attributes.rb - About 25 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 escape_html_entities has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def escape_html_entities(string) # @private
                  if (builder.escape_html_entities_in_hints_and_labels) ||
                     (self.respond_to?(:escape_html_entities_in_hints_and_labels) && escape_html_entities_in_hints_and_labels)
                    string = builder.template.escape_once(string) unless string.respond_to?(:html_safe?) && string.html_safe? == true # Accept html_safe flag as indicator to skip escaping
                  end
            Severity: Minor
            Found in lib/formtastic/localizer.rb - About 25 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 make_selected_values has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                  def make_selected_values
                    if object.respond_to?(method)
                      selected_items = object.send(method)
                      # Construct an array from the return value, regardless of the return type
                      selected_items = [*selected_items].compact.flatten
            Severity: Minor
            Found in lib/formtastic/inputs/check_boxes_input.rb - About 25 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_step has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

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

            Severity
            Category
            Status
            Source
            Language