Noosfero/noosfero

View on GitHub
app/helpers/forms_helper.rb

Summary

Maintainability
D
3 days
Test Coverage

Method date_field has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

  def date_field(name, value, datepicker_options = {}, html_options = {})
    datepicker_options[:disabled] ||= false
    datepicker_options[:alt_field] ||= ""
    datepicker_options[:alt_format] ||= ""
    datepicker_options[:append_text] ||= ""
Severity: Minor
Found in app/helpers/forms_helper.rb - About 7 hrs 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 date_field has 103 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def date_field(name, value, datepicker_options = {}, html_options = {})
    datepicker_options[:disabled] ||= false
    datepicker_options[:alt_field] ||= ""
    datepicker_options[:alt_format] ||= ""
    datepicker_options[:append_text] ||= ""
Severity: Major
Found in app/helpers/forms_helper.rb - About 4 hrs to fix

    File forms_helper.rb has 303 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module FormsHelper
      include ButtonsHelper
      include Entitlement::SliderHelper
    
      def labelled_radio_button(human_name, name, value, checked = false, options = {})
    Severity: Minor
    Found in app/helpers/forms_helper.rb - About 3 hrs to fix

      Method select_city has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def select_city(simple = false)
          states = State.order(:name).all
      
          state_id = "state-" + FormsHelper.next_id_number
          city_id = "city-" + FormsHelper.next_id_number
      Severity: Minor
      Found in app/helpers/forms_helper.rb - About 1 hr to fix

        Method slider_field_tag has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          def slider_field_tag(id, field_name, value, keys, labels, levels, range, html_options = {})
        Severity: Major
        Found in app/helpers/forms_helper.rb - About 1 hr to fix

          Method select_profile_folder has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            def select_profile_folder(label_text, field_id, profile, default_value = "", html_options = {}, js_options = {}, find_options = {}, extra_options = {})
          Severity: Major
          Found in app/helpers/forms_helper.rb - About 1 hr to fix

            Method labelled_select has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def labelled_select(human_name, name, value_method, text_method, selected, collection, options = {})
            Severity: Major
            Found in app/helpers/forms_helper.rb - About 50 mins to fix

              Method date_range_field has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def date_range_field(from_name, to_name, from_value, to_value, datepicker_options = {}, html_options = {})
              Severity: Minor
              Found in app/helpers/forms_helper.rb - About 45 mins to fix

                Method access_slider_field_tag has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  def access_slider_field_tag(id, field_name, profile, value = slider_levels[:self], levels = Entitlement::Levels.range_options, html_options = {})
                Severity: Minor
                Found in app/helpers/forms_helper.rb - About 45 mins to fix

                  Method select_folder has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    def select_folder(label_text, field_id, collection, default_value = nil, html_options = {}, js_options = {})
                  Severity: Minor
                  Found in app/helpers/forms_helper.rb - About 45 mins to fix

                    Method restriction_slider_field_tag has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      def restriction_slider_field_tag(id, field_name, profile, value = slider_levels[:self], levels = Entitlement::Levels.range_options, html_options = {})
                    Severity: Minor
                    Found in app/helpers/forms_helper.rb - About 45 mins to fix

                      Method labelled_radio_button has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        def labelled_radio_button(human_name, name, value, checked = false, options = {})
                      Severity: Minor
                      Found in app/helpers/forms_helper.rb - About 35 mins to fix

                        Method labelled_check_box has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          def labelled_check_box(human_name, name, value = "1", checked = false, options = {})
                        Severity: Minor
                        Found in app/helpers/forms_helper.rb - About 35 mins to fix

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

                              datepicker_options[:month_names_short] ||= [_("Jan"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"), _("Jul"), _("Aug"), _("Sep"), _("Oct"), _("Nov"), _("Dec")]
                          Severity: Minor
                          Found in app/helpers/forms_helper.rb and 1 other location - About 25 mins to fix
                          app/helpers/forms_helper.rb on lines 170..170

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

                          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

                              datepicker_options[:month_names] ||= [_("January"), _("February"), _("March"), _("April"), _("May"), _("June"), _("July"), _("August"), _("September"), _("October"), _("November"), _("December")]
                          Severity: Minor
                          Found in app/helpers/forms_helper.rb and 1 other location - About 25 mins to fix
                          app/helpers/forms_helper.rb on lines 171..171

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

                          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

                          There are no issues that match your filters.

                          Category
                          Status