I'm new to Yard, but have taken on maintenance of a project which uses it. When I run rake yard it succeeds but emits a warning:
[warn]: in YARD::Handlers::Ruby::AttributeHandler: Undocumentable Configuration::VALID_OPTIONS_KEYS
in file 'lib/pocket/api.rb':7:
7: attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
The repo is at https://github.com/turadg/pocket-ruby
I've looked at Yard's documentation and I understand this may be related to the use of the splat operator (*) but I'm unsure how to eliminate the warning. Any advice?
Ruby 3.0.1, Yard 0.9.26
Related
I'm getting repetitive warnings upon running a ruby script in a crontab, as well as manually in the terminal.
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/2.7.0/net/protocol.rb:66: warning: already initialized constant Net::ProtocRetryError
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:68: warning: previous definition of ProtocRetryError was here
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/2.7.0/net/protocol.rb:206: warning: already initialized constant Net::BufferedIO::BUFSIZE
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:208: warning: previous definition of BUFSIZE was here
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/2.7.0/net/protocol.rb:503: warning: already initialized constant Net::NetPrivate::Socket
/Users/rich/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/net-protocol-0.1.2/lib/net/protocol.rb:504: warning: previous definition of Socket was here
I've changed the script to either use net/http or Faraday, the latter I'm assuming requires the first. Having seen this behaviour before recently and way back, this is a reload of the net gem, which is part of the core if I am correct. I'm just not sure why it's reloading.
I'm using rbenv to juggle ruby versions for a couple of reasons, and that won't change. My shebang is #!/Users/rich/.rbenv/shims/ruby but my ruby version is a bit different:
$ which ruby
==> /Users/rich/.rbenv/versions/2.7.4/bin/ruby
$ ruby -v
==> Ruby version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [arm64-darwin21]
This slight difference from the shebang and requested versions of ruby might be the issue. I have many scripts that rely on that shebang, which points to the current rbenv version, which is what I want. I change versions from time to time and don't want to hard code that instruction.
Is there a way I can see why this is happening? How can I make these go away? How can I stop reloading core gems that are already loaded?
Bundler was the culprit with some dependency issues and reloading various versions on top of previous Gemfile.lock versions...something like that. Update this way:
bundle update --bundler
I had to add the following 2 lines to the Gemfile to finally eliminate the all the warnings:
gem 'net-http'
gem 'uri', '0.10.0' # force the default version for ruby 2.7
In ruby 2.7 I having a lot of warnings like this:
<main>: warning: __FILE__ in eval may not return location in binding; use Binding#source_location instead
/Users/user/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pry-nav-0.3.0/lib/pry-nav.rb:17:
warning: in `eval'
The RUBYOPT with such parameters doesn't work:
-W:no-deprecated -W:no-experimental
This is pry specific and it should have been fixed, see this commit.
Update pry (which pry-rails has a dependency) to v0.13.0
Edit: On the other hand, pry-nav which also seems to be involved in your issues currently asks for something lower than v0.13.0, so it might not work just like this out of the box. You have to get it to run with the latest pry.
I'm seeing a somewhat peculiar error in Jenkins where a gem is being invoked correctly, but the error is spitting out an option with a whitespace character between the options identifier (--) and the option name (checksum).
gemname publish_artifact --version 0.1.0 --checksum 01fakechecksum89 --repository release
publish_artifact: unrecognised option -- checksum
I checked the Jenkins node and the option is available. I haven't run the command because the deployment is not mine to make, I'm just on the ops team and am not really that familiar with Ruby yet.
I ran a command with a fake option for a different gem and got a different error response.
$ yard list --fakename blah
[warn]: Unrecognized/invalid option: --fakename
Notice no whitespace between the option specifier and the name. I'm digging into the Jenkins pipeline configuration because it is quite complex, and maybe the command is getting butchered between the master and the node, but it just doesn't make much sense to me.
It turned out to be a rather misleading error. The problem was that gem failed to update to the newest version. The older version didn't have the checksum option.
I started maintaining a big app with tons of Squeel queries.
The latest Squeel version (>1.1) is deprecating code extensions:
DEPRECATION WARNING: Core extensions are deprecated and will be
removed in Squeel 2.0.
Is there an easy way to grep for the this deprecated symbol and hash core extensions?
I think you can use RuboCop to find the usage of deprecated methods.
Installed it with:
$ gem install rubocop
and then in your project root run
$ rubocop
EDIT:
You could actually use the idea from https://stackoverflow.com/a/5515144/1006863 to print a message every time a method is used.
Other option would be to redefine every method by add the deprecation or fork the project and add it yourself and then ask for a merge request. If it's denied you can keep using your version by specifying the repository in your Gemfile.
The documentation for the minitest-ci gem (seemingly the only option for producing test results for a CI tool such as Jenkins) has the extremely annoying habit of not preserving the results of rake minitest:models when invoked as rake minitest - the test results from running minitest:models are deleted prior to running the rest of the tests. minitest-ci's barely-extant documentation claims adding this to test_helper.rb will disable the troublesome auto-clean behavior, but it doesn't:
# Why do SO and GitHub have to use completely different ways of indicating inline code?
# test/helper.rb
MiniTest::Ci.auto_clean = false
Has anyone out there managed to get minitest-ci to preserve all the test result files? I'm reaching wits' end here.
I think ci_reporter gem supports miniTest. This could be another option.