'cassandraclient' was used before it was defined
59 //logger.discordInfoLogger.info("Inserted Vote from Top.gg into database", {"type": "VoteWebhookDatabase"})
60 });
61
62 await cassandraclient.execute("INSERT INTO adoravotes.pendingvotereminders (time, userid, service, sent) VALUES (?,?,?,?)", 63 [timeuuid, userid, service, false])
64 .then((results) => {
65
'cassandraclient' was used before it was defined
53 var params;
54 params = [timeuuid, service, userid];
55
56 await cassandraclient.execute(query, params, { prepare: true }, await function (err) { 57 console.log(err);
58 //Inserted in the cluster
59 //logger.discordInfoLogger.info("Inserted Vote from Top.gg into database", {"type": "VoteWebhookDatabase"})
'cassandraclient' was used before it was defined
38 }).catch(error => console.error(error));
39
40 //Goes inside adoravotes keyspace, makes the table "pendingreminders"
41 await cassandraclient.execute("CREATE TABLE IF NOT EXISTS adoravotes.pendingvotereminders (time timeuuid PRIMARY KEY, userid text, service text, sent boolean);") 42 .then(async result => {
43 await logger.discordDebugLogger.debug({ type: "cassandraclient", result: result })
44 /*console.log(result)*/
'cassandraclient' was used before it was defined
31 }).catch(error => console.error(error));
32
33 //Goes inside adoravotes keyspace, makes the table "votes"
34 await cassandraclient.execute("CREATE TABLE IF NOT EXISTS adoravotes.votes (time timeuuid PRIMARY KEY, voteservice text, userid text);") 35 .then(async result => {
36 await logger.discordDebugLogger.debug({ type: "cassandraclient", result: result })
37 /*console.log(result)*/
'cassandraclient' was used before it was defined
24console.log(webhook)
25
26async function createDatabases() {
27 await cassandraclient.execute("CREATE KEYSPACE IF NOT EXISTS adoravotes WITH REPLICATION = { 'class' : 'NetworkTopologyStrategy', 'datacenter1': 1 };") 28 .then(async result => {
29 await logger.discordDebugLogger.debug({ type: "cassandraclient", result: result })
30 /*console.log(result)*/
'firstchangedbyidfirststate' was used before it was defined
596 if (isBanRecordNew) {
597 params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState];
598 } else {
599 params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, message.author.id, TimeUuid.now(), firstchangedbyidfirststate, firstchangedtimefirststate]; 600 }
601
602 await cassandraclient.execute(query, params, { prepare: true }, await function (err) {
'firstchangedtimefirststate' was used before it was defined
596 if (isBanRecordNew) {
597 params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState, banFirstChangedByIdInitialState, banFirstChangedTimeInitialState];
598 } else {
599 params = [individualUserIdToAddToBanDatabase, true, reasonForBanRegister, message.author.id, TimeUuid.now(), firstchangedbyidfirststate, firstchangedtimefirststate]; 600 }
601
602 await cassandraclient.execute(query, params, { prepare: true }, await function (err) {
Description
Variables, functions and types should always be used after they've been defined. This issue will flag any code snippets that use variables or types before definition.
Sometimes, the code will run just fine even when the variable is declared after use. Consider the following example:
const ram: Resource = { type: "memory", limit: 1024 ** 3 }
type Resource = {
type: string;
limit: number;
}
Here, Resource
is used in the annotation before it has been defined.
Similarly, it is possible to hoist function declarations and variables declared with the var
keyword:
const four = twice(2);
function twice(n: number) {
return n * 2;
}
However, it makes the code harder to follow when variables or types are declared after being used.
Bad Practice
const knight: Radiant = {
order: "SurgeBinder"
strength: 30
}
interface Radiant {
order: string;
strength: number;
}
Recommended
interface Radiant {
order: string;
strength: number;
}
const knight: Radiant = {
order: "SurgeBinder"
strength: 30
}