CSC/ECE 517 Spring 2019 - E1919 CodeClimate Issues: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


This wiki page is for the description of changes made according to the specification of E1919, OSS project.
This wiki page is for the description of changes made according to the specification of E1919, OSS project.
 
--[[User:Sbhadau|Sbhadau]] 21:53, 25 March 2019 (EDT)
== About Expertiza ==
== About Expertiza ==
Expertiza is a platform where assignments and related quizzes are managed. On this portal instructor  upload assignments/questionnaires, create list of topics for students and edit the existing assignments. Students can form teams, work on projects and submit their assignments as URL or files. It also helps in improving the work quality by allowing students to provide anonymous reviews. It is an Open source platform which is based on Ruby with Rails.
Expertiza is a platform where assignments and related quizzes are managed. On this portal instructor  upload assignments/questionnaires, create list of topics for students and edit the existing assignments. Students can form teams, work on projects and submit their assignments as URL or files. It also helps in improving the work quality by allowing students to provide anonymous reviews. It is an Open source platform which is based on Ruby with Rails.
Line 8: Line 8:
== Problem Statement ==
== Problem Statement ==
There were code smells detected in the application by code climate which violated the best practices of Ruby Rails. The goal was to fix those code smells by refactoring.
There were code smells detected in the application by code climate which violated the best practices of Ruby Rails. The goal was to fix those code smells by refactoring.
e.g. 1. belongs_to :topic, class_name: 'SignUpTopic'.  
Consider the following examples.  
 
1. '''Add inverse_of option.'''
 
File: Participant.rb
belongs_to :topic, class_name: 'SignUpTopic'.  


In the class 'SignUpTopic', we have  
In the class 'SignUpTopic', we have  
Line 16: Line 21:
Knowing the other side of the same association Rails can optimize object loading and will reference the same object in memory, instead of loading another copy of the same record.
Knowing the other side of the same association Rails can optimize object loading and will reference the same object in memory, instead of loading another copy of the same record.


2. in the file roles.rb we have  
2. '''Add dependent property'''
 
In the file roles.rb we have  
has_many :users
has_many :users


We need to specify "dependent" option here.
We need to specify "dependent" option here.
With Active Record associations, we can streamline these - and other - operations by declaratively telling Rails that there is a connection between the two models.
It would make more sense here if we add "dependent :destroy" option for users. If a particular role is deleted, all the users under that role must also disappear.

Revision as of 01:53, 26 March 2019

CSC/ECE 517 Spring 2019 / E1919. Fix Code Climate issues in models with names beginning with ‘H’ thru ‘Sc

This wiki page is for the description of changes made according to the specification of E1919, OSS project. --Sbhadau 21:53, 25 March 2019 (EDT)

About Expertiza

Expertiza is a platform where assignments and related quizzes are managed. On this portal instructor upload assignments/questionnaires, create list of topics for students and edit the existing assignments. Students can form teams, work on projects and submit their assignments as URL or files. It also helps in improving the work quality by allowing students to provide anonymous reviews. It is an Open source platform which is based on Ruby with Rails.

Problem Statement

There were code smells detected in the application by code climate which violated the best practices of Ruby Rails. The goal was to fix those code smells by refactoring. Consider the following examples.

1. Add inverse_of option.

File: Participant.rb belongs_to :topic, class_name: 'SignUpTopic'.

In the class 'SignUpTopic', we have has_many :teams

When you have two models in a has_many, has_one or belongs_to association, the :inverse_of option in Rails tells ActiveRecord that they're two sides of the same association. Knowing the other side of the same association Rails can optimize object loading and will reference the same object in memory, instead of loading another copy of the same record.

2. Add dependent property

In the file roles.rb we have has_many :users

We need to specify "dependent" option here.

With Active Record associations, we can streamline these - and other - operations by declaratively telling Rails that there is a connection between the two models. It would make more sense here if we add "dependent :destroy" option for users. If a particular role is deleted, all the users under that role must also disappear.