Cop idea: `Gemspec/RubyGemsVersionAssignment` and `Gemspec/SpecificationVersionAssignment` · Issue #10245 · rubocop/rubocop · GitHub
Skip to content

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

Closed
@mishina2228

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions