You named it data.
It processes user authentication tokens.
It is not "data".
A CLI tool that scans your codebase for terrible variable names and publicly shames them — with receipts.
npm install -g variable-shameOr run directly:
npx variable-shame# Scan current directory
variable-shame
# Scan a specific path
variable-shame --path ./src
# Scan only JS or TS or Python files
variable-shame --path ./src --lang js
variable-shame --path ./src --lang ts
variable-shame --path ./src --lang pySingle-letter variables outside of loop contexts:
const x = getUserId() // x? Really?
let a = fetchToken() // Not acceptable.Generic / lazy names that could mean anything:
const data = await fetch('/api/users') // "data". Revolutionary.
let result = processPayment(card) // result of what?
const stuff = getThings() // i cannot.Abbreviation crimes — saving 3 keystrokes, losing all meaning:
const usr = await getUser(id) // just... user
const msg = buildEmail(params) // message. it's one more syllable.
const cfg = loadConfig() // config. you can do it.Boolean lies — booleans that don't announce themselves:
let loaded = false // isLoaded
let valid = true // isValid
const enabled = flag // isEnabled━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
VARIABLE SHAME REPORT
Scanned: 47 files, 3,241 lines
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CARDINAL SINS (score 5)
src/auth.js:47
let x = getUserId()
-> x? Really? This held someone's identity. You named it with a key press.
Try: xValue / xItem / xRecord
src/api.js:12
const data = await fetch('/api/users')
-> Every variable is data. This tells us nothing.
Try: userData / apiResponse / fetchedItems / payload
LAZY NAMING (score 3)
src/user.js:89
const result = processUser(userData)
-> "result" of what? For whom? Since when?
Try: parsedToken / validatedUser / processedItem
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STATS:
Total shames found: 23
Shame index: 84% disgraceful
Worst file: src/utils.js (8 shames)
Most common sin: "data" (used 6 times)
By category:
Single-letter vars : 3
Generic names : 14
Abbreviation crimes: 4
Boolean lies : 2
Verdict: YOUR CODEBASE IS A CRIME SCENE.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
0— No shame found (good job, suspicious)1— Shame found (expected)
i,j,kinsideforloops — allowedeincatchblocks — allowed- Legitimate acronyms — not flagged
MIT