Skip to content

refactor: remove redundant else branches - #344

Open
tenthirtyam wants to merge 1 commit into
hashicorp:mainfrom
tenthirtyam:refactor/remove-redundant-else-branches
Open

refactor: remove redundant else branches#344
tenthirtyam wants to merge 1 commit into
hashicorp:mainfrom
tenthirtyam:refactor/remove-redundant-else-branches

Conversation

@tenthirtyam

Copy link
Copy Markdown
Contributor

Description

Removes unnecessary else clauses after terminating statements.

Resolved Issues

Redundant else clauses in if statements that contain a return.

Rollback Plan

Revert commit.

Changes to Security Controls

None.

@tenthirtyam
tenthirtyam requested a review from a team as a code owner July 24, 2026 03:39
Comment thread acctest/pluginacc.go
}

os.Remove(templatePath)
os.Remove(logfile)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel we would like to keep the two temporary files in case of test failures as they could help the users debug the failed test better.

Same goes for the change in acctest/provisioneracc/provisioners.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on the intent to keep the template and log on failure for debugging (the Fatalf message points at those paths for that reason).

Behaviorally this is unchanged: t.Fatalf never returns (FailNow / runtime.Goexit), so the os.Remove calls after the if only run on success. Same for provisioners.go. Dropping the else after a terminating statement is the usual Go early-exit idiom.

Happy to restore the else in both places if you prefer that form to make the “cleanup only on success” intent more obvious at a glance.

Removes unnecessary `else` clauses after terminating statements.

Signed-off-by: Ryan Johnson <ryan@tenthirtyam.org>
@tenthirtyam
tenthirtyam force-pushed the refactor/remove-redundant-else-branches branch from 7aefca9 to a8045c1 Compare August 12, 2026 18:10
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.

2 participants