hashicorp / hashicorp/hcl

hclwrite: Duplicate functions NewFile and NewEmptyFile

Open
#504 1 comment 0 reactions 0 assignees View on GitHub
cleanup confirmed
Dominant language
Go
Stars
5.8k
Forks
657
Avg merge
20h 36m
Merged PRs (30d)
6

Description

`hclwrite.NewFile` and `hclwrite.NewEmptyFile` are, on closer inspection, functionally identical duplicate code.

Suggestion: Replace `NewFile` (which manually reimplements `newBody` instead of invoking it) with a trivial deprecated wrapper invoking `NewEmptyFile`. (Or, perhaps, keep the `NewFile` name, along with the shorter more concise implementation from `NewEmptyFile`?)

Another suggestion: Rename hclwrite's public.go to helpers.go, since it isn't the only file defining public symbols.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by comparing hclwrite.NewFile and hclwrite.NewEmptyFile, then inspect hclwrite/public.go and the surrounding public symbols. Resolve whether NewFile should remain as a deprecated wrapper or retain its name while adopting the shorter implementation; done means the duplicate logic and file-naming concern have a clear, compatible resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.