robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

Method get_data has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_data
    events = []
    event_list = Osm::Event.get_list(user.osm_api, section_id)
    event_list.reject!{ |e| e[:archived] }
    event_list.each do |event|
Severity: Minor
Found in app/models/email_reminder_item_event.rb - About 1 hr to fix

    Method get_balanced_term_data has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def get_balanced_term_data(user, section=Osm::Section.get(user.osm_api, section_id))
        zones = {:number => {}, :time => {}}
        methods = {:number => {}, :time => {}}
    
        meetings = Osm::Meeting.get_for_section(user.osm_api, section_id, term_id, {:no_cache => true})
    Severity: Minor
    Found in app/models/programme_review_balanced_cache.rb - About 1 hr to fix

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

        data_table.addRow([ 'Mon', data[0][1], data[1][1]['subscribed'], data[1][1]['unsubscribed'], data[1][1]['pending'] ]);
      Severity: Major
      Found in app/assets/javascripts/statistics/email_reminders.js and 6 other locations - About 1 hr to fix
      app/assets/javascripts/statistics/email_reminders.js on lines 117..117
      app/assets/javascripts/statistics/email_reminders.js on lines 118..118
      app/assets/javascripts/statistics/email_reminders.js on lines 119..119
      app/assets/javascripts/statistics/email_reminders.js on lines 120..120
      app/assets/javascripts/statistics/email_reminders.js on lines 121..121
      app/assets/javascripts/statistics/email_reminders.js on lines 122..122

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

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

        data_table.addRow([ 'Thu', data[0][4], data[1][4]['subscribed'], data[1][4]['unsubscribed'], data[1][4]['pending'] ]);
      Severity: Major
      Found in app/assets/javascripts/statistics/email_reminders.js and 6 other locations - About 1 hr to fix
      app/assets/javascripts/statistics/email_reminders.js on lines 116..116
      app/assets/javascripts/statistics/email_reminders.js on lines 117..117
      app/assets/javascripts/statistics/email_reminders.js on lines 118..118
      app/assets/javascripts/statistics/email_reminders.js on lines 120..120
      app/assets/javascripts/statistics/email_reminders.js on lines 121..121
      app/assets/javascripts/statistics/email_reminders.js on lines 122..122

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

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

        data_table.addRow([ 'Fri', data[0][5], data[1][5]['subscribed'], data[1][5]['unsubscribed'], data[1][5]['pending'] ]);
      Severity: Major
      Found in app/assets/javascripts/statistics/email_reminders.js and 6 other locations - About 1 hr to fix
      app/assets/javascripts/statistics/email_reminders.js on lines 116..116
      app/assets/javascripts/statistics/email_reminders.js on lines 117..117
      app/assets/javascripts/statistics/email_reminders.js on lines 118..118
      app/assets/javascripts/statistics/email_reminders.js on lines 119..119
      app/assets/javascripts/statistics/email_reminders.js on lines 121..121
      app/assets/javascripts/statistics/email_reminders.js on lines 122..122

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

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

        data_table.addRow([ 'Tue', data[0][2], data[1][2]['subscribed'], data[1][2]['unsubscribed'], data[1][2]['pending'] ]);
      Severity: Major
      Found in app/assets/javascripts/statistics/email_reminders.js and 6 other locations - About 1 hr to fix
      app/assets/javascripts/statistics/email_reminders.js on lines 116..116
      app/assets/javascripts/statistics/email_reminders.js on lines 118..118
      app/assets/javascripts/statistics/email_reminders.js on lines 119..119
      app/assets/javascripts/statistics/email_reminders.js on lines 120..120
      app/assets/javascripts/statistics/email_reminders.js on lines 121..121
      app/assets/javascripts/statistics/email_reminders.js on lines 122..122

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

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

        data_table.addRow([ 'Sat', data[0][6], data[1][6]['subscribed'], data[1][6]['unsubscribed'], data[1][6]['pending'] ]);
      Severity: Major
      Found in app/assets/javascripts/statistics/email_reminders.js and 6 other locations - About 1 hr to fix
      app/assets/javascripts/statistics/email_reminders.js on lines 116..116
      app/assets/javascripts/statistics/email_reminders.js on lines 117..117
      app/assets/javascripts/statistics/email_reminders.js on lines 118..118
      app/assets/javascripts/statistics/email_reminders.js on lines 119..119
      app/assets/javascripts/statistics/email_reminders.js on lines 120..120
      app/assets/javascripts/statistics/email_reminders.js on lines 122..122

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

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

        data_table.addRow([ 'Sun', data[0][0], data[1][0]['subscribed'], data[1][0]['unsubscribed'], data[1][0]['pending'] ]);
      Severity: Major
      Found in app/assets/javascripts/statistics/email_reminders.js and 6 other locations - About 1 hr to fix
      app/assets/javascripts/statistics/email_reminders.js on lines 116..116
      app/assets/javascripts/statistics/email_reminders.js on lines 117..117
      app/assets/javascripts/statistics/email_reminders.js on lines 118..118
      app/assets/javascripts/statistics/email_reminders.js on lines 119..119
      app/assets/javascripts/statistics/email_reminders.js on lines 120..120
      app/assets/javascripts/statistics/email_reminders.js on lines 121..121

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

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

        data_table.addRow([ 'Wed', data[0][3], data[1][3]['subscribed'], data[1][3]['unsubscribed'], data[1][3]['pending'] ]);
      Severity: Major
      Found in app/assets/javascripts/statistics/email_reminders.js and 6 other locations - About 1 hr to fix
      app/assets/javascripts/statistics/email_reminders.js on lines 116..116
      app/assets/javascripts/statistics/email_reminders.js on lines 117..117
      app/assets/javascripts/statistics/email_reminders.js on lines 119..119
      app/assets/javascripts/statistics/email_reminders.js on lines 120..120
      app/assets/javascripts/statistics/email_reminders.js on lines 121..121
      app/assets/javascripts/statistics/email_reminders.js on lines 122..122

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

      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 event_attendance has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def event_attendance
          require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
          require_osm_permission(:read, :events)
          return if performed? # The above either redirected or rendered
      
      
      Severity: Minor
      Found in app/controllers/reports_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 getPasswordTips has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      function getPasswordTips(password) {
          if ((password.length >= 1) && (passwordHaystackSize(password) < minimum_haystack_size)) {
              tips = "\n<ul>";
              if (password.match(/[A-Z]/) == null)
                  tips += '<li>Try adding some uppercase letters</li>';
      Severity: Minor
      Found in app/assets/javascripts/application/passwords.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

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

      $(document).ready(function() {  
          $('#calendar_select_all_events').click(function(){
              $('.calendar_events').prop('checked', this.checked);
          });
      });
      Severity: Major
      Found in app/assets/javascripts/reports/index.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/reports/index.js on lines 7..11

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

      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

      $(document).ready(function() {  
          $('#calendar_select_all_programme').click(function(){
              $('.calendar_programme').prop('checked', this.checked);
          });
      });
      Severity: Major
      Found in app/assets/javascripts/reports/index.js and 1 other location - About 1 hr to fix
      app/assets/javascripts/reports/index.js on lines 13..17

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

      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 event_attendance has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def self.event_attendance(user, section, events, groupings)
          Rails.cache.fetch("user#{user.id}-report-event_attendance-data-#{user.id}-#{section.id}-#{events.inspect}-#{groupings.inspect}", :expires_in => 10.minutes) do
            event_names = []
            row_groups = {}
            member_totals = {}
      Severity: Minor
      Found in app/models/report.rb - About 1 hr to fix

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

          def perform
            noterm_emails_sent = {}
            forbidden_emails_sent = {}
            lists = EmailList.where(:notify_changed => true).order(:section_id)
            count = lists.count
        Severity: Minor
        Found in app/jobs/email_lists_job.rb - About 1 hr to fix

          Method check_osm_setup has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            def check_osm_setup
              sections = Osm::Section.get_all(osm_api, :no_cache => true)
          
              Osm::Model.cache_delete(osm_api, ['permissions', osm_api.user_id]) # Clear cached user permissions
              @other_sections = Array.new
          Severity: Minor
          Found in app/controllers/static_controller.rb - About 1 hr to fix

            Method badge_stock_check has 30 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              def badge_stock_check
                @my_params = params.require(:badge_stock_check)
                                   .permit(:include_core, :include_activity, :include_challenge, :include_staged, :hide_no_stock)
            
                require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
            Severity: Minor
            Found in app/controllers/reports_controller.rb - About 1 hr to fix

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

                def flexi_record
                  require_osm_permission :read, :flexi
                  flexi_record = nil
                  flexi_record_id = params[:flexi_record_id].to_i
              
              
              Severity: Minor
              Found in app/controllers/osm_exports_controller.rb - About 1 hr to fix

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

                  def self.get_calendar_items_for_section(api, section, options)
                    [:start, :finish, :include_meetings, :include_events].each do |attr|
                      fail ArgumentError, "options doesn't contain a value for :#{attr}" unless options.has_key?(attr)
                    end
                
                
                Severity: Minor
                Found in app/models/report.rb - About 1 hr to fix

                  Function drawDayChart has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function drawDayChart(data, options, chart) {
                    data_table = new google.visualization.DataTable();
                    data_table.addColumn({
                      type: 'string',
                      label: 'Day'
                  Severity: Minor
                  Found in app/assets/javascripts/statistics/email_reminders.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language