Module:Sandbox/trappist the monk/parameter match test explained

--2 parameters extracted from the cs1|2 whitelist module and from the cs1|2 configuration module. In general,these lists should match.

the module returns one of five tables. In the debug console the commands are: =p.aliases – returns the list of parameters and their associated meta parameter from the ~/Configuration module =p.aliases_dups – returns a list of parameters that appear in more than one meta parameter (not necessarily a bad thing depending on the version of the cs1|2 module suite) =p.whitelist – returns the list of parameters from the ~/Whitelist module =p.alias_params_not_in_whitelist – returns a list of parameters found in the ~/Configuration module but not found in the ~/Whitelist module =p.wh_params_not_in_aliases – returns a list of parameters found in the ~/Whitelist module but not found in the ~/Configuration module

set to true to run the above comparisons against the module suite's sandboxen. if sandboxen don't exist, is ignored

copies of this module are located at: da:Modul:Sandkasse/trappist the monk/parameter match test en:Module:Sandbox/trappist_the_monk/parameter_match_test es:Módulo:Zona de pruebas/trappist_the_monk/parameter_match_test -- couldn't create there; I don't have permission it:Modulo:Sandbox/trappist_the_monk/parameter_match_test no:Modul:Sandbox/trappist the monk/parameter match test pt:Módulo:Usuário(a)/trappist the monk/parameter match test tr: -- couldn't create there; I don't have permission?

require('strict');

local lang_code = mw.language.getContentLanguage:getCode; -- so that this can be used at multiple wikis--lang_code = 'TR'; -- for those wikis where I do not have permission to create this module; uppercase to use local copieslocal use_sandboxen = false; -- set to true to evaluate the modules suite's sandboxen

local module; -- name of module to be loaded is assembled here

local modules =

local sandboxen =

local whitelist_m = mw.loadData (table.concat);local whitelist_t = ; -- a master list of all whitelist parameters

local simple_sections =

local special_sections = ;

local configuration_m = mw.loadData (table.concat);local aliases_t = ; -- a master k/v table of all parameter aliaseslocal aliases_dups_t = ; -- a sequence table of parameter aliases that are used in multiple metaparameters

local wh_params_not_in_aliases_t = ; -- a sequence table of whitelist parameters not found in the master aliases listlocal alias_params_not_in_whitelist_t = ; -- a sequence table of alias list parameters not found in the master whitelist

for _, section in ipairs (simple_sections) do if whitelist_m[section] then -- not all simple sections used in every cs1|2 implementation for k, _ in pairs (whitelist_m[section]) do -- for each of the whitelist tables that do not have subtables whitelist_t[k] = section; -- save the parameter name with section name (just because and all = true is boring) end endend

if whitelist_m[special_sections[1]] or whitelist_m[special_sections[1]] then -- not all implementations of cs1|2 have these sections for _, section in ipairs (special_sections) do for k1, v1_t in pairs (whitelist_m[section]) do for k, v in pairs (whitelist_m[section][k1]) do whitelist_t[k] = table.concat ; -- save the parameter name with section name (just because and all = true is boring) end end endend

for meta, params_t in pairs (configuration_m.aliases) do -- build a list of all parameters in the ~/Configuration aliases table if 'table'

type (params_t) then -- when only one parameter assigned to (parameter) it is type string for _, param in ipairs (params_t) do -- loop through the sequence table of parameters associated with if aliases_t[param] then -- if already in table.insert (aliases_dups_t, table.concat); -- make a note else aliases_t[param] = meta; -- add this with its associated to end if param:find ('#', 1, true) then -- if this is an enumerated parameter param = param:gsub ('#', ); -- make a parameter without enumeration if aliases_t[param] then -- if already in if meta ~= aliases_t[param] then table.insert (aliases_dups_t, table.concat); -- make a note end else aliases_t[param] = meta; -- add this with its associated to end end end

elseif 'string'

type (params_t) then -- here when is a string local param = params_t; if aliases_t[param] then -- if already in table.insert (aliases_dups_t, table.concat); -- make a note else aliases_t[param] = meta; -- add this with its associated to end

elseif 'number'

type (params_t) then -- here when is a number local param = params_t; param = table.concat ; aliases_t[param] = meta; -- add this with its error message to endend

for id, v_t in pairs (configuration_m.id_handlers) do for k, param in ipairs (v_t.parameters) do if aliases_t[param] then -- if already in table.insert (aliases_dups_t, table.concat); -- make a note else aliases_t[param] = table.concat ; -- add this with its associated id_hamdler to end end

local param = v_t.custom_access; if param and aliases_t[param] then -- if already in table.insert (aliases_dups_t, table.concat); -- make a note elseif param then aliases_t[param] = table.concat ; -- add this with its associated id_hamdler to endend

for wl_param, _ in pairs (whitelist_t) do if not aliases_t[wl_param] then table.insert (wh_params_not_in_aliases_t, wl_param); endend

for alias, meta in pairs (aliases_t) do if not whitelist_t[alias] then table.insert (alias_params_not_in_whitelist_t, table.concat); endend

table.sort (wh_params_not_in_aliases_t); -- sort so the lists are more pretty-liketable.sort (alias_params_not_in_whitelist_t);table.sort (aliases_dups_t);

table.insert (wh_params_not_in_aliases_t, 1, -- insert headers to describe the lists table.concat);table.insert (alias_params_not_in_whitelist_t, 1, table.concat);table.insert (aliases_dups_t, 1, table.concat);

local aliases = mw.dumpObject (aliases_t);local aliases_dups = table.concat (aliases_dups_t, '\n\t');local wh_params_not_in_aliases = table.concat (wh_params_not_in_aliases_t, '\n\t');local whitelist = mw.dumpObject (whitelist_t);local alias_params_not_in_whitelist = table.concat (alias_params_not_in_whitelist_t, '\n\t');

return