A public repository like GitHub makes checks for common errors like this really easy. Would it be feasible for GitHub or the community to automatically recognize broad classes of these likely errors and notify the authors? How sophisticated could that sort of tool become?
Maybe "given enough bots, most bugs are shallow".
>> Yeah, maybe the answer is a hybrid, bots that look for common mistakes and a website that lets people login to github and displays the potential fixes so they can fix the code in the browser and send the pull request. Like a way to try and introduce people to open source through guided fixes more or less. [1]
Maybe we can create a resource of common typos in numerical constants that would auto-detect by edit distance? But I suppose most people willing to check a resource like that probably already double check their arithmetic. (That said, I've probably had this exact bug somewhere in my coding history, so no shame.)
SECONDS_PER_23_5_HOURS = 84600A day is a day, it's not 86400 seconds.
Or, are there languages where you can't declare a constant with a multiplication expression?
obviously PHP.
php > const X = 1;
php > echo X;
1
php > const Y = 1 * 2;
Parse error: parse error, expecting `','' or `';'' in php shell code on line 1
php > echo Y;
YTime makes my brain hurt sometimes.