Skip to content

Version 1.9.0 has a "warning: string literal in condition" warning message #526

Closed
@emmahsax

Description

@emmahsax

Subject of the issue

On the latest new version of Ruby git gem, I see this message:

/Users/emmasax/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/git-1.9.0/lib/git/lib.rb:663: warning: string literal in condition

This error is pointing to this line:

arr_opts << '--gpg-sign' if opts[:gpg_sign] == true || "--gpg-sign=#{opts[:gpg_sign]}" if opts[:gpg_sign]

Looking at the error (StackOverflow describes what the warning message means here), it seems the easiest way to fix it is to change that line to:

arr_opts << '--gpg-sign' if opts[:gpg_sign] && (opts[:gpg_sign] == true || opts[:gpg_sign] == "--gpg-sign=#{opts[:gpg_sign]}")

Your environment

  • Ruby git gem 1.9.0
  • Ruby version 3.0.1 installed with rbenv

Steps to reproduce

Using the newest version of the git Ruby gem with Ruby 3.0.1:

$ irb
irb(main):002:0> require 'git'
/Users/emmasax/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/git-1.9.0/lib/git/lib.rb:663: warning: string literal in condition
=> true

Expected behaviour

$ irb
irb(main):002:0> require 'git'
=> true

Actual behaviour

See the Steps to reproduce section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions