robertgauld/OSMExtender

View on GitHub

Showing 133 of 203 total issues

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

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

              def perform
                noterm_emails_sent = {}
                forbidden_emails_sent = {}
                reminders = EmailReminder.where(:send_on => Date.today.wday).order(:section_id)
                count = reminders.size
            Severity: Minor
            Found in app/jobs/reminder_emails_job.rb - About 1 hr to fix

              Method programme_meetings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def programme_meetings
                  require_osm_permission :read, :programme
              
                  headers = [
                    'ID',
              Severity: Minor
              Found in app/controllers/osm_exports_controller.rb - About 1 hr to fix

                Method get_fake_data has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def get_fake_data
                    events = []
                    attendance = {}
                
                    (1 + rand(3)).times do |i|
                Severity: Minor
                Found in app/models/email_reminder_item_event.rb - About 1 hr to fix

                  Method show has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    def show
                      @record = nil
                      record_id = params[:record_id].to_i
                  
                      @section.flexi_records.each do |record|
                  Severity: Minor
                  Found in app/controllers/osm_flexi_records_controller.rb - About 1 hr to fix

                    Method send_email has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      def send_email(options={})
                        # :only_to is an array of strings or objects with an :email_address method or nil (send to everyone).
                        # :except_to is an array of strings or objects with an :email_address method or nil (send to everyone).
                        # :skip_subscribed_check if true then the email will be sent even if the subscription state is not :subscribed
                    
                    
                    Severity: Minor
                    Found in app/models/email_reminder.rb - About 1 hr to fix

                      Method create has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        def create
                          @user = User.new(params[:user].permit(:name, :email_address, :password, :password_confirmation, :gdpr_consent))
                          @user.gdpr_consent ||= false
                      
                          if @signup_code
                      Severity: Minor
                      Found in app/controllers/users_controller.rb - About 1 hr to fix

                        Method health has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def health
                            data = Status.new.health
                            status = data[:healthy] ? :ok : :service_unavailable
                            respond_with(data) do |format|
                              format.cacti { render cacti: {healthy: data[:healthy] ? 1 : 0}, status: status }
                        Severity: Minor
                        Found in app/controllers/status_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 get_balanced_statistics has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def get_balanced_statistics(data, type)
                            statistics = {}
                        
                            [:number, :time].each do |num_or_time|
                              statistics[num_or_time] = {
                        Severity: Minor
                        Found in app/models/programme_review.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 show has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def show
                            @record = nil
                            record_id = params[:record_id].to_i
                        
                            @section.flexi_records.each do |record|
                        Severity: Minor
                        Found in app/controllers/osm_flexi_records_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 badge_completion_matrix has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                        Open

                          def badge_completion_matrix
                            require_section_type Constants::YOUTH_AND_ADULT_SECTIONS
                            require_osm_permission(:read, :badge)
                            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

                        Method email_reminders_data has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          def email_reminders_data
                            todays_data = Statistics.create_or_retrieve_for_date(Date.today)
                        
                            by_day = [todays_data['email_reminders_by_day'], todays_data['email_reminder_shares_by_day']]
                            by_day_max = 0
                        Severity: Minor
                        Found in app/controllers/statistics_controller.rb - About 1 hr to fix

                          Method get_list has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            def get_list
                              emails = Array.new
                              no_emails = Array.new
                              section = Osm::Section.get(user.osm_api, section_id)
                              fail Osm::Forbidden if section.nil?
                          Severity: Minor
                          Found in app/models/email_list.rb - About 1 hr to fix

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

                              def get_data
                                earliest = configuration[:the_last_n_weeks].weeks.ago.to_date
                                latest = Date.current
                            
                                api = user.osm_api
                            Severity: Minor
                            Found in app/models/email_reminder_item_not_seen.rb - About 1 hr to fix

                              Method search_results has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                def search_results
                                  if params[:selected].nil?
                                    flash[:error] = 'You must select some fields to search.'
                                    redirect_to osm_search_members_form_path(:search_for => params[:search_for]) and return
                                  end
                              Severity: Minor
                              Found in app/controllers/osm_search_members_controller.rb - About 1 hr to fix

                                Method flexi_record has a Cognitive Complexity of 9 (exceeds 5 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 55 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

                                Severity
                                Category
                                Status
                                Source
                                Language