Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

NickCirv/variable-shame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

variable-shame

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.

Install

npm install -g variable-shame

Or run directly:

npx variable-shame

Usage

# 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 py

What it detects

Single-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

Sample output

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  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.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Exit codes

  • 0 — No shame found (good job, suspicious)
  • 1 — Shame found (expected)

Exceptions (we're not monsters)

  • i, j, k inside for loops — allowed
  • e in catch blocks — allowed
  • Legitimate acronyms — not flagged

License

MIT

About

You named it 'data'. Shame on you. Finds every lazy variable name in your codebase.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors