E1916. Fix Code Climate issues in controllers with names beginning with A through N: Difference between revisions
Jump to navigation
Jump to search
(Blanked the page) |
No edit summary |
||
Line 1: | Line 1: | ||
__TOC__ | |||
===Description of the project=== | |||
====Project Team Member==== | |||
*Shuai Wang (swang28) | |||
*Huan Chang (hchang15) | |||
*Guangyu Yu (gyu22) | |||
====Project Task==== | |||
There is some code smells detected by the code climate. These violate many of the ruby/rails best practices and needs to be rectified. | |||
Our team is to fix all code smells except: | |||
*Assignment Branch Condition size for [method name] is too high | |||
*Perceived complexity for [method name] is too high. | |||
*Cyclomatic complexity for [method name] is too high. | |||
*Method [method name] has a Cognitive Complexity of XX (exceeds 5 allowed). Consider refactoring. | |||
*File [file name] has XXX lines of code (exceeds 250 allowed). Consider refactoring. | |||
*Class [class name] has XX methods (exceeds 20 allowed). Consider refactoring. | |||
*Method [method name] has XX lines of code (exceeds 25 allowed). Consider refactoring. | |||
*Mass assignment is not restricted using attr_accessible. | |||
*Potentially dangerous attribute available for mass assignment. | |||
===Files modified in the project=== | |||
In all files in app/controllers/ with names beginning with A through N, except assignment_controller.rb. | |||
====Main issue files:==== | |||
*[MAINTAINABILITY C] app/controllers/assessment360_controller.rb | |||
*[MAINTAINABILITY B] app/controllers/automated_metareviews_controller.rb | |||
*[MAINTAINABILITY B] app/controllers/grades_controller.rb | |||
*[MAINTAINABILITY C] app/controllers/impersonate_controller.rb | |||
*[MAINTAINABILITY F] app/controllers/import_file_controller.rb | |||
*[MAINTAINABILITY C] app/controllers/lottery_controller.rb | |||
===Typical Issues and Improvements=== | |||
====Issue: Use a guard clause instead of wrapping the code inside a conditional expression.==== | |||
=====Example===== | |||
<pre> | |||
if assignment.try(:is_selfreview_enabled) and unsubmitted_self_review?(participant.try(:id)) | |||
return false | |||
else | |||
return true | |||
end | |||
</pre> | |||
=====Solution===== | |||
<pre> | |||
return false if assignment.try(:is_selfreview_enabled) and unsubmitted_self_review?(participant.try(:id)) | |||
true | |||
</pre> | |||
===Testing=== | |||
===Reference=== | |||
*Our Team GitHub Repository: https://github.com/ece517-p3/expertiza | |||
*Our Team Code Climate: https://codeclimate.com/github/ece517-p3/expertiza | |||
*The Class GitHub Repository: https://github.com/expertiza/expertiza | |||
*The Class Code Climate:https://codeclimate.com/github/expertiza/expertiza |
Latest revision as of 04:05, 25 March 2019
Description of the project
Project Team Member
- Shuai Wang (swang28)
- Huan Chang (hchang15)
- Guangyu Yu (gyu22)
Project Task
There is some code smells detected by the code climate. These violate many of the ruby/rails best practices and needs to be rectified.
Our team is to fix all code smells except:
- Assignment Branch Condition size for [method name] is too high
- Perceived complexity for [method name] is too high.
- Cyclomatic complexity for [method name] is too high.
- Method [method name] has a Cognitive Complexity of XX (exceeds 5 allowed). Consider refactoring.
- File [file name] has XXX lines of code (exceeds 250 allowed). Consider refactoring.
- Class [class name] has XX methods (exceeds 20 allowed). Consider refactoring.
- Method [method name] has XX lines of code (exceeds 25 allowed). Consider refactoring.
- Mass assignment is not restricted using attr_accessible.
- Potentially dangerous attribute available for mass assignment.
Files modified in the project
In all files in app/controllers/ with names beginning with A through N, except assignment_controller.rb.
Main issue files:
- [MAINTAINABILITY C] app/controllers/assessment360_controller.rb
- [MAINTAINABILITY B] app/controllers/automated_metareviews_controller.rb
- [MAINTAINABILITY B] app/controllers/grades_controller.rb
- [MAINTAINABILITY C] app/controllers/impersonate_controller.rb
- [MAINTAINABILITY F] app/controllers/import_file_controller.rb
- [MAINTAINABILITY C] app/controllers/lottery_controller.rb
Typical Issues and Improvements
Issue: Use a guard clause instead of wrapping the code inside a conditional expression.
Example
if assignment.try(:is_selfreview_enabled) and unsubmitted_self_review?(participant.try(:id)) return false else return true end
Solution
return false if assignment.try(:is_selfreview_enabled) and unsubmitted_self_review?(participant.try(:id)) true
Testing
Reference
- Our Team GitHub Repository: https://github.com/ece517-p3/expertiza
- Our Team Code Climate: https://codeclimate.com/github/ece517-p3/expertiza
- The Class GitHub Repository: https://github.com/expertiza/expertiza
- The Class Code Climate:https://codeclimate.com/github/expertiza/expertiza