<commit_before>local helper = {}

local dir_sep = package.config:sub(1, 1)

-- Return path to root directory when run from `path`.
local function antipath(path)
   local _, level = path:gsub(dir_sep, "")
   return (".."..dir_sep):rep(level)
end

-- Try to load a lua module from `file_path` when run from `loc_path`.
local function try_load(loc_path, file_path)
   local real_path = antipath(loc_path)..file_path
   local fd = io.open(real_path, "rb")

   if not fd then
      return
   end

   local src = fd:read("*a")
   fd:close()
   local func, err = (loadstring or load)(src, "@"..file_path) -- luacheck: compat
   return err or func
end

-- Return a package searcher which, when run from `loc_path`,
-- loads lua libraries from `lib_path`.
function helper.prefix_searcher(loc_path, lib_path)
   return function(package_name)
      local package_path = lib_path..package_name:gsub("%.", dir_sep)
      return try_load(loc_path, package_path..".lua") or
         try_load(loc_path, package_path..dir_sep.."init.lua"), package_name
   end
end

function helper.luacov_config(prefix)
   return {
      statsfile = prefix.."luacov.stats.out",
      reportfile = prefix.."luacov.report.out",
      deletestats = false,
      runreport = false,
      include = {"luacheck/.+$"},
      exclude = {}
   }
end

local luacov = package.loaded.luacov or package.loaded["luacov.runner"]

-- Returns command that runs `luacheck` executable from `loc_path`.
function helper.luacheck_command(loc_path)
   loc_path = loc_path or "."
   local prefix = antipath(loc_path)<commit_msg>Fix travis coveralls<commit_after>local helper = {}

local dir_sep = package.config:sub(1, 1)

-- Return path to root directory when run from `path`.
local function antipath(path)
   local _, level = path:gsub(dir_sep, "")
   return (".."..dir_sep):rep(level)
end

-- Try to load a lua module from `file_path` when run from `loc_path`.
local function try_load(loc_path, file_path)
   local real_path = antipath(loc_path)..file_path
   local fd = io.open(real_path, "rb")

   if not fd then
      return
   end

   local src = fd:read("*a")
   fd:close()
   local func, err = (loadstring or load)(src, "@"..file_path) -- luacheck: compat
   return err or func
end

-- Return a package searcher which, when run from `loc_path`,
-- loads lua libraries from `lib_path`.
function helper.prefix_searcher(loc_path, lib_path)
   return function(package_name)
      local package_path = lib_path..package_name:gsub("%.", dir_sep)
      return try_load(loc_path, package_path..".lua") or
         try_load(loc_path, package_path..dir_sep.."init.lua"), package_name
   end
end

function helper.luacov_config(prefix)
   return {
      statsfile = prefix.."luacov.stats.out",
      reportfile = prefix.."luacov.report.out",
      deletestats = false,
      runreport = false,
      include = {"luacheck/[^/]+$"},
      exclude = {}
   }
end

local luacov = package.loaded.luacov or package.loaded["luacov.runner"]

-- Returns command that runs `luacheck` executable from `loc_path`.
function helper.luacheck_command(loc_path)
   loc_path = loc_path or "."
   local prefix = antipath(loc_path)
{'fraction_non_alphanumeric': 0.12547649301143582, 'fraction_numerical': 0.0012706480304955528, 'mean_word_length': 3.5703918722786647, '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': '6489867', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1038, 'n_words': 279}