Skip to content

Conversation

Nigel2392
Copy link
Contributor

While inspecting the Truncate function to gain some inspiration, I noticed it has an unnecessary error check.

This PR specifically targets the following blob:
https://github.com/gohugoio/hugo/blob/3aa22b09425ab9e4e4d79c328ae16692cb3df736/tpl/strings/truncate.go#L70C1-L76C3

if err != nil {
	return "", errors.New("text to truncate must be a string")
}
text, err := cast.ToStringE(textParam)
if err != nil {
	return "", errors.New("text must be a string")
}

The previous error might have belonged to an old piece of code, but as it stands - it will always be nil.

@CLAassistant
Copy link

CLAassistant commented Jul 28, 2025

CLA assistant check
All committers have signed the CLA.

@bep bep force-pushed the remove-redundant-err-check branch from 13d3f02 to 2e4ba7f Compare August 15, 2025 10:04
@bep bep merged commit 348aae9 into gohugoio:master Aug 15, 2025
6 checks passed
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.

3 participants