formtastic/formtastic

View on GitHub

Showing 57 of 57 total issues

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 :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 :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 :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 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 :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 :password  if method.to_s =~ /password/
              Severity: Major
              Found in lib/formtastic/helpers/input_helper.rb - About 30 mins to fix

                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 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 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 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 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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        def size
                          return options[:size] if options.key?(:size)
                          return options[:input_html][:size] if options[:input_html] && options[:input_html].key?(:size)
                          default_size
                Severity: Minor
                Found in lib/formtastic/inputs/base/datetime_pickerish.rb and 1 other location - About 20 mins to fix
                lib/formtastic/inputs/base/datetime_pickerish.rb on lines 46..49

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 27.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      def input_html_options_name
                        if builder.options.key?(:index)
                          "#{object_name}[#{builder.options[:index]}][#{association_primary_key}]"
                        else
                          "#{object_name}[#{association_primary_key}]"
                Severity: Minor
                Found in lib/formtastic/inputs/select_input.rb and 1 other location - About 20 mins to fix
                lib/formtastic/inputs/boolean_input.rb on lines 86..90

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 27.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                        def maxlength
                          return options[:maxlength] if options.key?(:maxlength)
                          return options[:input_html][:maxlength] if options[:input_html] && options[:input_html].key?(:maxlength)
                          default_size
                Severity: Minor
                Found in lib/formtastic/inputs/base/datetime_pickerish.rb and 1 other location - About 20 mins to fix
                lib/formtastic/inputs/base/datetime_pickerish.rb on lines 34..37

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 27.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                      def input_html_options_name
                        if builder.options.key?(:index)
                          "#{object_name}[#{builder.options[:index]}][#{method}]"
                        else
                          "#{object_name}[#{method}]"
                Severity: Minor
                Found in lib/formtastic/inputs/boolean_input.rb and 1 other location - About 20 mins to fix
                lib/formtastic/inputs/select_input.rb on lines 206..210

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 27.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language