Open samreid opened 6 years ago
I have been grinding through many TODOs in Wave Interference and interested to see the big picture of the progress, so I threw something together quickly. Here is the plot of Lines of Code and TODOs (multiplied by 50) vs time:
Here is the script that can be used to gather that data (or similar metrics) for any repo. I expect I'll want to use it again, and it may be useful to others on the team, but I'm not sure where to commit it:
// Copyright 2018, University of Colorado Boulder
/**
* usage:
* cd {{repo}}
* node ../perennial/js/scripts/repo-report.js > out.txt
* then import in Excel
*
* @author Sam Reid (PhET Interactive Simulations)
*/
const { exec } = require( 'child_process' ); // eslint-disable-line
exec( 'git rev-list master', ( error, stdout, stderr ) => {
'use strict';
if ( error ) {
console.error( `exec error: ${error}` );
return;
}
if ( stderr.length === 0 && stdout.length !== 0 ) {
const lines = stdout.trim().split( /\n/ ).reverse();
console.log( 'sha' + '\t' + 'date' + '\t' + 'LOC' + '\t' + 'TODO' + '\t' + 'REVIEW' );
const visit = function( index ) {
exec( 'git checkout ' + lines[ index ], ( error, stdout, stderr ) => {
exec( 'grep -ro "TODO" ./js/ | wc -l', ( error, stdout, stderr ) => {
const todoCount = stdout.trim();
exec( 'grep -ro "REVIEW" ./js/ | wc -l', ( error, stdout, stderr ) => {
const reviewCount = stdout.trim();
exec( 'git log -1 --format=format:\'%ai\'', ( error, stdout, stderr ) => {
const date = stdout.trim();
exec( '( find ./js/ -name \'*.js\' -print0 | xargs -0 cat ) | wc -l', ( error, stdout, stderr ) => {
const lineCount = stdout.trim();
// console.log( 'hello ' + lines[ index ] );
// console.log( stdout.trim() );
// console.log( stdout.trim() );
console.log( lines[ index ] + '\t' + date + '\t' + lineCount + '\t' + todoCount + '\t' + reviewCount );
if ( index < lines.length - 1 ) {
visit( index + 1 );
}
else {
// done
exec( 'git checkout master', ( error, stdout, stderr ) => {
// console.log( 'checked out master' );
} );
}
} );
} );
} );
} );
} );
};
visit( 0 );
}
} );
@jonathanolson can you recommend a repo/directory where something like this could be committed?
perennial seems fine to me, under js/scripts/?
Sounds great, thanks!
Initial version checked in and working ok, we can update/refine it later as needed. Closing.
Reopening. This TODO by @zepumph has not been addressed:
* TODO https://github.com/phetsims/tasks/issues/942 This is a "quick" version which could benefit from documentation, better command line hygiene, more options, etc.
I have not worked on this file at all, over to you @samreid.
No work planned at the moment, unassigning.
It could be useful to visualize a number of metrics for a GitHub repository as a function of time. For instance, number of files, lines of code, lines of comments, number of TODOs, number of REVIEW comments and publication dates. This may be a meaningful data point in understanding the lifecycle of a sim in development. Different developers wield
TODO
andREVIEW
differently, so results wouldn't be 100% cross-compatible, but this could still be useful.I was picturing something like using
git rev-list master
, then iterating over commits and running a command to get a snapshot of metrics like the above at each time, then plotting them as a function of time.I'm not planning on working on it now, but it seemed useful enough to at least write it down. It also seems like it wouldn't take much time to develop something useful if we (a) constrain ourselves to look at master, and (b) output to raw text, assuming we can import to excel or the likes, and maybe (c) only include easily/automatically computed metrics (e.g. omit publication date).