yard icon indicating copy to clipboard operation
yard copied to clipboard

gemspec: Avoid including .rubocop.yml

Open olleolleolle opened this issue 2 years ago • 1 comments

Description

This PR removes a (1) file from the gemspec's files directive.

With default settings, a consuming project could inadvertently end up including the directives set up for the Yard project.

Example: a setup where there's a temporary directory with gems inside the app.

Error: The `Style/MethodMissingSuper` cop has been removed since it has been superseded by `Lint/MissingSuper`. Please use `Lint/MissingSuper` instead.
(obsolete configuration found in app/views/jasmine/tmp/devbox/gems_inside_the_current_ruby_install/gems/yard-0.9.27/.rubocop.yml, please update it)

Completed Tasks

  • [x] I have read the Contributing Guide.
  • [x] The pull request is complete (implemented / written).
  • [x] Git commits have been cleaned up (squash WIP / revert commits).
  • [ ] I wrote tests and ran bundle exec rake locally (if code is attached to PR).

olleolleolle avatar Aug 09 '22 14:08 olleolleolle

I mostly think that removing the file should be okay, but I'm not sure about the specific motivation for this change.

In the case you've described, Rubocop is (helpfully) telling you that it's running against a source tree that it probably shouldn't be. Put another way, if Rubocop is going to be running against YARD source (which it is in this example), it should probably at least be following consistent linter rules for the source tree so as not to accidentally autofix and reformat a bunch of code.

If this is just about the specific Style/MethodMissingSuper rule from logging a messy warning to the user, then it seems like we should probably be addressing that directly, which this PR does not do. In other words, it kind of seems to me like the intent of this PR is to silence a warning rather than fix the root cause. The better fix would be to update the lint rule IMO.

PS: in either case you likely want to update the outer project's configuration to exclude vendored gem directories in your source tree, since this will likely reduce the amount of unncessary work Rubocop is doing significantly.

lsegal avatar Aug 09 '22 17:08 lsegal

It would make sense to reduce the gem size by removing files not needed for the runtime, e.g.:

  • benchmarks
  • docs
  • po/ja.po
  • .github/*
  • Rakefile
  • Gemfile
  • .rspec
  • ...

pirj avatar Jan 08 '23 18:01 pirj

This was pulled from #1480, but thank you for starting the conversation!

lsegal avatar Apr 08 '23 19:04 lsegal