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

dnsexit2: Code health improvements #678

Merged
merged 20 commits into from
May 30, 2024
Merged

Conversation

rhansen
Copy link
Member

@rhansen rhansen commented May 29, 2024

No (substantial) behavior changes, only code cleanups.

@jortkoopmans This is going to cause substantial merge conflicts with #674. I'll rebase your PR after this is merged. My motivation for making this PR is to make it easier to review your PR.

rhansen added 20 commits May 29, 2024 16:48
Rationale:
  * For consistency.
  * It's generally not a good idea to mix interpolation with `sprintf`
    because the interpolated string itself might coincidentally (or
    maliciously) contain format specifiers.
Instead of:

    if ($success1) {
        if ($success2) {
            if ($success3) {
                # yay
            } else {
                # fail
            }
        } else {
            # fail
        }
    } else {
        # fail
    }

do:

    if (!$success1) {
        # fail
    }
    if (!$success2) {
        # fail
    }
    if (!$success3) {
        # fail
    }
    # yay
Comments should only be used if the code is doing something
subtle/tricky/non-obvious/unusual, otherwise they're distracting and
might get out of sync with the code (in which case it becomes
difficult to tell if it's the comment or the code that's wrong).  If
the code is difficult to understand without comments but is doing
something ordinary, then the code needs to be modified to improve
readability.
for consistency, and to avoid bugs if additional items are added or
the items are reordered.
to improve readability, and to make it easier to use
`group_hosts_by()` in the future to update multiple hosts at the same
time.
@rhansen rhansen merged commit b3951e4 into ddclient:master May 30, 2024
11 checks passed
@rhansen rhansen deleted the dnsexit2 branch May 30, 2024 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant