A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rubocop/rubocop/issues/14329 below:

Lint/LiternalAsCondition false positive in case statement · Issue #14329 · rubocop/rubocop · GitHub

Expected behavior

It should not detect any problem, because this is not a condition in the sense of an if/unless.

Actual behavior

Describe here what actually happened.

Offenses:

lib/blacklight.rb:32:48: W: Lint/LiteralAsCondition: Literal 'solr' appeared as a condition.
    case connection_config&.fetch(:adapter) || 'solr'
Steps to reproduce the problem

Error occurs on first line.

    case connection_config&.fetch(:adapter) || 'solr'
    when 'solr'
      Blacklight::Solr::Repository
    when /::/
      connection_config[:adapter].constantize
    else
      raise "The value for :adapter was not found in the blacklight.yml config" unless connection_config.key? :adapter

      Blacklight.const_get("#{connection_config.fetch(:adapter)}/Repository".classify)
    end
RuboCop version
bundle exec rubocop -V
1.76.2 (using Parser 3.3.8.0, rubocop-ast 1.45.1, analyzing as Ruby 3.2, running on ruby 3.4.1) [arm64-darwin24]
  - rubocop-capybara 2.22.1
  - rubocop-rspec 3.6.0
  - rubocop-rspec_rails 2.31.0
  - rubocop-rails 2.32.0
  - rubocop-factory_bot 2.27.1

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4