<commit_before># encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::NonNilCheck do
  subject(:cop) { described_class.new }

  it 'registers an offense for != nil' do
    inspect_source(cop, 'x != nil')
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights).to eq(['!='])
  end

  it 'registers an offense for !x.nil?' do
    inspect_source(cop, '!x.nil?')
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights).to eq(['!x.nil?'])
  end

  it 'registers an offense for not x.nil?' do
    inspect_source(cop, 'not x.nil?')
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights).to eq(['not x.nil?'])
  end

  it 'autocorrects by removing != nil' do
    corrected = autocorrect_source(cop, 'x != nil')
    expect(corrected).to eq 'x'
  end

  it 'autocorrects by removing non-nil (!x.nil?) check' do
    corrected = autocorrect_source(cop, '!x.nil?')
    expect(corrected).to eq 'x'
  end
end<commit_msg>failing test case for NonNilCheck<commit_after># encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::NonNilCheck do
  subject(:cop) { described_class.new }

  it 'registers an offense for != nil' do
    inspect_source(cop, 'x != nil')
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights).to eq(['!='])
  end

  it 'registers an offense for !x.nil?' do
    inspect_source(cop, '!x.nil?')
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights).to eq(['!x.nil?'])
  end

  it 'registers an offense for not x.nil?' do
    inspect_source(cop, 'not x.nil?')
    expect(cop.offenses.size).to eq(1)
    expect(cop.highlights).to eq(['not x.nil?'])
  end

  it 'autocorrects by removing != nil' do
    corrected = autocorrect_source(cop, 'x != nil')
    expect(corrected).to eq 'x'
  end

  it 'autocorrects by removing non-nil (!x.nil?) check' do
    corrected = autocorrect_source(cop, '!x.nil?')
    expect(corrected).to eq 'x'
  end

  it 'does not blow up when autocorrecting implicit receiver' do
    corrected = autocorrect_source(cop, '!nil?')
    expect(corrected).to eq 'self'
  end
end
{'fraction_non_alphanumeric': 0.15321805955811718, 'fraction_numerical': 0.0038424591738712775, 'mean_word_length': 3.7233560090702946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1877601', 'n_tokens_mistral': 777, 'n_tokens_neox': 755, 'n_words': 192}