<commit_before># rubocop:disable Lint/UnusedMethodArgument
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
# rubocop:disable Style/Documentation
# rubocop:disable Style/EmptyLinesAroundModuleBody

module Library

  # TODO Comments are needed here to explain how these routines use information
  #      from the 'env' object and their arguments and how they satisfy return-
  #      value requirements. For now, please consult Section 5 in ../README
  #      when reading this code. Other sections of the README may be helpful,
  #      too.

  def lib_build(env, prepkit)
    bindir = env.build.bindir
    binname = env.run.binname
    compiler = env.build.compiler
    srcdir = env.build.ddts_root
    srcfile = env.build.srcfile
    cmd = "cd #{srcdir} && #{compiler} #{srcfile} -o #{bindir}/#{binname}"
    ext(cmd, {msg: "Build failed, see #{logfile}"})
  end

  def lib_build_post(env, buildkit)
    File.join(env.build.ddts_root, env.build.bindir, env.build.binname)
  end

  def lib_build_prep(env)
    FileUtils.cp(File.join(app_dir, env.build.srcfile), env.build.ddts_root)
    FileUtils.mkdir_p(File.join(env.build.ddts_root, env.build.bindir))
  end

  def lib_comp_alt(env, f1, f2)
    logi "Comparing '#{f1}' to '#{f2}' with alternate comparator..."
    FileUtils.compare_file(f1, f2)
  end

  def lib_data(env)
    f = 'data.tgz'
    src = File.join(app_dir, f)
    dst = File.join(tmp_dir, f)
    cmd = "cp #{src} #{dst}"
    md5 = 'd49037f1ef796b8a7ca3906e713fc33b'
    unless File.exists?(dst) and hash_matches(dst, md5)
      logd "Getting data: #{cmd}"
      ext(cmd, {msg: "Failed to get data, see #{logfile}"})
      die "Data archive #{f} has incorrect md5 hash" unless hash_matches(dst, md5)
    end
    logd "Data archive #{f} ready"
    cmd = "cd #{tmp_dir} && tar xvzf #{f}"
    logd "Extracting data: #{cmd}"
    ext(cmd, {msg: "Data extract failed, see #{logfile}"})
    logd 'Data extract complete'
  end

  def lib_outfiles_ex(env, path)
    expr = File.join(path, 'out[0-9]')
    Dir.glob(expr).map { |e| [path, File.basename(e)] }
  end

  def lib_run(env, prepkit)
    rundir = prepkit
    bin = env.run.binname
    run = env.run.runcmd<commit_msg>Fix braces around hash parameters in library.rb<commit_after># rubocop:disable Lint/UnusedMethodArgument
# rubocop:disable Metrics/AbcSize
# rubocop:disable Metrics/MethodLength
# rubocop:disable Style/Documentation
# rubocop:disable Style/EmptyLinesAroundModuleBody

module Library

  # TODO Comments are needed here to explain how these routines use information
  #      from the 'env' object and their arguments and how they satisfy return-
  #      value requirements. For now, please consult Section 5 in ../README
  #      when reading this code. Other sections of the README may be helpful,
  #      too.

  def lib_build(env, prepkit)
    bindir = env.build.bindir
    binname = env.run.binname
    compiler = env.build.compiler
    srcdir = env.build.ddts_root
    srcfile = env.build.srcfile
    cmd = "cd #{srcdir} && #{compiler} #{srcfile} -o #{bindir}/#{binname}"
    ext(cmd, msg: "Build failed, see #{logfile}")
  end

  def lib_build_post(env, buildkit)
    File.join(env.build.ddts_root, env.build.bindir, env.build.binname)
  end

  def lib_build_prep(env)
    FileUtils.cp(File.join(app_dir, env.build.srcfile), env.build.ddts_root)
    FileUtils.mkdir_p(File.join(env.build.ddts_root, env.build.bindir))
  end

  def lib_comp_alt(env, f1, f2)
    logi "Comparing '#{f1}' to '#{f2}' with alternate comparator..."
    FileUtils.compare_file(f1, f2)
  end

  def lib_data(env)
    f = 'data.tgz'
    src = File.join(app_dir, f)
    dst = File.join(tmp_dir, f)
    cmd = "cp #{src} #{dst}"
    md5 = 'd49037f1ef796b8a7ca3906e713fc33b'
    unless File.exists?(dst) and hash_matches(dst, md5)
      logd "Getting data: #{cmd}"
      ext(cmd, msg: "Failed to get data, see #{logfile}")
      die "Data archive #{f} has incorrect md5 hash" unless hash_matches(dst, md5)
    end
    logd "Data archive #{f} ready"
    cmd = "cd #{tmp_dir} && tar xvzf #{f}"
    logd "Extracting data: #{cmd}"
    ext(cmd, msg: "Data extract failed, see #{logfile}")
    logd 'Data extract complete'
  end

  def lib_outfiles_ex(env, path)
    expr = File.join(path, 'out[0-9]')
    Dir.glob(expr).map { |e| [path, File.basename(e)] }
  end

  def lib_run(env, prepkit)
    rundir = prepkit
    bin = env.run.binname
    run = env.run.runcmd
{'fraction_non_alphanumeric': 0.1259009009009009, 'fraction_numerical': 0.014864864864864866, 'mean_word_length': 3.441, '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': '2793030', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1582, 'n_words': 423}