robertgauld/OSMExtender

View on GitHub

Showing 203 of 203 total issues

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

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

                    rescue Osm::Error::NoCurrentTerm => exception
                      Rails.logger.error "(#{reminder.id} for user #{reminder.user_id}) No current term for section #{reminder.section_id}."
                      noterm_emails_sent[reminder.user_id] ||= []
                      unless noterm_emails_sent[reminder.user_id].include?(reminder.section_id)
                        EmailReminderMailer.no_current_term(reminder, exception).deliver_now
              Severity: Major
              Found in app/jobs/reminder_emails_job.rb and 1 other location - About 1 hr to fix
              app/jobs/email_lists_job.rb on lines 26..38

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

              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

                    rescue Osm::Error::NoCurrentTerm => exception
                      Rails.logger.error "(#{list.id} for user #{list.user_id}) No current term for section #{list.section_id}."
                      noterm_emails_sent[list.user_id] ||= []
                      unless noterm_emails_sent[list.user_id].include?(list.section_id)
                        EmailListMailer.no_current_term(list, exception).deliver_now
              Severity: Major
              Found in app/jobs/email_lists_job.rb and 1 other location - About 1 hr to fix
              app/jobs/reminder_emails_job.rb on lines 23..36

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

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

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

                        def next_birthday_for_member(member, from=Date.current)
                          year = from.year
                          mmdd = member.date_of_birth.strftime('%m%d')
                          year += 1 if mmdd < from.strftime('%m%d')
                          mmdd = '0301' if mmdd == '0229' && !Date.parse("#{year}0101").leap?
                      Severity: Minor
                      Found in app/models/email_reminder_item_birthday.rb and 1 other location - About 55 mins to fix
                      app/models/automation_task_birthday_badge.rb on lines 150..155

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

                      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

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

                        def next_birthday_for_member(member, from=Date.current)
                          year = from.year
                          mmdd = member.date_of_birth.strftime('%m%d')
                          year += 1 if mmdd < from.strftime('%m%d')
                          mmdd = '0301' if mmdd == '0229' && !Date.parse("#{year}0101").leap?
                      Severity: Minor
                      Found in app/models/automation_task_birthday_badge.rb and 1 other location - About 55 mins to fix
                      app/models/email_reminder_item_birthday.rb on lines 101..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 46.

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

                      Method gdpr_consent_given has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def gdpr_consent_given
                          if params[:gdpr_consent].eql?('1')
                            if current_user.update gdpr_consent_at: Time.now.utc
                              redirect_to session[:return_to].nil? ? my_page_path : session.delete(:return_to), :notice => 'Thank you, your consent has been recorded.'
                            else
                      Severity: Minor
                      Found in app/controllers/users_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