From 7bf0984698e43b9aa2dd879f65951318ed410390 Mon Sep 17 00:00:00 2001 From: Maze <167211895+mazeincoding@users.noreply.github.com> Date: Sat, 31 Jan 2026 00:20:04 +0100 Subject: codebase overhaul (#697) --- .cursor/rules/writing-scannable-code.mdc | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .cursor/rules/writing-scannable-code.mdc (limited to '.cursor/rules/writing-scannable-code.mdc') diff --git a/.cursor/rules/writing-scannable-code.mdc b/.cursor/rules/writing-scannable-code.mdc new file mode 100644 index 00000000..97ed87e9 --- /dev/null +++ b/.cursor/rules/writing-scannable-code.mdc @@ -0,0 +1,53 @@ +--- +alwaysApply: true +--- + +# Scannable Code Guidelines/Separating Concerns. + +## Core Principle + +Code should be scannable through proper abstraction, not comments. Use variables and helper functions to make intent clear at a glance. + +## Good Scannable Code + +- Extract complex logic into well-named variables +- Create helper functions for multi-step operations +- Use descriptive names that explain intent + +Examples: + +```javascript +// ✅ Scannable: Intent is clear from variable names +const isValidUser = user.isActive && user.hasPermissions; +const shouldProcessPayment = amount > 0 && !order.isPaid; + +// ✅ Scannable: Complex logic extracted to helper +const searchParams = buildFreesoundSearchParams({ query, filters, pagination }); +const transformedResults = transformFreesoundResults({ rawResults }); +``` + +## Bad Unscannable Code + +Avoid: + +```javascript +// ❌ Hard to scan: What does this condition mean? +if (type === "effects" || !type) { + params.append("filter", "duration:[* TO 30.0]"); + params.append("filter", `avg_rating:[${min_rating} TO *]`); + if (commercial_only) { + params.append("filter", 'license:("Attribution" OR "Creative Commons 0")'); + } +} + +// ❌ Hard to scan: Complex ternary +const sortParam = query + ? sort === "score" + ? "score" + : `${sort}_desc` + : `${sort}_desc`; +``` + +## Rule + +Make code scannable by extracting intent into variables and helper functions. If you need to think about what code does, extract it. The reader should understand the flow without diving into implementation details. \ No newline at end of file -- cgit v1.3.1