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

wip: add Rubocop and Linting lesson #27794

Merged
merged 21 commits into from
May 23, 2024

Conversation

scheals
Copy link
Contributor

@scheals scheals commented Apr 14, 2024

Because

We never had a dedicated lesson for Linting and Rubocop. This is even more important now because of Ruby LSP requiring a locally installed RuboCop for linting and formatting to work.

This PR

  • Adds RuboCop and Linting lesson.
  • Removes outdated RuboCop installation instructions in Object Oriented Programming lesson.
  • Does some style cleanup in the aforementioned OOP lesson.

Issue

Closes #27091

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

@github-actions github-actions bot added the Content: Ruby Involves the Ruby course label Apr 14, 2024
@scheals
Copy link
Contributor Author

scheals commented Apr 14, 2024

@JoshDevHub
First draft is ready. Assignment section and Additional resources is very WIP but the foundations are there.

Be frank with me and I hope that the content looks good :D

@JoshDevHub JoshDevHub self-requested a review April 16, 2024 17:39
@JoshDevHub JoshDevHub self-assigned this Apr 16, 2024
@JoshDevHub
Copy link
Contributor

I'm on triage this week, so it might take me a few days to read through this more thoroughly. Looking pretty good though! Will be awesome to have this content in the curriculum.

@scheals
Copy link
Contributor Author

scheals commented Apr 16, 2024

No worries, focus on the triage :)

Copy link
Contributor

@JoshDevHub JoshDevHub left a comment

Choose a reason for hiding this comment

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

Just a couple of comments so far. I think it's pretty awesome. Let me know if you want any input on any of the Todo items.

Co-authored-by: Josh Smith <[email protected]>
@scheals
Copy link
Contributor Author

scheals commented Apr 20, 2024

Just a couple of comments so far. I think it's pretty awesome. Let me know if you want any input on any of the Todo items.

Thanks!

Hmmm, I haven't really directly defined linting and formatting and I wonder if that's a problem. Formatting is probably clear enough on its own but perhaps it'd be good to make a clear distinction between the two? Perhaps just linking to the wiki page of Linting in the assignment is going to be enough. Not sure.

Also not super confident in my ABC/Cyclomatic/Perceived metric explanations.

(Hope this is on-topic, this is how I understood Todo items :) )

@scheals
Copy link
Contributor Author

scheals commented Apr 20, 2024

Interestingly enough, I had some typos/misspellings and while the action has pointed out them in the preview, the action in the summary has not failed. Not sure if intentional.

image

@nguyenlekhtn
Copy link
Contributor

HI, "This is even more important now because of Ruby LSP requiring a locally installed RuboCop for linting and formatting to work."

As I checked the latest Rbuy-LSP version, it is no longer true. It doesn't require rubucop when I create new project.

@scheals
Copy link
Contributor Author

scheals commented Apr 27, 2024

@nguyenlekhtn

That sounds great! Could you provide me with an example file that I can test this with? My tests went the usual route with Ruby-LSP:

  1. It fails to do anything without a Gemfile.
  2. Closing the tab with a Ruby file and reopening it gets it to ask me about monorepo setup.
  3. It starts finally.
  4. I write some code that RuboCop should hate - it is silent.

Perhaps you need to have a default linter/formatter set up? I have none and rely on the Gemfile:
image

For more context, I cloned TOP's ruby-exercises repo, opened it in VSCode and then started playing around:
image
image

@nguyenlekhtn
Copy link
Contributor

nguyenlekhtn commented Apr 28, 2024

Hi @scheals, my bad, look like I misread. What I mean is now Ruby-LSP run without a Gemfile. It still requires rubocop to lint and format, as expected. If it's not in the bundle, or Gemfile doesn't exist, then Ruby-LSP still works, but won't be able to do linting.

@scheals
Copy link
Contributor Author

scheals commented Apr 28, 2024

Ahh no worries. Yeah, in the meantime Ruby LSP fixed it not working without a Gemfile but I still find its activation rather hit and miss - often I open a Ruby project and Ruby LSP only opens after I close-reopen a Ruby file for it to pick up that I'm working on a Ruby file. I'm expecting looots of questions about this - I imagine that the bit I have proposed to change in Installing Ruby:

The most important features Ruby LSP provides will work out of the box. But it may bug you about using a monorepo setup, missing lockfiles or rubocop - you can choose "Don't show again" for now. We will introduce these later.

Will not be sufficient and instructions how to make Ruby LSP start without a Gemfile are going to be needed.

- Assignment
- Knowledge check
- Additional resources
@scheals
Copy link
Contributor Author

scheals commented May 11, 2024

So, in the Lesson overview this promise is made:

  • What the differences between RuboCop in the CLI and in your VSCode are.

and I am not sure whether I've kept it as of current draft. The lesson does introduce how to use RuboCop in VSCode but doesn't really talk about the differences in what RuboCop in the CLI can do and what RuboCop integration in VSCode can't do and vice versa. Perhaps this should be changed to:

  • How to use RuboCop in VSCode.

which would be OK for the current content.

I have "finalized" the assignment and the additional resources and have proposed a rather long list of knowledge checks. I took a quick glance at the freshly revamped React course and I found at least one lesson with similar check count, so perhaps it is A-OK and I can start filling in the anchors.

Strongly believe that including Sandi Metz' talk on Rules in the Assignment section is the way to go. I gave it a re-listen and it is even better than I remembered it. Thrown out a link to RuboCop's GH repo as the docs would have the same information anyway.

Material related to Standard was also removed although I'm still waiting for clarification as to what is needed to be done with the mention of Standard in the lesson content itself - I'll clear that up together with the common config issues then.

@JoshDevHub
Copy link
Contributor

This lesson looks great @scheals

I'm a fan of your knowledge checks, so feel free to go ahead and start filling in the anchors whenever you want. Also love that Sandi Metz talk and I'm glad to have it in the assignment.

Was there any other specific thing you were concerned about or want me to respond to?

- also remove the bit about Standard and hammer the point about defaults a lil' harder
@scheals scheals requested a review from JoshDevHub May 21, 2024 17:41
@scheals
Copy link
Contributor Author

scheals commented May 21, 2024

I'm very glad to hear that @JoshDevHub :D

So, I had to include an explicit definition of linting and formatting in the lesson itself, otherwise the anchors would not be as straightforward and might've lead to confusion. I've dropped mention of Standard and brought instructions on how to change particular rules and how to inherit configuration from other .rubocop.yml files. I am not sure whether they should live where they do or whether they should come after/before .rubocop.yml explanation and enabling NewCops.

I wonder if the install/run knowledge checks aren't too close to each other and overall too laconic:

Go back and install RuboCop locally (as in, use Bundler) and then run bundle exec rubocop in your terminal.

On one hand, it is just that easy and this knowledge should be present due to the previous Bundler lesson but I wonder if those two knowledge checks should be merged into one. But perhaps the questions themselves being there are important, to check whether folks actually know.

As for requests - please check the Metrics section to make sure it is clear and correct :)

In short:

  • Is the order for .rubocop.yml configuration and inline configuration OK? (general overview of the config file, then inline, then more detailed explanation of configuring)?
  • Is the Metrics section good?
  • Do knowledge checks make sense where they are and is content they link to enough?

@JoshDevHub
Copy link
Contributor

Is the order for .rubocop.yml configuration and inline configuration OK? (general overview of the config file, then inline, then more detailed explanation of configuring)?

I think the order is great. The lesson flows very well in my opinion.

There may be an argument later to split this up (the same way we're thinking of splitting up the bundler / project organization lesson). Maybe there can be a Introduction/setup lesson and then a lesson for configuration? I'm fine to shift this to a different PR though.

Is the Metrics section good?

I think it's great! Wish I had it while I was learning 😆

Do knowledge checks make sense where they are and is content they link to enough?

They all seem good to me 👍

@JoshDevHub
Copy link
Contributor

@scheals Can you try to merge upstream main and see if that fixes whatever is happening with the linter action?

Also feel free to mark this as ready for review.

One thing was curious for your thoughts on: where do you think the two new lessons should be positioned within the Ruby course?

@scheals
Copy link
Contributor Author

scheals commented May 22, 2024

Linter is not happy but I don't think it needs to be corrected:
image
This is about:
image

As for placement, I think they should be introduced right after Object Oriented Programming, of course Bundler lesson before RuboCop one. In the future I could see that project that was thought about way in the past that'd be about extending existing app would come before the RuboCop lesson. If that ever comes to fruition, of course.

@scheals scheals marked this pull request as ready for review May 22, 2024 17:54
Copy link
Contributor

@JoshDevHub JoshDevHub left a comment

Choose a reason for hiding this comment

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

I agree with that placement I think.

Also this PR should be good to go. Here are the next steps:

  • Merge the bundler lesson and this one (I'll handle this of course)
  • Add the 2nd PR for the images in this lesson. You can follow our guide for adding images if you've never done this. Basically this adds the images to our CDN setup.
  • PR to the main site repo that adds the lessons. You can find the guide for that on the main site repo's wiki

After that, we should be done 🥳

@JoshDevHub JoshDevHub merged commit 270b3d2 into TheOdinProject:main May 23, 2024
2 of 3 checks passed
@scheals scheals deleted the feat/rubocop_lesson branch May 23, 2024 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content: Ruby Involves the Ruby course
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ruby Course: Add Rubocop / Linting Lesson
3 participants