rapidftr/RapidFTR

View on GitHub

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

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

            $('.criteria-list .criteria-value-select').each(function(){
                if(special_char.test($(this).val()) || white_space.test($(this).val())) { result = I18n.t("messages.enter_valid_field_value"); }
            });
    Severity: Major
    Found in app/assets/javascripts/advanced_search.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/advanced_search.js on lines 170..173

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

    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

            $('.criteria-list .criteria-value-text').each(function(){
    
                if(special_char.test($(this).val()) || white_space.test($(this).val())) { result = I18n.t("messages.enter_valid_field_value"); }
            });
    Severity: Major
    Found in app/assets/javascripts/advanced_search.js and 1 other location - About 2 hrs to fix
    app/assets/javascripts/advanced_search.js on lines 174..176

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

    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

    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

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

                  .success(function() {
                      tds.parent().css('background-color', "#87A96B");
                      tds.animate({opacity: 0.3}, 300).animate({opacity: 1}, 300, "swing", function() {
                          tds.parent().css('background-color', "transparent");
                          });
      Severity: Major
      Found in app/assets/javascripts/form_section.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/form_section.js on lines 53..58

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

      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

          rotateClockwise: function(event) {
              RapidFTR.childPhotoRotation.childPicture().rotateRight(90, 'rel');
              self.photoOrientation.val((parseInt(self.photoOrientation.val()) + 90) % 360);
              event.preventDefault();
          },
      Severity: Major
      Found in app/assets/javascripts/rapidftr.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/rapidftr.js on lines 102..106

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

      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

                  .success(function(data) {
                      td.parent().css('background-color', "#87A96B");
                      td.animate({opacity: 0.7}, 300).animate({opacity: 1}, 300, "swing", function() {
                          td.parent().css('background-color', "transparent");
                      });
      Severity: Major
      Found in app/assets/javascripts/form_section.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/form_section.js on lines 23..28

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

      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

          rotateAntiClockwise: function(event) {
              RapidFTR.childPhotoRotation.childPicture().rotateLeft(90, 'rel');
              self.photoOrientation.val((parseInt(self.photoOrientation.val()) - 90) % 360);
              event.preventDefault();
          },
      Severity: Major
      Found in app/assets/javascripts/rapidftr.js and 1 other location - About 2 hrs to fix
      app/assets/javascripts/rapidftr.js on lines 96..100

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

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

                Severity
                Category
                Status
                Source
                Language