diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-25 16:16:42 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:46:35 +0200 |
| commit | 2c0fd4f86b011bbc8c0d86c61f96ade3ea249508 (patch) | |
| tree | 660cbe303457d212d4c1d5398b02ed64945b7099 /.cursor/rules/writing-scannable-code.mdc | |
| parent | 5e2b829f8a682a619cd0de6681ddd9f542235ebf (diff) | |
| download | opencut-2c0fd4f86b011bbc8c0d86c61f96ade3ea249508.tar.gz | |
untrack .cursor/
Diffstat (limited to '.cursor/rules/writing-scannable-code.mdc')
| -rw-r--r-- | .cursor/rules/writing-scannable-code.mdc | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/.cursor/rules/writing-scannable-code.mdc b/.cursor/rules/writing-scannable-code.mdc deleted file mode 100644 index 2c36d496..00000000 --- a/.cursor/rules/writing-scannable-code.mdc +++ /dev/null @@ -1,52 +0,0 @@ ---- -alwaysApply: false ---- -# 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 |
