Files
opentf/internal/addrs/parse_ref.go
Martin Atkins 65f4d7f430 addrs: Rework parseRef to be shorter
Our complexity lint rules previously considered this function to have both
too many statements and too many lines.

Factoring out more of the "single-attr ref" logic into the
parseSingleAttrRef function eliminated one statement per case that was
using it.

Factoring out the handling of module call references -- the most complex
case this function handles -- into a separate parseModuleCallRef reduced
it considerably more.

Removing the empty lines between the "case" statements was necessary after
that just to get below the line count limit, which seems like a rather
dubious situation for a lint rule to complain about but it doesn't seem
to hurt readability, so fair enough.

The rework of parseSingleAttrRef made it slightly less convenient to use
as part of parseModuleCallRef, but not onerously so and thus this
prioritizes making the common case simpler at the expense of a small
amount of extra work in the parseModuleCallRef function.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-02-12 09:09:52 -08:00

16 KiB