-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Exclude *.gemspec
files for Rails/TimeZone
cop
#432
Comments
I don't think I've ever seen this field used in a gemspec. The Rubygems source says:
|
I know it, I remember, but I'm working on |
Yeah, I think both are worth it. |
Follow rubocop/rubocop-rails#432. This PR adds new `Gemspec/DateAssignment` cop. This cop checks that `date =` is not used in gemspec file. It is set automatically when the gem is packaged. ```ruby # bad Gem::Specification.new do |spec| s.name = 'your_cool_gem' spec.date = Time.now.strftime('%Y-%m-%d') end # good Gem::Specification.new do |spec| s.name = 'your_cool_gem' end ``` RubyGems doesn't expect the value to be set. https://github.com/rubygems/rubygems/blob/be08d8307eda3b61f0ec0460fe7fbcf647b526e6/lib/rubygems/specification.rb#L1679-L1681
Good idea! I support this. |
…` cop Fixes rubocop#432. This PR excludes gemspec file by default for `Rails/TimeZone` cop.
Thank you. I opened PR #439. It will be applied in the next release :-) |
Thank you for your work! I'll wait and ready to help (it's not too hard to add |
Follow rubocop/rubocop-rails#432. This PR adds new `Gemspec/DateAssignment` cop. This cop checks that `date =` is not used in gemspec file. It is set automatically when the gem is packaged. ```ruby # bad Gem::Specification.new do |spec| s.name = 'your_cool_gem' spec.date = Time.now.strftime('%Y-%m-%d') end # good Gem::Specification.new do |spec| s.name = 'your_cool_gem' end ``` RubyGems doesn't expect the value to be set. https://github.com/rubygems/rubygems/blob/be08d8307eda3b61f0ec0460fe7fbcf647b526e6/lib/rubygems/specification.rb#L1679-L1681
…s_time_zone [Fix #432] Exclude gemspec file by default for `Rails/TimeZone` cop
Hello.
If I'm working on a gem, and it has
rails
as a dependency, also there isspec.date = Time.now.strftime('%Y-%m-%d')
in the*.gemspec
file.Expected behavior
No offenses from
Rails/TimeZone
cop, because gemspec file evaluates atgem build
and it will not require gem dependencies.Actual behavior
There is an offense.
Steps to reproduce the problem
Any gem, add
rails
(I guess, or something related) to gem dependencies (or Gemfile maybe), useTime.now
(or I guess another code forRails/TimeZone
cop) in the*.gemspec
file.RuboCop version
The text was updated successfully, but these errors were encountered: