x-govuk/govuk-form-builder

View on GitHub

Showing 7 of 14 total issues

File date_spec.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

describe GOVUKDesignSystemFormBuilder::FormBuilder do
  include_context 'setup builder'

  describe '#govuk_date_field' do
    let(:method) { :govuk_date_field }
Severity: Minor
Found in spec/govuk_design_system_formbuilder/builder/date_spec.rb - About 2 hrs to fix

    Method initialize has 7 arguments (exceeds 5 allowed). Consider refactoring.
    Open

            def initialize(builder, object_name, attribute_name, value, unchecked_value, label:, hint:, link_errors:, multiple:, exclusive:, **kwargs, &block)

      Method initialize has 6 arguments (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(builder, object_name, attribute_name, choices, options:, form_group:, label:, hint:, caption:, **kwargs, &block)
      Severity: Minor
      Found in lib/govuk_design_system_formbuilder/elements/select.rb - About 35 mins to fix

        Method initialize has 6 arguments (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint:, label:, caption:, form_group:, options: {}, **kwargs, &block)
        Severity: Minor
        Found in lib/govuk_design_system_formbuilder/elements/collection_select.rb - About 35 mins to fix

          Method initialize has 6 arguments (exceeds 5 allowed). Consider refactoring.
          Open

                  def initialize(builder, object_name, attribute_name, value, label:, hint:, link_errors:, **kwargs, &block)

            Method initialize has 6 arguments (exceeds 5 allowed). Consider refactoring.
            Open

                    def initialize(builder, object_name, attribute_name, collection, value_method:, text_method:, hint_method:, hint:, legend:, caption:, inline:, small:, bold_labels:, form_group:, include_hidden:, **kwargs, &block)
            Severity: Minor
            Found in lib/govuk_design_system_formbuilder/elements/radios/collection.rb - About 35 mins to fix

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

                    def presenter
                      (@presenter.is_a?(Class) ? @presenter.new(error_messages) : @presenter).tap do |p|
                        fail(ArgumentError, "error summary presenter doesn't implement #formatted_error_messages") unless
                          p.respond_to?(:formatted_error_messages)
                      end
              Severity: Minor
              Found in lib/govuk_design_system_formbuilder/elements/error_summary.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