Your app looks AI-generated. Vincent Van Gogh noticed. An agent skill that finds and fixes AI-looking UI and UX in mobile apps, web apps, and websites.
JavaScript accessibilityagent-skillsagent-skills-toolsagentsagentskillsai-slopclaudeclaude-codeclaude-skillsexpoflutterfrontendionicjetpack-composemobilereact-nativeswiftuiuiuxvibe-coding
fix(detect): fail the scan when it read zero files (#99)
Nguyễn Tuấn Anh6cca7bacb7a2
diff --git a/skills/unslop-anything/scripts/detect.js b/skills/unslop-anything/scripts/detect.jsindex 5666159..d23c477 100644--- a/skills/unslop-anything/scripts/detect.js+++ b/skills/unslop-anything/scripts/detect.js@@ -1147,7 +1147,14 @@ function scan(targets, opts = {}) {}}findings.sort((a, b) => SEVERITY_RANK[a.severity] - SEVERITY_RANK[b.severity] || a.file.localeCompare(b.file) || a.line - b.line);- return { version: VERSION, filesScanned, unreadable, findings };+ // A scan that read zero files is not a clean scan: a typo'd folder, an+ // Objective-C/Java-only folder, or the wrong subdirectory would otherwise+ // print a clean result and exit 0, reading as a pass in CI when nothing+ // was checked. Flag it the same way unreadable files make a scan incomplete.+ const message = filesScanned === 0+ ? `No supported source files under ${targets.length ? targets.join(", ") : "."} (${Object.keys(STACK_BY_EXT).join(", ")}). The scan checked nothing.`+ : undefined;+ return { version: VERSION, filesScanned, unreadable, findings, ...(message ? { message } : {}) };}// ---------- output ----------@@ -1156,7 +1163,9 @@ function formatText(result) {const { findings, filesScanned } = result;const out = [];if (findings.length === 0) {- out.push(`Dr. Unslopovich found nothing in ${filesScanned} files. Suspicious, but fine.`);+ out.push(filesScanned === 0 && result.message+ ? result.message+ : `Dr. Unslopovich found nothing in ${filesScanned} files. Suspicious, but fine.`);} else {const count = (s) => findings.filter((f) => f.severity === s).length;const files = new Set(findings.map((f) => f.file)).size;@@ -1258,11 +1267,19 @@ function main(argv) {console.error(err.message);return 1;}+ if (result.filesScanned === 0 && !json && !result.unreadable.length) {+ console.error(result.message);+ return 1;+ }console.log(json ? JSON.stringify(result, null, 2) : formatText(result));if (result.unreadable.length) {console.error(`Could not read ${result.unreadable.length} file(s): ${result.unreadable.join(", ")}. The scan is incomplete.`);return 1;}+ if (result.filesScanned === 0) {+ console.error(result.message);+ return 1;+ }return result.findings.length ? 2 : 0;}diff --git a/test/detect.test.js b/test/detect.test.jsindex 80aeb55..1205e96 100644--- a/test/detect.test.js+++ b/test/detect.test.js@@ -461,6 +461,40 @@ test("an unreadable file makes the scan fail, not pass", () => {}});+test("a scan that reads zero files fails instead of passing", () => {+ const fs = require("fs");+ const os = require("os");+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "unslop-"));+ // Objective-C / Java only: no supported source files under this folder.+ fs.writeFileSync(path.join(root, "main.m"), "#import <Foundation/Foundation.h>\nint main() { return 0; }\n");+ fs.writeFileSync(path.join(root, "App.java"), "public class App {}\n");+ const err = console.error;+ const log = console.log;+ let errOut = "";+ let out = "";+ console.error = (s) => (errOut += s);+ console.log = (s) => (out += s);+ try {+ const result = scan([root]);+ assert.strictEqual(result.filesScanned, 0);+ assert.match(result.message, /No supported source files under/);+ assert.ok(result.message.includes(root));+ assert.strictEqual(main([root]), 1);+ assert.match(errOut, /No supported source files under/);+ errOut = "";+ out = "";+ assert.strictEqual(main([root, "--json"]), 1);+ const parsed = JSON.parse(out);+ assert.strictEqual(parsed.filesScanned, 0);+ assert.match(parsed.message, /No supported source files under/);+ assert.ok(parsed.message.includes(".swift"));+ } finally {+ console.error = err;+ console.log = log;+ fs.rmSync(root, { recursive: true, force: true });+ }+});+test("web slop is caught", () => {const found = new Set(scan([path.join(fixtures, "slop", "web")]).findings.map((f) => f.rule));for (const id of [