<commit_before># encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe EnsureReturn do
        let(:er) { EnsureReturn.new }

        it 'registers an offence for return in ensure' do
          inspect_source(er,
                         ['begin',
                          '  something',
                          'ensure',
                          '  file.close',
                          '  return',
                          'end'])
          expect(er.offences.size).to eq(1)
          expect(er.offences.map(&:message))
            .to eq([EnsureReturn::MSG])
        end

        it 'does not register an offence for return outside ensure' do
          inspect_source(er,
                         ['begin',
                          '  something',
                          '  return',
                          'ensure',
                          '  file.close',
                          'end'])
          expect(er.offences).to be_empty
        end

        it 'does not check when ensure block has no body' do
          expect do
            inspect_source(er,
                           ['begin',
                            '  something',
                            'ensure',
                            'end'])
          end.to_not raise_exception

        end
      end
    end
  end<commit_msg>Code style<commit_after># encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Lint
      describe EnsureReturn do
        let(:cop) { EnsureReturn.new }

        it 'registers an offence for return in ensure' do
          inspect_source(cop,
                         ['begin',
                          '  something',
                          'ensure',
                          '  file.close',
                          '  return',
                          'end'])
          expect(cop.offences).to have(1).item
        end

        it 'does not register an offence for return outside ensure' do
          inspect_source(cop,
                         ['begin',
                          '  something',
                          '  return',
                          'ensure',
                          '  file.close',
                          'end'])
          expect(cop.offences).to be_empty
        end

        it 'does not check when ensure block has no body' do
          expect do
            inspect_source(cop,
                           ['begin',
                            '  something',
                            'ensure',
                            'end'])
          end.to_not raise_exception
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.07703984819734346, 'fraction_numerical': 0.0015180265654648956, 'mean_word_length': 0.8869005010737294, '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': '4115334', 'n_tokens_mistral': 620, 'n_tokens_neox': 615, 'n_words': 163}