question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enforce `x`, `x1`,` x2` naming consistency

See original GitHub issue

Rule request

Thesis

I often see that some people use this naming pattern:

x1 = 1
x2 = 2

Which is perfectly fine. But, this one looks ugly:

x = 1
x2 = 2

Note x1 vs x2 difference.

Reasoning

My proposed solution is to create a new naming rule to check that if a variable named something1 or something2 there should not be just something in the current scope. While just something and something1 with something2 are totally fine.

Our own code will have lots of these issues!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
Dreamsorcerercommented, Feb 8, 2021

Might also want to consider checking for underscores:

x = 1
x_2 = 2
0reactions
sobolevncommented, Feb 8, 2021

Ok, this is hard. There are lots of corner cases and small things to think about.

For example, attributes need special handling:

  • some.x and some.x2 are violating this rule
  • while some.x and other.x2 are not

So, I am moving this feature for the next version.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enforce `x`, `x1`,` x2` naming consistency #1381 - Issuehunt
My proposed solution is to create a new naming rule to check that if a variable named something1 or something2 there should not...
Read more >
Chapter 3 Consistency-enforcing algorithms: constraint ...
The primary characteristic of consistency in- ference algorithms is the size of the subnetwork involved in the inference.
Read more >
Data Scientists, Your Variable Names Are a Mess. Clean Up ...
One of the important points to remember when naming variables is: consistency counts. Staying consistent with variable names means you spend ...
Read more >
Local Consistency
Enforcing AC means removing arc-inconsistent values until AC is achieved. Page 22. Arc Consistency. 11 / 43. □ The AC name comes from...
Read more >
PEP 8 – Style Guide for Python Code
Consistency with this style guide is important. Consistency within a ... Correct: x = 1 y = 2 long_variable = 3. # Wrong:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found