Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E1959.Intelligent copying of assignments without topics (Issue #1341) #1524

Merged
merged 20 commits into from Mar 7, 2021

Conversation

subhasekhar
Copy link

we identified the code to make the changes and identified the pattern used.

@expertiza-bot
Copy link
Contributor

expertiza-bot commented Oct 17, 2019

1 Message
💬 Thanks for the pull request, and welcome! 🎉 The Expertiza team is excited to review your changes, and you should hear from us soon.

This repository is being automatically checked for code-quality issues using Code Climate.
You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a pull request is considered ready to review.

Also, please spend some time looking at the instructions at the top of your course project writeup.
If you have any questions, please send email to expertiza-support@lists.ncsu.edu.

UUID 4 Warnings
e222 ⚠️ Your pull request is more than 500 LoC.
Please make sure you did not commit unnecessary changes, such as schema.rb, node_modules, change logs.
846d ⚠️ Your pull request has many duplicated commit messages. Please try to squash similar commits.
And using meaningful commit messages later.
c51d ⚠️ You are modifying Gemfile or Gemfile.lock, please double check whether it is necessary.
You are suppose to add a new gem only if you have a very good reason. Try to use existing gems instead.
Please revert changes to Gemfile.lock made by the IDE.
04af ⚠️ One or more of your tests do not have expectations or you commented out some expectations.
To avoid shallow tests – tests concentrating on irrelevant, unlikely-to-fail conditions – please write at least one expectation for each test and do not comment out expectations.
d699 You changed YAML (*.yml) or example (*.yml.example) files; please double-check whether this is necessary.
ecaa There are code changes, but no corresponding tests.
Please include tests if this PR introduces any modifications in behavior.
61df Your pull request is less than 50 LoC.
If you are finished refactoring the code, please consider writing corresponding tests.
UUID ✅ Woo!
65de You are including debug code in your pull request, please remove it.

Generated by expertiza-bot

@coveralls
Copy link

coveralls commented Oct 17, 2019

Coverage Status

Coverage increased (+8.2%) to 49.43% when pulling f6c084e on subhasekhar:master into 6a7042a on expertiza:master.

@expertiza-travisci-bot
Copy link

expertiza-travisci-bot commented Oct 17, 2019

Hey @subhasekhar,
Your changes look good to me! 🎉

questionnaire_weight: aq.questionnaire_weight,
used_in_round: aq.used_in_round,
dropdown: aq.dropdown
assignment_id: new_assign.id,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than the start of the previous line.

)
end
end
end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 trailing blank lines detected.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

if copytopics == 'Y'
topics = SignUpTopic.where(assignment_id: old_assign.id)
topics.each do |topic|
SignUpTopic.create(topic_name: topic.topic_name, assignment_id: new_assign_id, max_choosers: topic.max_choosers, category: topic.category, topic_identifier: topic.topic_identifier, micropayment: topic.micropayment)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [224/160]

@assignment_id = params[:id]
end

def copy#Issue #1341 - Might require to modify below code
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after #.

@assignment_id = params[:id]
end

def copy#Issue #1341 - Might require to modify below code
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a space before an end-of-line comment.

@@ -380,4 +385,4 @@ def update_feedback_assignment_form_attributes
def assignment_form_params
params.require(:assignment_form).permit!
end
end
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

@assignment_id = params[:id]
end

def copy#Issue #1341 - Might require to modify below code
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not place comments on the same line as the def keyword.

@codeclimate
Copy link

codeclimate bot commented Oct 22, 2019

Code Climate has analyzed commit f6c084e and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Style 1

The test coverage on the diff in this pull request is 22.2% (50% is the threshold).

This pull request will bring the total coverage in the repository to 29.9% (-22.0% change).

View more on Code Climate.

@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay)
end

# Copies the inputted assignment into new one and returns the new assignment id
def self.copy(assignment_id, user)
def self.copy(assignment_id, copyoption, user)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay)
end

# Copies the inputted assignment into new one and returns the new assignment id
def self.copy(assignment_id, user)
def self.copy(assignment_id, copyoption, user)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method copy has 33 lines of code (exceeds 25 allowed). Consider refactoring.

dropdown: aq.dropdown
)
AssignmentQuestionnaire.create(
assignment_id: new_assign.id,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the first parameter one step more than the start of the previous line.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

used_in_round: aq.used_in_round,
dropdown: aq.dropdown
)
AssignmentQuestionnaire.create(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use 2 (not 4) spaces for indentation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

if copyoption != 'copyWithoutTopics'
topics = SignUpTopic.where(assignment_id: old_assign.id)
topics.each do |topic|
newSignUpTopic = SignUpTopic.create(topic_name: topic.topic_name, assignment_id: new_assign_id, max_choosers: topic.max_choosers, category: topic.category, topic_identifier: topic.topic_identifier, micropayment: topic.micropayment)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [241/160]

expect(AssignmentForm.copy(1, 'copyWithTopicsTeams', build(:instructor))).to eq(2)
end


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tab detected.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

allow_any_instance_of(AssignmentForm).to receive(:update_attribute).with(any_args).and_return('OK!')
expect(AssignmentForm.copy(1, 'copyWithTopicsTeams', build(:instructor))).to eq(2)
end

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

expect(AssignmentForm.copy(1, 'copyWithTopicsTeams', build(:instructor))).to eq(2)
end


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

allow(assignment).to receive(:dup).and_return(new_assignment)
allow(new_assignment).to receive(:save).and_return(false)

context 'when new assignment is not able to be copied' do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

context 'when new assignment is not able to be copied' do
it 'should show an error and redirect to assignments#tree display page' do
allow(AssignmentForm).to receive(:copy).with("1", nil, instructor).and_return(false)
allow(Assignment).to receive(:find).with(2).and_return(false)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation detected.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

Copy link

@Yashad Yashad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please correct the code climate issues.

@@ -398,7 +398,7 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
rake (12.3.2)
rake (13.0.0)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the Gems versions are changed, it might affect the other parts of the system. Could to try keeping the same version?

(assignment.instructor_id == current_user.try(:id)) ||
TaMapping.exists?(ta_id: current_user.try(:id), course_id: assignment.course_id) ||
(assignment.course_id && Course.find(assignment.course_id).instructor_id == current_user.try(:id))
(assignment.instructor_id == current_user.try(:id)) ||
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white spaces.

<%= label_tag(:copyoption_topics, "copy with topics") %><br>
<%= radio_button_tag(:copyoption, "copyWithTopicsTeams") %>
<%= label_tag(:copyoption_topics_teams, "copy with topics and teams") %><br>
<%= submit_tag("Create") %>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the submit button name be "Copy"

React.createElement(TabSystem),
document.getElementById("tree_display")
)
}

})
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you did not intend to change this file but introduced many whitespaces and newlines unknowingly. Please correct it. (remove this file from commit if it does not have any changes relevant to your project or correct its code climate )

@@ -143,7 +144,7 @@
end
end

resources :institution, except: [:destroy] do
resources :institution, except: [:destroy] do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white space

allow(assignment).to receive(:dup).and_return(new_assignment)
allow(new_assignment).to receive(:save).and_return(false)

context 'when new assignment is not able to be copied' do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

white spaces

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved.

@Yashad
Copy link

Yashad commented Nov 4, 2019

Do you have any other pull request for expertiza beta? We would like these changes on beta.

@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay)
end

# Copies the inputted assignment into new one and returns the new assignment id
def self.copy(assignment_id, user)
def self.copy(assignment_id, copyoption, user)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method copy has 40 lines of code (exceeds 25 allowed). Consider refactoring.

@@ -310,7 +309,7 @@ def enqueue_simicheck_task(due_date, simicheck_delay)
end

# Copies the inputted assignment into new one and returns the new assignment id
def self.copy(assignment_id, user)
def self.copy(assignment_id, copyoption, user)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method copy has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.

@Saurabh110 Saurabh110 merged commit f6c084e into expertiza:master Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants