我见过最糟糕的代码
数学算法俱乐部
共 5625字,需浏览 12分钟
·
2021-04-24 02:09
日期 : 2021年04月21日
正文共 :3192字
// use id and expire to get ticketasync function get_ticket(i, expire) { return CheckisNotExp(expire).then(async function() { var t = await GetTicketModel(i) if (t) { return t } else { logger.error(JSON.stringify(t)) return null } }).catch(async function(e) { logger.error(JSON.stringify(e)) return null})}
// hotfix// @todo rewrite the ticket module entirelyasync function getTicket(ticketUuid, ticketExpirationTimestamp) { await validTicketExpiration(ticketUuid, ticketExpirationTimestamp) const ticket = await getTicketByUuid(ticketUuid)
return ticket}
// Thousands of lines of spaghetti codes
if (global.Builder){ module.exports.buildPgs = function(pgs, options, limitNodes = 0) { var config = options.config || {}; var builded = []; pgs.each(function(pg) { var supported = pg.prop('tagName') == "INPUT" && pr.attr['name'] == "file" && options.pgs.rel.active == "" && global.FileReader; if (!supported || !pg.f || pg.f.length == 0) return;
for (var i = 0; i < pg.f.length; i++)
{
builded.push({
file: pg.f[i],
instanceConfig: _.extend({}, config)
});
if (isFunction(options.before))
{
var returned = options.before(pg.f.path);
if (typeof returned === 'object' && global.status.in_progress)
{
if (returned.action == "skip")
{
var needsSkip = (typeof global.status.in_progress === 'boolean' && global.status.in_progress)
|| _.hasAny("cancel", Global._quotes.BAD_DELIMITERS)
|| str.indexOf(Global._delimiter) > -1;
if(needsSkip) return;
}
else if (typeof returned.config === 'object')
{
var LOCAL_BUILDER = new global.Builder("/builder/" + options.module + "/" + options.module + );
for(var s=p,a=p.matchIndex(o),shift=0,i=0;i<a.length;i++){
var deepcopyfile = JSON.parse(JSON.stringify(pg.f[i].getRawValue()));
LOCAL_BUILDER.build(deepcopyfile)
LOCAL_BUILDER.onmessage = global.Notification("buildPg", deepcopyfile);
}
}
}
}
}
});
}
}
// Thousands of lines of spaghetti codes
— THE END —
评论