no-nested-ternary

no-nested-ternary is a cursor rule for Cursor from LodyAI/Lody. It costs 248 tokens per session, scanned A, original, Apache-2.0.

A coding rule that forbids putting one conditional expression inside another conditional expression. It recommends a lookup table or ordinary if and switch statements when several cases need to be handled.

In plain words
What is it for?
Use it when writing or reviewing conditional assignments and status logic. Replace nested choices with a dictionary, if statements, or a switch where appropriate.
Why use it?
It keeps branching logic easier to read and reduces deeply nested code. The rule applies across JavaScript, TypeScript, and Swift examples in the guidance.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when writing or reviewing conditional assignments and status logic. Replace nested choices with a dictionary, if statements, or a switch where appropriate.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/lodyai/lody/no-nested-ternary
About the project

Lody is a shared workspace that connects coding agents running on different computers and lets people view and direct their work from desktop, mobile, web, or a command line. Teams use it to share agent conversations, monitor progress and code changes, and assign work to connected machines while retaining their existing agents and configurations.

LodyAI/Lody · 1,674 stars · on GitHub · lody.ai

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/LodyAI/Lody

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for no-nested-ternary

README.md
[![agentmods](https://agentmods.dev/badge/rules/lodyai/lody/no-nested-ternary/github.svg)](https://agentmods.dev/rules/lodyai/lody/no-nested-ternary)
Your own site
<a href="https://agentmods.dev/rules/lodyai/lody/no-nested-ternary"><img src="https://agentmods.dev/badge/rules/lodyai/lody/no-nested-ternary/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for no-nested-ternary

Your own site · 80×15
<a href="https://agentmods.dev/rules/lodyai/lody/no-nested-ternary"><img src="https://agentmods.dev/badge/rules/lodyai/lody/no-nested-ternary.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 248 This file is loaded in full into every session.
When invoked 248 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00248 $0.00248
Opus 5.5 $0.00099 $0.00099
Sonnet 5.5 $0.00050 $0.00050
Haiku 4.5 $0.00025 $0.00025

Measured today against content hash 226f30c937f5, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

no-nested-ternary scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

apps/mobile/ios/.cursor/rules/no-nested-ternary.mdc · 37 lines

What it actually says

No nested ternaries

A single cond ? a : b is fine. Nesting another ? in either branch is not.

Use a dictionary when the input is a closed set of keys. Use if / switch when the conditions are ordered or overlapping.

// BAD
const status =
  state.status === 'offline'
    ? 'failed'
    : state.status !== 'live'
      ? 'syncing'
      : reply?.finished
        ? 'completed'
        : reply
          ? 'receiving'
          : 'sent';

// GOOD
if (state.status === 'offline') return 'failed';
if (state.status !== 'live') return 'syncing';
if (!reply) return 'sent';
if (reply.finished) return 'completed';
return 'receiving';

// GOOD — closed set
const tint = { attention: 'warning', failed: 'danger' }[state] ?? 'secondary';

Same rule in Swift, TS, and TSX. Optional chaining (?.) and nullish (??) are not ternaries.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today First seen · 37 lines · 248 tokens per session scan A 226f30c937f5

Subscribe to this mod's changes

no-nested-ternary is a cursor rule published in the GitHub repository LodyAI/Lody (1,674 stars, last pushed today), licensed Apache-2.0. It adds 248 tokens to every session, about $0.0010 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-11-07.

Related

no-nested-ternary compared with cursor rules from other repositories

no-nested-ternary next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
no-nested-ternaryLodyAI/LodyCursor rule1.7ktodayApache-2.0A248Cursor
git-workflowuseshape/ShapeCursor rule345d agononeA174Cursor
ponytailDietrichGebert/ponytailCursor rule186k9d agoMITA604Cursor
angular-20angular/angularCursor rule101ktodayMITA0Cursor
dev-standardapache/supersetCursor rule75ktodayApache-2.0A1,147Cursor
prefer-direct-imports-over-module-mocksprisma/ormCursor rule48ktodayApache-2.0A0Cursor
config-validation-and-normalizationprisma/ormCursor rule48ktodayApache-2.0A0Cursor