InfluxCommunity / influxdb-ruby

Ruby client for InfluxDB
MIT License
370 stars 133 forks source link

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

Open erikj opened 3 years ago

erikj commented 3 years ago

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.