influxdb-ruby icon indicating copy to clipboard operation
influxdb-ruby copied to clipboard

query builder: "warning: too many arguments for format string"

Open erikj opened this issue 3 years ago • 0 comments

Performing a client query w/ Ruby warnings enabled and no params passed results in a warning from ruby re: an empty hash as right-hand argument to %:

vendor/ruby/2.7.0/gems/influxdb-0.8.1/lib/influxdb/query/builder.rb:12: warning: too many arguments for format string

Triggering this warning in plain-old ruby:

$ irb -w
irb(main):001:0> "foo" % {}
(irb):1: warning: too many arguments for format string
=> "foo"

Adding a params.empty? check to InfluxDB::Query::Builder#build() seems to address the warning:

params.empty? ? query : query % params

The warning is not a bug per se, but when running code w/ many queries and warnings enabled, such as in a test suite, it can result in diminished signal to noise that obscures warnings from application code.

erikj avatar Aug 17 '21 22:08 erikj