Skip to content

Instantly share code, notes, and snippets.

@mozfreddyb
Last active February 22, 2021 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mozfreddyb/4baa712a61d6504ad35bf995f2ab7e6c to your computer and use it in GitHub Desktop.
Save mozfreddyb/4baa712a61d6504ad35bf995f2ab7e6c to your computer and use it in GitHub Desktop.
turn searchfox results object into audit spreadsheet
/* This script can be run on a searchfox.org results page as it is.
* the results.normal from line 9 is already in global scope and can be iterated as it is
* Note that this "results.normal" does /not/ include occurences in tests or generated code.
* Use other properties of the "results" object instead, if you need these.
*/
// objkey is something like "Uses (searchterm)"
objkey = Object.keys(results.normal)[0];
occs = results.normal[objkey];
t = [];
for (let file of occs) {
for (let instnce of file.lines) {
a = {loc: file.path+':'+instnce.lno,
context: instnce.context,
sourcetext: instnce.line
}
console.log(a.loc, '#', a.context, '#', a.sourcetext);
//t.push(auditline)
}
}
//console.table(t);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment