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

Show Ruby version of the current dir for rubocop -V #13347

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

Earlopain
Copy link
Contributor

The rules are complex, even within the same project different ruby versions can be used for analysis. This makes rubocop -V output the ruby version of the current working directory.

The first commit is a bit of cleanup. It was more difficult than necessary to understand where the version method is being used and how. Most callers simply want RuboCop::Version::STRING, i've updated these places. I wanted to just remove the debug option since it is marked private but standardrb uses it and other places use RuboCop::Version.version as well anyways, regardless of intended visibility. Instead I've left a note, so that if it does get changed in the future, it can be more coordinated.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

…tput

This method really does two things.
While it is marked as private api, some external code uses it as an alias for
`Version::STRING`. Additionally, standardrb uses it to
programatically output the same verbose output that RuboCop does.
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 17, 2024

even within the same project different ruby versions can be used for analysis.

It never crossed my mind someone might want to do something like this, but I guess in makes sense in some mono-repo setups when you have multiple projects.

@bbatsov bbatsov merged commit d204188 into rubocop:master Oct 17, 2024
22 checks passed
@Earlopain
Copy link
Contributor Author

Yeah, monorepos are a possible use-case. Rails uses rubocop-md and analyses code with a more recent version that what they themselves support so they can use more modern syntax in docs.

@Earlopain Earlopain deleted the rubocop-V-ruby-version branch October 17, 2024 08:44
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.

2 participants