-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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/TestFiles #10065
Comments
Apart from this suggestion, the following RuboCop Packaging documentation (examples) may also be improved. Cc @utkarsh2102 |
Hi @koic,
That seems like a good idea. IIUC, you propose removing any and every mention of |
Right! And I can take the doc improvement of RuboCop Packaging! |
Follow up to rubocop/rubocop#10065 (comment). This PR removes `spec.test_files` from `Packaging/GemspecGit`'s doc.
Fixes rubocop#10065. This PR adds new `Gemspec/TestFilesAssignment` cop. This cop checks that `test_files =` is not used in gemspec file. if removing `test_files =`, then user could receive smaller packed gems. ```ruby # bad Gem::Specification.new do |spec| spec.name = 'your_cool_gem_name' spec.test_files = Dir.glob('test/**/*') end # bad Gem::Specification.new do |spec| spec.name = 'your_cool_gem_name' spec.test_files += Dir.glob('test/**/*') end # good Gem::Specification.new do |spec| spec.name = 'your_cool_gem_name' end ```
Fixes #10065. This PR adds new `Gemspec/TestFilesAssignment` cop. This cop checks that `test_files =` is not used in gemspec file. if removing `test_files =`, then user could receive smaller packed gems. ```ruby # bad Gem::Specification.new do |spec| spec.name = 'your_cool_gem_name' spec.test_files = Dir.glob('test/**/*') end # bad Gem::Specification.new do |spec| spec.name = 'your_cool_gem_name' spec.test_files += Dir.glob('test/**/*') end # good Gem::Specification.new do |spec| spec.name = 'your_cool_gem_name' end ```
Is your feature request related to a problem? Please describe.
I don't think it's necessary to use the
test_files
attribute in a gemspec in most cases, since it has been removed from the gemspec's official document and seems to be no longer recommended.Also, if removing
test_files
, then we could receive smaller packed gems.See also the discussions:
Describe the solution you'd like
I suggest adding a cop like
Gemspec/TestFiles
that warns the use oftest_files
in a gemspec.(I'm not sure about this naming... 😅 )
Describe alternatives you've considered
I have no alternatives.
Additional context
Many gems including Rails have removed
test_files
to reduce a gem size.(see also rails/rails#22272)
The text was updated successfully, but these errors were encountered: