<commit_before># frozen_string_literal: true

module RuboCop
  module Cop
    module Gemspec
      # This cop checks that the `test_files` attribute is not set in a gemspec file.
      # Removing it allows the user to receive smaller packed gems.
      #
      # @example
      #
      #   # bad
      #   Gem::Specification.new do |spec|
      #     spec.name = 'your_cool_gem_name'
      #     spec.test_files = Dir.glob('test/**/*')
      #   end
      #
      #   # bad
      #   Gem::Specification.new do |spec|
      #     spec.name = 'your_cool_gem_name'
      #     spec.test_files += Dir.glob('test/**/*')
      #   end
      #
      #   # good
      #   Gem::Specification.new do |spec|
      #     spec.name = 'your_cool_gem_name'
      #   end
      #
      class TestFilesAssignment < Base
        include RangeHelp
        extend AutoCorrector

        MSG = 'Do not set `test_files` in gemspec.'

        # @!method gem_specification(node)
        def_node_matcher :gem_specification, <<~PATTERN
          (block
            (send<commit_msg>Fix a build error<commit_after># frozen_string_literal: true

module RuboCop
  module Cop
    module Gemspec
      # Checks that the `test_files` attribute is not set in a gemspec file.
      # Removing it allows the user to receive smaller packed gems.
      #
      # @example
      #
      #   # bad
      #   Gem::Specification.new do |spec|
      #     spec.name = 'your_cool_gem_name'
      #     spec.test_files = Dir.glob('test/**/*')
      #   end
      #
      #   # bad
      #   Gem::Specification.new do |spec|
      #     spec.name = 'your_cool_gem_name'
      #     spec.test_files += Dir.glob('test/**/*')
      #   end
      #
      #   # good
      #   Gem::Specification.new do |spec|
      #     spec.name = 'your_cool_gem_name'
      #   end
      #
      class TestFilesAssignment < Base
        include RangeHelp
        extend AutoCorrector

        MSG = 'Do not set `test_files` in gemspec.'

        # @!method gem_specification(node)
        def_node_matcher :gem_specification, <<~PATTERN
          (block
            (send
{'fraction_non_alphanumeric': 0.10052157420578474, 'fraction_numerical': 0.0, 'mean_word_length': 1.7984084880636604, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6123446', 'n_tokens_mistral': 673, 'n_tokens_neox': 666, 'n_words': 160}