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

Cop idea: Gemspec/RubyGemsVersionAssignment and Gemspec/SpecificationVersionAssignment #10245

Closed
mishina2228 opened this issue Nov 14, 2021 · 1 comment

Comments

@mishina2228
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I've found some (older) gems using rubygems_version= or specification_version= in a gemspec file.
However, RubyGems source says not to use them.

DO NOT set this, it is set automatically when the gem is packaged.

https://github.com/rubygems/rubygems/blob/cc6f96aa0c1c99d94363d12884001a2de28da033/lib/rubygems/specification.rb#L530-L534
https://github.com/rubygems/rubygems/blob/cc6f96aa0c1c99d94363d12884001a2de28da033/lib/rubygems/specification.rb#L744-L748

I thought it would be a good idea to handle it the same way as Gemspec/DateAssignment, which was added in #9496.

Describe the solution you'd like

I suggest adding cops like Gemspec/RubyGemsVersionAssignment and Gemspec/SpecificationVersionAssignment that warn the use of rubygems_version= or specification_version= in a gemspec file.

Describe alternatives you've considered

Or merge them with Gemspec/DateAssignment and rename it?

Additional context

For example, Jeweler and the gems created by it (e.g. OS) use these fields.

https://github.com/technicalpickles/jeweler/blob/2ab86309fc2494ba2a4e9c86c514742cd4f681c2/jeweler.gemspec#L193
https://github.com/rdp/os/blob/1245b3a1821c5cf0ff5167069f70b70658752491/os.gemspec#L42

@mishina2228
Copy link
Contributor Author

mishina2228 commented Mar 16, 2022

I found a case where rubygems_version was used by mistake where required_rubygems_version should have been used.

kaitithoma added a commit to kaitithoma/rubocop that referenced this issue Jun 15, 2022
Gemspec/DateAssignment functionality is
integrated into Gemspec/DeprecatedAttributeAssignment
kaitithoma added a commit to kaitithoma/rubocop that referenced this issue Jun 15, 2022
Add specification_version and rubygems_version
to Gemspec/DeprecatedAttributeAssignment
bbatsov pushed a commit that referenced this issue Jun 20, 2022
Add specification_version and rubygems_version
to Gemspec/DeprecatedAttributeAssignment
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

No branches or pull requests

1 participant