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

Feature idea: Gemspec/GemVersion #10570

Closed
Timothy04 opened this issue Apr 22, 2022 · 0 comments · Fixed by #10572
Closed

Feature idea: Gemspec/GemVersion #10570

Timothy04 opened this issue Apr 22, 2022 · 0 comments · Fixed by #10572

Comments

@Timothy04
Copy link

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

There is already a Bundler/GemVersion cop that enforces gems in the Gemfile to include a version specification.
But this cop doesn't work for gemspec files.

Describe the solution you'd like

I would like either Bundler/GemVersion to also work for gemspec files or to have a new Gemspec/GemVersion cop that would enforce version specifications in gemspec files.

Examples

spec.add_dependency 'redis' # bad
spec.add_dependency 'redis', '~> 4.5.1' # good

spec.add_development_dependency 'faker' # bad
spec.add_development_dependency 'faker', '~> 2.19.0' # good
nobuyo added a commit to nobuyo/rubocop that referenced this issue Apr 29, 2022
Resolve: rubocop#10570.

This cop requires/forbids version specifications or a commit reference for gem dependency in gemspec.

## example

```ruby
# EnforcedStyle: required (default)

# bad
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop'
end

# good
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop', '~> 1.28'
end
```

```ruby
# EnforcedStyle: forbidden

# bad
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop', '~> 1.28'
end

# good
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop'
end
```
bbatsov pushed a commit that referenced this issue Apr 29, 2022
Resolve: #10570.

This cop requires/forbids version specifications or a commit reference for gem dependency in gemspec.

## example

```ruby
# EnforcedStyle: required (default)

# bad
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop'
end

# good
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop', '~> 1.28'
end
```

```ruby
# EnforcedStyle: forbidden

# bad
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop', '~> 1.28'
end

# good
Gem::Specification.new do |spec|
  spec.add_dependency 'rubocop'
end
```
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 a pull request may close this issue.

1 participant