<commit_before>module Awspec::Helper
  module Finder
    module Ec2
      def find_ec2(id)
        # instance_id or tag:Name
        begin
          res = ec2_client.describe_instances({
                                                instance_ids: [id]
                                              })
        rescue
          # Aws::EC2::Errors::InvalidInstanceIDMalformed
          # Aws::EC2::Errors::InvalidInstanceIDNotFound
          res = ec2_client.describe_instances({
                                                filters: [{ name: 'tag:Name', values: [id] }]
                                              })
        end
        # rubocop:enable Style/GuardClause
        if res.reservations.count == 1
          res.reservations.first.instances.single_resource(id)
        elsif res.reservations.count > 1
          raise Awspec::DuplicatedResourceTypeError, "Duplicate instances matching id or tag #{id}"
        else
          nil
        end
      end

      def find_ec2_attribute(id, attribute)
        res = ec2_client.describe_instance_attribute({
                                                       instance_id: id, attribute: attribute
                                                     })
      end<commit_msg>Removed unnecessary else at request of rubocop<commit_after>module Awspec::Helper
  module Finder
    module Ec2
      def find_ec2(id)
        # instance_id or tag:Name
        begin
          res = ec2_client.describe_instances({
                                                instance_ids: [id]
                                              })
        rescue
          # Aws::EC2::Errors::InvalidInstanceIDMalformed
          # Aws::EC2::Errors::InvalidInstanceIDNotFound
          res = ec2_client.describe_instances({
                                                filters: [{ name: 'tag:Name', values: [id] }]
                                              })
        end
        # rubocop:enable Style/GuardClause
        if res.reservations.count == 1
          res.reservations.first.instances.single_resource(id)
        elsif res.reservations.count > 1
          raise Awspec::DuplicatedResourceTypeError, "Duplicate instances matching id or tag #{id}"
        end
      end

      def find_ec2_attribute(id, attribute)
        res = ec2_client.describe_instance_attribute({
                                                       instance_id: id, attribute: attribute
                                                     })
      end
{'fraction_non_alphanumeric': 0.07004830917874397, 'fraction_numerical': 0.008051529790660225, 'mean_word_length': 1.2407574391343552, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5085416', 'n_tokens_mistral': 568, 'n_tokens_neox': 559, 'n_words': 121}