Skip to content

Commit

Permalink
Validation improvements to reduce noise
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Aug 19, 2024
1 parent 239785e commit 5194be9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/app/helpers/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export function validationMessagesForMod(
nonexistentRecipes(mod),
];

validationContainer.forEach((v) => {
v.messages = sortBy(v.messages, 'message');
});

validationContainer.forEach((v) => {
if (v.messages.length !== 0) return;

Expand Down
41 changes: 36 additions & 5 deletions src/app/helpers/validators/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { get, groupBy } from 'lodash';
import {
IItemDefinition,
IModKit,
ItemSlot,
ItemSlotType,
ValidationMessage,
ValidationMessageGroup,
Expand Down Expand Up @@ -96,15 +97,45 @@ export function checkItemUses(mod: IModKit): ValidationMessageGroup {
});
});

Object.keys(itemCounts).forEach((item) => {
if (itemCounts[item] > 0) return;
mod.dialogs.forEach((dialog) => {
Object.keys(dialog.items?.equipment ?? {}).forEach((slot) => {
if (!dialog.items.equipment[slot as ItemSlot]) return;

itemValidations.messages.push({
type: 'warning',
message: `${item} is unused.`,
addItemCount(dialog.items.equipment[slot as ItemSlot]);
});

Object.keys(itemCounts).forEach((item) => {
if (itemCounts[item] > 0) return;

const dialogText = JSON.stringify(dialog.dialog ?? {});
const dialogBehavior = JSON.stringify(dialog.behaviors ?? {});

if (dialogText.includes(item) || dialogBehavior.includes(item)) {
addItemCount(item);
}
});
});

Object.keys(itemCounts)
.sort()
.forEach((item) => {
if (itemCounts[item] > 0) return;

// autogenerated items dont count against warnings
if (
item.includes('Lore Scroll') ||
item.includes('Rune Scroll') ||
item.includes('Solokar') ||
item.includes('Orikurnis')
)
return;

itemValidations.messages.push({
type: 'warning',
message: `${item} is unused.`,
});
});

return itemValidations;
}

Expand Down
5 changes: 4 additions & 1 deletion src/app/helpers/validators/spawner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export function checkSpawners(mod: IModKit): ValidationMessageGroup {
});
}

if (!spawner.npcAISettings?.includes('default')) {
if (
spawner.npcAISettings?.length > 0 &&
!spawner.npcAISettings?.includes('default')
) {
itemValidations.messages.push({
type: 'warning',
message: `Spawner ${spawner.tag} does not have the default AI setting.`,
Expand Down

0 comments on commit 5194be9

Please sign in to comment.