SlopScore for Code

Patterns / Generic and inconsistent names

Generic and inconsistent names

Models pick names from whatever style they saw most recently, so a camelCase TypeScript file gets a snake_case helper and a Python module gets a camelCase function. Under pressure they also number things: data2, result1, helperFunction.

What it looks like

function retry_count_for(id) in a camelCase file
def loadConfig(path): in a snake_case module
const data2 = rows as any;
function myFunction()

Why it matters

Inconsistent names make code harder to search and hint that it wasn't written with the rest of the file in mind.

Before and after

Before
const data2 = await getRows();
function retry_count_for(id) { ... }
After
const unpaidInvoices = await getRows();
function retryCountFor(id) { ... }

How to fix it

  1. Follow the file's existing convention (PEP 8 snake_case in Python).
  2. Name variables after what they hold.
  3. These are info-level findings in SlopScore for Code: they nudge, they don't fail builds.

When it's fine

Names that mirror an external API (snake_case JSON fields in TypeScript, for example).

Catch this automatically. SlopScore for Code checks every pull request for this pattern (rule naming-inconsistency) and 11 others. Score a public PR or add the free GitHub Action.

Related