CSC/ECE 517 Fall 2022 - E2255. Refactor review mapping helper.rb: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
===Problems and Solutions=== | ===Problems and Solutions=== | ||
* '''Problem 1''': Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above. | * '''Problem 1''': Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above. | ||
* '''Problem 2''': Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas, space or lack of it, and assigning branching condition. | |||
::Example: check_submission_state has Cyclomatic complexity 10 Maximum 5 | ::Example: check_submission_state has Cyclomatic complexity 10 Maximum 5 | ||
<pre> | <pre> | ||
Line 50: | Line 52: | ||
end | end | ||
</pre> | </pre> | ||
* '''Problem 3''': Write test cases of any new code written. Test the existing functionality after refactoring | * '''Problem 3''': Write test cases of any new code written. Test the existing functionality after refactoring |
Revision as of 02:05, 26 October 2022
This page provides a description of the Expertiza based OSS project.
About Expertiza
Expertiza is an open-source project based on the Ruby on Rails framework. Expertiza allows the instructor to create new assignments and customize new or existing assignments. It also allows the instructor to create a list of topics the students can sign up for. Students can form teams of Expertise to work on various projects and assignments. Students can also peer review other students' submissions. Expertise supports submission across various document types, including URLs and wiki pages.
Problem Statement
The following tasks were accomplished in this project:
- Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.
- Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas, space or lack of it, and assigning branching condition.
- Write test cases of any new code written. Test the existing functionality after refactoring
Problems and Solutions
- Problem 1: Use Code Climate to do a diagnosis for Expertiza. Search for the issues involving the files mentioned above.
- Problem 2: Fix all the methods having the issue with cyclomatic complexity, assignment branch condition size, extra commas, space or lack of it, and assigning branching condition.
- Example: check_submission_state has Cyclomatic complexity 10 Maximum 5
def check_submission_state(response_map, assignment_created, assignment_due_dates, round, color) if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates) color.push 'purple' else link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates) if link.nil? || (link !~ %r{https*:\/\/wiki(.*)}) # can be extended for github links in future color.push 'green' else link_updated_at = get_link_updated_at(link) color.push link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green' end end end
- Solution: The problem is caused by nesting loops so we break it up
def check_submission_state(response_map, assignment_created, assignment_due_dates, round, color) if submitted_within_round?(round, response_map, assignment_created, assignment_due_dates) color.push 'purple' return link = submitted_hyperlink(round, response_map, assignment_created, assignment_due_dates) if link.nil? || (link !~ %r{https*:\/\/wiki(.*)}) # Can be extended for github links in future color.push 'green' return link_updated_at = get_link_updated_at(link) color.push link_updated_since_last?(round, assignment_due_dates, link_updated_at) ? 'purple' : 'green' end
- Problem 3: Write test cases of any new code written. Test the existing functionality after refactoring