nfigueira/cs370

View on GitHub

Showing 13 of 13 total issues

Class AdminsController has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

class AdminsController < ApplicationController
layout 'admin_layout', :only => [:home, :update_semester, :updateCurrentSemester, :rating_tutors, :tutor_hours, :update_password, :update_student_priorities, :manage_tutors, :manage_semester, :update_question_templates]
before_action :set_admin, except: [:landing, :destroyAdminSession]
before_action :check_logged_in, except: [:landing, :createAdminSession, :destroyAdminSession]
 
 
Severity: Minor
Found in app/controllers/admins_controller.rb - About 2 hrs to fix

    Method batch_update has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def batch_update
    new_ordering = []
    params.keys.each do |k|
    if k.include?('qt')
    #second split by _ index is always the qt id value, a la qt_#{qt.index}_etcetc
    Severity: Minor
    Found in app/controllers/question_templates_controller.rb - About 1 hr to fix

      Method set_tutor has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def set_tutor
      if params[:id] == "sign_out" || params[:id] == "new"
      redirect_to new_tutor_session_path
      elsif params[:id] == "password"
      redirect_to new_tutor_password_path
      Severity: Minor
      Found in app/controllers/tutors_controller.rb - About 35 mins to fix

      Method check_valid_tutee has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def check_valid_tutee
      #I'm so sorry, but this is what they left me and I didn't have time to fix it.
      #We need to either commit fully to Devise or just don't, cause this is what happens when you try to validate across forms,
      #posts, gets, etc. and everything is split between param ids, nested resource ids, session checks, etc.
      if ['tutees','tutees/registrations'].include? params[:controller] and current_tutee&.id.to_i == params[:id].to_i
      Severity: Minor
      Found in app/controllers/application_controller.rb - About 25 mins to fix

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

      def self.to_csv
      attributes = self.attribute_names
       
      CSV.generate(headers: true) do |csv|
      csv << attributes.first(15)
      Severity: Minor
      Found in app/models/tutor.rb and 1 other location - About 25 mins to fix
      app/models/tutee.rb on lines 22..29

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

      def self.to_csv
      attributes = self.attribute_names
       
      CSV.generate(headers: true) do |csv|
      csv << attributes.first(14)
      Severity: Minor
      Found in app/models/tutee.rb and 1 other location - About 25 mins to fix
      app/models/tutor.rb on lines 15..22

      Method edit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def edit
      @tutee = Tutee.find params[:tutee_id]
      @evaluation = Evaluation.friendly.find params[:id]
      @meeting = Meeting.where("evaluation_id = ?", @evaluation.id).first
      if not @meeting.nil? and not @meeting.set_time.nil?
      Severity: Minor
      Found in app/controllers/evaluations_controller.rb - About 25 mins to fix

      Method create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def create
       
      # Checks if parameters are good
      if request_params[:subject].blank?
      flash[:notice] = "Invalid request: Subject should be filled out."
      Severity: Minor
      Found in app/controllers/requests_controller.rb - About 25 mins to fix

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

      def update
      @evaluation = Evaluation.friendly.find params[:id]
      took_place = (params['hours'].to_d > 0)
      @evaluation.update(took_place: took_place, course: params['course'], hours: params['hours'], status: "Complete")
      #in case the tutor hasn't marked it as done yet, tutee submitting an evaluation will.
      Severity: Minor
      Found in app/controllers/evaluations_controller.rb - About 25 mins to fix

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

      def invite_student(tutor_id, tutee_id, request_id, tutor_message)
      @tutor = Tutor.find_by_id(tutor_id)
      @tutee = Tutee.find_by_id(tutee_id)
      @request = Request.find_by_id(request_id)
      @tutor_message = tutor_message
      Severity: Minor
      Found in app/mailers/tutor_mailer.rb and 1 other location - About 15 mins to fix
      app/mailers/tutor_mailer.rb on lines 11..16

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

      def meeting_confirmation(tutor_id, tutee_id, message, request_id)
      @tutor = Tutor.find_by_id(tutor_id)
      @tutee = Tutee.find_by_id(tutee_id)
      @request = Request.find_by_id(request_id)
      @message = message
      Severity: Minor
      Found in app/mailers/tutor_mailer.rb and 1 other location - About 15 mins to fix
      app/mailers/tutor_mailer.rb on lines 3..8

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

      def self.to_csv
      attributes = Meeting.attribute_names
       
      CSV.generate(headers: true) do |csv|
      csv << attributes
      Severity: Minor
      Found in app/models/meeting.rb and 1 other location - About 15 mins to fix
      app/models/request.rb on lines 9..16

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

      def self.to_csv
      attributes = Request.attribute_names
       
      CSV.generate(headers: true) do |csv|
      csv << attributes
      Severity: Minor
      Found in app/models/request.rb and 1 other location - About 15 mins to fix
      app/models/meeting.rb on lines 7..14
      Severity
      Category
      Status
      Source
      Language