cleanup and fix sonarqube findings
Sonarqube Scanner / Build and analyze (push) Successful in 51s

This commit is contained in:
ChatGPT
2026-06-04 23:54:22 +02:00
parent d7ce563925
commit dd1b08ee21
5 changed files with 54 additions and 19 deletions
+21 -12
View File
@@ -10,21 +10,30 @@ export async function handleTrigger(triggerType, context) {
const assignedReactions = await getAssignedReactionsForContext(context);
for (const reaction of assignedReactions) {
try {
if (!reaction?.enabled) continue;
if (reaction.trigger?.type !== triggerType) continue;
if (!matchesTriggerSpellFilter(reaction.trigger, context)) continue;
if (!await checkConsumptionAvailable(reaction, context)) continue;
if (!await checkConditions(reaction, context)) continue;
const result = await executeReactionActions(reaction, context);
if (result.shouldConsume) await consumeReactionUse(reaction, context);
} catch (error) {
console.error(`${MODULE_ID} | Failed to handle reaction`, reaction, error);
}
await handleAssignedReaction(triggerType, context, reaction);
}
}
async function handleAssignedReaction(triggerType, context, reaction) {
try {
if (!await shouldExecuteReaction(triggerType, context, reaction)) return;
const result = await executeReactionActions(reaction, context);
if (result.shouldConsume) await consumeReactionUse(reaction, context);
} catch (error) {
console.error(`${MODULE_ID} | Failed to handle reaction`, reaction, error);
}
}
async function shouldExecuteReaction(triggerType, context, reaction) {
if (!reaction?.enabled) return false;
if (reaction.trigger?.type !== triggerType) return false;
if (!matchesTriggerSpellFilter(reaction.trigger, context)) return false;
if (!await checkConsumptionAvailable(reaction, context)) return false;
return checkConditions(reaction, context);
}
function matchesTriggerSpellFilter(trigger, context) {
const expectedName = trigger?.spell?.itemName;
if (!expectedName) return true;