x-govuk/govuk-form-builder

View on GitHub

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

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

                    def initialize(builder, object_name, attribute_name, hint:, legend:, caption:, inline:, small:, form_group:, **kwargs, &block)
                      fail LocalJumpError, 'no block given' unless block_given?
              
                      super(builder, object_name, attribute_name, &block)
              
              
              lib/govuk_design_system_formbuilder/containers/check_boxes_fieldset.rb on lines 7..18

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

              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 initialize(builder, object_name, attribute_name, hint:, legend:, caption:, small:, form_group:, multiple:, **kwargs, &block)
                      fail LocalJumpError, 'no block given' unless block_given?
              
                      super(builder, object_name, attribute_name, &block)
              
              
              lib/govuk_design_system_formbuilder/containers/radio_buttons_fieldset.rb on lines 7..18

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

              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

              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

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

                module Elements
                  module Inputs
                    class Number < Base
                      include Traits::Input
                      include Traits::Error
              Severity: Minor
              Found in lib/govuk_design_system_formbuilder/elements/inputs/number.rb and 4 other locations - About 15 mins to fix
              lib/govuk_design_system_formbuilder/elements/inputs/email.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/phone.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/text.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/url.rb on lines 2..15

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

              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 5 locations. Consider refactoring.
              Open

                module Elements
                  module Inputs
                    class Phone < Base
                      include Traits::Input
                      include Traits::Error
              Severity: Minor
              Found in lib/govuk_design_system_formbuilder/elements/inputs/phone.rb and 4 other locations - About 15 mins to fix
              lib/govuk_design_system_formbuilder/elements/inputs/email.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/number.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/text.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/url.rb on lines 2..15

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

              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 5 locations. Consider refactoring.
              Open

                module Elements
                  module Inputs
                    class Email < Base
                      include Traits::Input
                      include Traits::Error
              Severity: Minor
              Found in lib/govuk_design_system_formbuilder/elements/inputs/email.rb and 4 other locations - About 15 mins to fix
              lib/govuk_design_system_formbuilder/elements/inputs/number.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/phone.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/text.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/url.rb on lines 2..15

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

              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 5 locations. Consider refactoring.
              Open

                module Elements
                  module Inputs
                    class URL < Base
                      include Traits::Input
                      include Traits::Error
              Severity: Minor
              Found in lib/govuk_design_system_formbuilder/elements/inputs/url.rb and 4 other locations - About 15 mins to fix
              lib/govuk_design_system_formbuilder/elements/inputs/email.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/number.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/phone.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/text.rb on lines 2..15

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

              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 5 locations. Consider refactoring.
              Open

                module Elements
                  module Inputs
                    class Text < Base
                      include Traits::Input
                      include Traits::Error
              Severity: Minor
              Found in lib/govuk_design_system_formbuilder/elements/inputs/text.rb and 4 other locations - About 15 mins to fix
              lib/govuk_design_system_formbuilder/elements/inputs/email.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/number.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/phone.rb on lines 2..15
              lib/govuk_design_system_formbuilder/elements/inputs/url.rb on lines 2..15

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

              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