Add to_s representation to LintRoller::Plugin#6
Open
koic wants to merge 1 commit intostandardrb:mainfrom
Open
Conversation
While developing rubocop/rubocop#13792, I noticed that `LintRoller::Plugin` lacks a string representation. For example, in RuboCop, there is a feature to display a list of plugins using the `rubocop -V` command: ```console $ bundle exec rubocop -V 1.71.2 (using Parser 3.3.7.0, rubocop-ast 1.38.0, analyzing as Ruby 2.7, running on ruby 3.4.1) [x86_64-darwin23] - rubocop-performance 1.23.1 - rubocop-rake 0.6.0 - rubocop-rspec 3.4.0 ``` In cases like this, having a string representation would simplify things. I'm not sure what the best string representation would be, but I have chosen to include the name and version as they provide the minimal and most easily identifiable details.
1395543 to
59372f3
Compare
to_s representation to LintRoller::Plugin`to_s representation to LintRoller::Plugin
bbatsov
reviewed
Feb 8, 2025
| def to_s | ||
| if about.name && about.version | ||
| "#{about.name} #{about.version}" | ||
| elsif about.name |
There was a problem hiding this comment.
I'm wondering if the version should be optional, because even for built-in plugins you still have the version of the containing library. But I guess some people will have RuboCop or Standard plugins in their Rails apps as well. Kind of weird for me, but I've seen this in wild...
Contributor
Author
There was a problem hiding this comment.
Yeah, that's mostly the reason. More practically, this implementation is based on the fact that the attributes in About are not required. Ideally, both the "name and version" should be present, but when they are not, the decision is to display only the "name" instead of the result of inspect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While developing rubocop/rubocop#13792, I noticed that
LintRoller::Pluginlacks a string representation. For example, in RuboCop, there is a feature to display a list of plugins using therubocop -Vcommand:In cases like this, having a string representation would simplify things.
I'm not sure what the best string representation would be, but I have chosen to include the name and version as they provide the minimal and most easily identifiable details.