Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch refactoring always re-orders if..elif comparisons alphabetically #102

Open
Hellebore opened this issue Nov 18, 2020 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@Hellebore
Copy link
Collaborator

Issue description or question

The switch refactoring always re-orders comparisons of values to strings alphabetically. This does not change behaviour but can obscure developer intent and harm readability.

Sourcery Version

0.8.3

Code editor or IDE name and version

All

OS name and version

All

@Hellebore Hellebore added the enhancement New feature or request label Nov 18, 2020
@Hellebore Hellebore self-assigned this Nov 18, 2020
@3yte
Copy link

3yte commented Jun 15, 2021

Here is a concrete example:

original:

if INSTANCE == "test":
     MODE_DEFS = [MODE_TEST]
elif INSTANCE == "dev":
    MODE_DEFS = [MODE_TEST, MODE_DEV]
else:
     MODE_DEFS = [MODE_TEST, MODE_DEV, MODE_PROD]

suggested change:

if INSTANCE == "dev":
    MODE_DEFS = [MODE_TEST, MODE_DEV]
elif INSTANCE == "test":
     MODE_DEFS = [MODE_TEST]
else:
     MODE_DEFS = [MODE_TEST, MODE_DEV, MODE_PROD]

@Hellebore Hellebore removed their assignment Sep 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants