<commit_before>rule "FC025", "Prefer chef_gem to compile-time gem install" do
  tags %w{correctness deprecated}
  recipe do |ast|
    gem_install = ast.xpath("//stmts_add/assign[method_add_block[command/ident/
      @value='gem_package'][do_block/stmts_add/command[ident/@value='action']
      [descendant::ident/@value='nothing']]]")
    gem_install.map do |install|
      gem_var = install.xpath("var_field/ident/@value")
      unless ast.xpath("//method_add_arg[call/
        var_ref/ident/@value='#{gem_var}']
        [arg_paren/descendant::ident/@value='install' or
         arg_paren/descendant::ident/@value='upgrade']").empty?
        gem_install
      end
    end
  end<commit_msg>Fix FC025 for Ruby 2.5<commit_after>rule "FC025", "Prefer chef_gem to compile-time gem install" do
  tags %w{correctness deprecated}
  recipe do |ast|
    # when Ruby 2.4 support goes away this can be simplified to remove the
    # do_block/stmts_add/command case which is Ruby 2.4
    gem_install = ast.xpath("//stmts_add/assign[method_add_block[command/ident/
      @value='gem_package'][do_block/bodystmt/stmts_add/command[ident/@value='action'] | do_block/stmts_add/command[ident/@value='action']
      [descendant::ident/@value='nothing']]]")
    gem_install.map do |install|
      gem_var = install.xpath("var_field/ident/@value")
      unless ast.xpath("//method_add_arg[call/
        var_ref/ident/@value='#{gem_var}']
        [arg_paren/descendant::ident/@value='install' or
         arg_paren/descendant::ident/@value='upgrade']").empty?
        gem_install
      end
    end
  end
{'fraction_non_alphanumeric': 0.14294750158127767, 'fraction_numerical': 0.009487666034155597, 'mean_word_length': 3.8085106382978724, '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': '4772247', 'n_tokens_mistral': 554, 'n_tokens_neox': 532, 'n_words': 91}