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

Add rubocop settings and run safe autocorrect #1395

Merged
merged 5 commits into from Oct 21, 2021

Conversation

victorhuangwq
Copy link
Contributor

Description

Add Styles from https://relaxed.ruby.style/ into our rubocop settings.
Ran safe autocorrect.

Motivation and Context

This is part 1 of our efforts to organize our ruby codebase better.

How Has This Been Tested?

Ran server

  1. Tried out courses and assignments
  2. Submitted an assignment
  3. Opened up course settings
  4. View student code
  5. Opened gradebook

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation, which is located at Autolab Docs
  • I have updated the documentation accordingly, included in this PR

Other issues / help required

If unsure, feel free to submit first and we'll help you along.

@victorhuangwq
Copy link
Contributor Author

Was thinking we can split this PR up for 2 people to review?
First person does file 1 to 28, second does 28 - 56

@xinyis991105 xinyis991105 self-requested a review October 11, 2021 17:02
.rubocop.yml Outdated
Enabled: false
StyleGuide: https://relaxed.ruby.style/#lintassignmentincondition

Layout/LineLength:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we going to enable this sometime in the future? I saw that Layout/LineLength is defined on line 22 and it doesn't seem to be part of the relaxed style guide.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this line. We are setting the line length to be 100 at the beginning of rubocop file

@xinyis991105
Copy link
Contributor

Was thinking we can split this PR up for 2 people to review? First person does file 1 to 28, second does 28 - 56

I can review 1-28. Can you assign another person?

@xinyis991105
Copy link
Contributor

File 1-28 LGTM!

@victorhuangwq
Copy link
Contributor Author

Hi @xinyis991105 could you use the check box on the review page to indicate which files you have looked at?

@xinyis991105
Copy link
Contributor

Hi @xinyis991105 could you use the check box on the review page to indicate which files you have looked at?

Already did.

@victorhuangwq
Copy link
Contributor Author

@xinyis991105 I think the checkmarks aren't saved unless you submit the review

Copy link
Contributor

@xinyis991105 xinyis991105 left a comment

Choose a reason for hiding this comment

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

1-28 LGTM!

@xinyis991105
Copy link
Contributor

@xinyis991105 I think the checkmarks aren't saved unless you submit the review

Are they visible now?

@victorhuangwq
Copy link
Contributor Author

HAHA i don't think so. I guess we don't get to see other people's checkmarks :/

@xinyis991105
Copy link
Contributor

xinyis991105 commented Oct 20, 2021

@michellexliu Please prioritize roster upload! I will review the rest of this PR!

@victorhuangwq victorhuangwq removed the request for review from michellexliu October 20, 2021 20:20
0.0
when EXCUSED
nil
end

# TODO: final_score = apply_tweak(final_score) if final_score
Copy link
Contributor

Choose a reason for hiding this comment

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

The step of applying a tweak is now in app/models/submission.rb. Maybe delete this comment to avoid future confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay sounds good.

0.0
when EXCUSED
nil
end

# TODO: final_score = apply_tweak(final_score) if final_score
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above.

if pending_watchlist?
contacted_watchlist!

raise "Failed to update watchlist instance #{id} to contacted" if !save && !save
Copy link
Contributor

Choose a reason for hiding this comment

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

Now this code doesn't make sense 😂 . Could you remove the second !save?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

HAHA okay :)

if not self.save
raise "Failed to update watchlist instance #{self.id} to resolved" unless self.save
end
raise "Failed to update watchlist instance #{id} to resolved" if !save && !save
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above.

Copy link
Contributor

@xinyis991105 xinyis991105 left a comment

Choose a reason for hiding this comment

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

Changes requested. See comments.
Tested behaviorally as well. Found a bug #1401 that is replicated on master so it's not linting specific. Otherwise, everything functions normally. Thanks a lot!

@victorhuangwq
Copy link
Contributor Author

Thanks for the review! @xinyis991105

@@ -16,7 +19,7 @@ AllCops:
Rails:
Enabled: true

Metrics/LineLength:
Layout/LineLength:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here is the linelength stuff

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make sure, does removing "Enabled: false" introduce further changes if linting is run again? I'm not sure whether all lines are below 100 right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will probably introduce more things to be manually fixed, but not things that can be automatically fixed. I ran it again and there was nothing else that can be safely autofixed

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok then let's not run it again for now.

Copy link
Contributor

@xinyis991105 xinyis991105 left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks again!

@victorhuangwq victorhuangwq merged commit 30465f9 into master Oct 21, 2021
@victorhuangwq victorhuangwq deleted the add-rubocop-settings branch October 21, 2021 17:30
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

2 participants