-
Notifications
You must be signed in to change notification settings - Fork 27
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
Create a cop to validate gem version annotations in RBI files #199
Conversation
029c92d
to
436eddc
Compare
lib/rubocop/cop/sorbet/rbi_versioning/valid_gem_version_annotations.rb
Outdated
Show resolved
Hide resolved
spec/rubocop/cop/sorbet/rbi_versioning/valid_gem_version_annotations_spec.rb
Show resolved
Hide resolved
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
436eddc
to
477c2b0
Compare
477c2b0
to
f0424ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make sure the annotation is attached to a class/method/attr node? Or we don't care about this yet?
lib/rubocop/cop/sorbet/rbi_versioning/valid_gem_version_annotations.rb
Outdated
Show resolved
Hide resolved
lib/rubocop/cop/sorbet/rbi_versioning/valid_gem_version_annotations.rb
Outdated
Show resolved
Hide resolved
f0424ea
to
b9fa1da
Compare
b9fa1da
to
eaeba24
Compare
@Morriar Great question -- how do you generally think about what goes in the same Rubocop rule vs different rules? Like I could imagine that being in a rule called "NoOrphanedVersionAnnotations" or something like that? |
@egiurleo I think it would be better in the same cop but we can merge this now and iterate in another PR 👍 |
lib/rubocop/cop/sorbet/rbi_versioning/gem_version_annotation_helper.rb
Outdated
Show resolved
Hide resolved
|
||
if gem_versions.empty? | ||
message = format(MSG, versions: "empty version") | ||
add_offense(comment, message: message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this cop will be enabled in rbi-central
. Have we considered having the default case not error to make the onboarding easier (both here and in rbi
logic)? Or do we want to manually add versions to existing annotations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh this is only if someone writes # @version
but then doesn't actually provide any version numbers! Any code without any comment or a different comment will be left alone :)
lib/rubocop/cop/sorbet/rbi_versioning/valid_gem_version_annotations.rb
Outdated
Show resolved
Hide resolved
While adding gem version annotations to RBI files would allow developers to write more comprehensive RBIs for their gems, it has has the potential to create RBI files that are cluttered, disorganized, or incorrect. This would be the first of a few cops meant to keep versioned RBIs clean and accurate. This cop checks that every version included in a "@Version" annotation fits the format specified by the RBI library.
eaeba24
to
3cffa24
Compare
Created as part of hackdays, along with Shopify/rbi#180 and Shopify/tapioca#1585
While adding gem version annotations to RBI files would allow developers to write more comprehensive RBIs for their gems, it has has the potential to create RBI files that are cluttered, disorganized, or incorrect.
This would be the first of a few cops meant to keep versioned RBIs clean and accurate.
This cop checks that every version included in a "@Version" annotation fits the format specified by the RBI library.