rapidftr/RapidFTR

View on GitHub

Showing 85 of 110 total issues

Method build_family_details_section has 62 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def self.build_family_details_section
      family_details_fields = [
        Field.new('name' => '3_father_first_name',
                  'type' => 'text_field',
                  'display_name_all' => 'Child\'s Father - First Name',
Severity: Major
Found in lib/rapid_ftr/enquiries_form_section_setup.rb - About 2 hrs to fix

    Function PasswordPrompt has 59 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    RapidFTR.PasswordPrompt = (function() {
        var passwordDialog = null, targetEl = null, passwordEl = null;
    
        return {
            initialize: function() {
    Severity: Major
    Found in app/assets/javascripts/rapidftr.js - About 2 hrs to fix

      Method build_current_arrangements_section has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.build_current_arrangements_section
            current_arrangements_fields = [
              Field.new('name' => 'care_arrangements',
                        'type' => 'select_box',
                        'display_name_all' => 'Current Care Arrangements',
      Severity: Major
      Found in lib/rapid_ftr/children_form_section_setup.rb - About 2 hrs to fix

        File rapidftr.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        var RapidFTR = {};
        
        RapidFTR.maintabControl = function(){
            var currentURL = window.location.href;
            var module = currentURL.split("/");
        Severity: Minor
        Found in app/assets/javascripts/rapidftr.js - About 2 hrs to fix

          Method update has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            def update
              respond_to do |format|
                format.json do
                  params[:child] = JSON.parse(params[:child]) if params[:child].is_a?(String)
                  child = update_child_from params
          Severity: Minor
          Found in app/controllers/children_controller.rb - About 1 hr 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 update_photo_keys has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def update_photo_keys
              return if @new_photo_keys.blank? && @deleted_photo_keys.blank?
              self['photo_keys'].concat(@new_photo_keys).uniq! if @new_photo_keys
              @deleted_photo_keys.each do |p|
                self['photo_keys'].delete p
          Severity: Minor
          Found in app/helpers/photo_helper.rb - About 1 hr 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 index has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def index
              authorize! :index, Child
          
              @page_name = t('home.view_records')
              @aside = 'shared/sidebar_links'
          Severity: Minor
          Found in app/controllers/children_controller.rb - About 1 hr 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 search has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def search
              @search_type = params[:search_type].nil? ? Child : params[:search_type].safe_constantize
          
              allowed_search_types = [Child]
              allowed_search_types << Enquiry if Enquiry.enquiries_enabled?
          Severity: Minor
          Found in app/controllers/search_controller.rb - About 1 hr 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

          Function PasswordPrompt has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

          RapidFTR.PasswordPrompt = (function() {
              var passwordDialog = null, targetEl = null, passwordEl = null;
          
              return {
                  initialize: function() {
          Severity: Minor
          Found in app/assets/javascripts/rapidftr.js - About 1 hr 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 update_properties has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            def update_properties(properties, user_name)
              properties['histories'] = remove_newly_created_media_history(properties['histories'])
              should_update = self['last_updated_at'] && properties['last_updated_at'] ? (DateTime.parse(properties['last_updated_at']) > DateTime.parse(self['last_updated_at'])) : true
              if should_update
                attributes_to_update = {}
          Severity: Minor
          Found in app/helpers/record_helper.rb - About 1 hr 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 build_separation_history_section has 38 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def self.build_separation_history_section
                separation_history_fields = [
                  Field.new('name' => 'separation_place',
                            'display_name_all' => 'Place of Separation.',
                            'matchable' => true,
          Severity: Minor
          Found in lib/rapid_ftr/children_form_section_setup.rb - About 1 hr to fix

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

                def self.build_other_interviews_section
                  other_interviews_fields = [
                    Field.new('name' => 'other_org_interview_status',
                              'type' => 'select_box',
                              'display_name_all' => 'Has the child been interviewed by another organization?',
            Severity: Minor
            Found in lib/rapid_ftr/children_form_section_setup.rb - About 1 hr to fix

              Method build_separation_history_section has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  def self.build_separation_history_section
                    separation_history_fields = [
                      Field.new('name' => '4_permanent_address',
                                'type' => 'text_field',
                                'display_name_all' => 'Permanent address prior to separation',
              Severity: Minor
              Found in lib/rapid_ftr/enquiries_form_section_setup.rb - About 1 hr to fix

                Method mark_or_unmark_as_reunited has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  def mark_or_unmark_as_reunited(reunited)
                    without_updating_matches do
                      Enquiry.skip_callback(:save, :after, :find_matching_children)
                      self['reunited'] = reunited
                      save!
                Severity: Minor
                Found in app/models/enquiry.rb - About 1 hr 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 execute_search has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    def execute_search
                      search = Search.for(Child)
                
                      @criteria.each do |criterion|
                        search.fulltext_by [criterion[:field]], criterion[:value]
                Severity: Minor
                Found in app/models/forms/search_form.rb - About 1 hr 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 return_partial_hash has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def return_partial_hash(change, field, history, model = nil)
                    if field == 'photo_keys'
                      return {:partial => 'shared/histories/photo_history_change',
                              :locals => {
                                :new_photos => change['added'],
                Severity: Minor
                Found in app/helpers/histories_helper.rb - About 1 hr to fix

                  Method to_csv has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                    def to_csv
                      fields = metadata_fields([], CHILD_IDENTIFIERS) + FormSection.all_visible_child_fields_for_form(model_class::FORM_NAME)
                      field_names = fields.map { |field| field.display_name }
                      csv_data = CSV.generate do |rows|
                        rows << field_names + CHILD_STATUS + metadata_fields([], CHILD_METADATA).map { |field| field.display_name }
                  Severity: Minor
                  Found in lib/export_generator.rb - About 1 hr 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

                  Function start has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  IdleSessionTimeout.start = function() {
                      var dialog_buttons = {};
                      dialog_buttons[I18n.t("messages.keep_working")] = function () {$(this).dialog('close');};
                      dialog_buttons[I18n.t("cancel")] = function () {$.idleTimeout.options.onTimeout.call(this);};
                      $("#dialog").dialog({
                  Severity: Minor
                  Found in app/assets/javascripts/session_timeout.js - About 1 hr to fix

                    Method index has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def index
                        authorize! :index, Child
                    
                        @page_name = t('home.view_records')
                        @aside = 'shared/sidebar_links'
                    Severity: Minor
                    Found in app/controllers/children_controller.rb - About 1 hr to fix

                      Method initialize_child_permissions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def initialize_child_permissions(user)
                          if user.has_permission?(Permission::CHILDREN[:register])
                            can [:create], Child
                            can [:read], Child do |child|
                              child.created_by == user.user_name
                      Severity: Minor
                      Found in app/models/ability.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language