<commit_before>#!/bin/env lua
local luacheck = require "luacheck"
local format = require "luacheck.format"
local argparse = require "argparse"

local parser = argparse "luacheck"
   :description "luacheck 0.4.0, a simple static analyzer for Lua. "

parser:argument "files"
   :description "List of files to check. "
   :args "+"
   :argname "<file>"

parser:flag "-g" "--no-global"
   :description "Do not check for accessing global variables. "
parser:flag "-r" "--no-redefined"
   :description "Do not check for redefined variables. "
parser:flag "-u" "--no-unused"
   :description "Do not check for unused variables. "
parser:flag "-a" "--no-unused-args"
   :description "Do not check for unused arguments and loop variables. "
parser:flag "-v" "--no-unused-values"
   :description "Do not check for unused values. "

parser:option "--globals"
   :description "Defined globals. Hyphen expands to standard globals. "
   :args "*"
   :argname "<global>"
parser:flag "-c" "--compat"
   :description "Adjust globals for Lua 5.1/5.2 compatibility. "
parser:flag "-d" "--allow-defined"
   :description "Allow accessing globals set elsewhere. "
parser:flag "-e" "--ignore-env"
   :description "Do not be _ENV-aware. "

parser:option "--ignore"
   :description "Do not report warnings related to these variables. "
   :args "+"
   :argname "<var>"
parser:option "--only"
   :description "Only report warnings related to these variables. "
   :args "+"
   :argname "<var>"

parser:option "-l" "--limit"
   :description "Exit with 0 if there are <limit> or less warnings. "
   :convert(tonumber)

parser:flag "-q" "--quiet"
   :count "0-3"
   :description [[Suppress output for files without warnings. 
-qq: Only print total number of warnings and errors. 
-qqq: Suppress output completely. ]]

parser:flag "--no-color"
   :description "Do not color output"

local args = parser:parse()

local options = {
   allow_defined = args["allow-defined"],
   globals = args.globals,
   compat = args.compat,
   env_aware = not args["ignore-env"],
   ignore = args.ignore,
   only = args.only,
   global = not args["no-global"],
   redefined = not args["no-redefined"],<commit_msg>Allow --globals, --ignore and --only to be used several times<commit_after>#!/bin/env lua
local luacheck = require "luacheck"
local format = require "luacheck.format"
local argparse = require "argparse"

local parser = argparse "luacheck"
   :description "luacheck 0.4.0, a simple static analyzer for Lua. "

parser:argument "files"
   :description "List of files to check. "
   :args "+"
   :argname "<file>"

parser:flag "-g" "--no-global"
   :description "Do not check for accessing global variables. "
parser:flag "-r" "--no-redefined"
   :description "Do not check for redefined variables. "
parser:flag "-u" "--no-unused"
   :description "Do not check for unused variables. "
parser:flag "-a" "--no-unused-args"
   :description "Do not check for unused arguments and loop variables. "
parser:flag "-v" "--no-unused-values"
   :description "Do not check for unused values. "

parser:option "--globals"
   :description "Defined globals. Hyphen expands to standard globals. "
   :args "*"
   :count "*"
   :argname "<global>"
parser:flag "-c" "--compat"
   :description "Adjust globals for Lua 5.1/5.2 compatibility. "
parser:flag "-d" "--allow-defined"
   :description "Allow accessing globals set elsewhere. "
parser:flag "-e" "--ignore-env"
   :description "Do not be _ENV-aware. "

parser:option "--ignore"
   :description "Do not report warnings related to these variables. "
   :args "+"
   :count "*"
   :argname "<var>"
parser:option "--only"
   :description "Only report warnings related to these variables. "
   :args "+"
   :count "*"
   :argname "<var>"

parser:option "-l" "--limit"
   :description "Exit with 0 if there are <limit> or less warnings. "
   :convert(tonumber)

parser:flag "-q" "--quiet"
   :count "0-3"
   :description [[Suppress output for files without warnings. 
-qq: Only print total number of warnings and errors. 
-qqq: Suppress output completely. ]]

parser:flag "--no-color"
   :description "Do not color output"

local args = parser:parse()

local function concat_arrays(array)
   if #array > 0 then
      local ret = {}

      for _, subarray in ipairs(array) do
         for _, item in ipairs(subarray) do
            table.insert(ret, item)
         end
      end

      return ret
   end
end

local options = {
   allow_defined = args["allow-defined"],
   globals = concat_arrays(args.globals),
   compat = args.compat,
   env_aware = not args["ignore-env"],
   ignore = concat_arrays(args.ignore),
   only = concat_arrays(args.only),
   global = not args["no-global"],
   redefined = not args["no-redefined"],
{'fraction_non_alphanumeric': 0.13728813559322034, 'fraction_numerical': 0.0044491525423728815, 'mean_word_length': 3.48338081671415, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, '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': '7172457', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1459, 'n_words': 498}