cockroach icon indicating copy to clipboard operation
cockroach copied to clipboard

lint: add a linter to prohibit map[...]bool in favor of map[...]struct{}

Open yuzefovich opened this issue 3 years ago • 3 comments

The linter is currently limited to sql/opt/norm package. This commit was prompted by an article mentioned in the Golang Weekly newsletter. The rationale is that map[...]struct{} is more efficient, but in some cases the bool map value is actually desired.

Release note: None

yuzefovich avatar Aug 05 '22 20:08 yuzefovich

This change is Reviewable

cockroach-teamcity avatar Aug 05 '22 20:08 cockroach-teamcity

Curious what people think about such a linter in general @cockroachdb/sql-queries.

yuzefovich avatar Aug 05 '22 20:08 yuzefovich

I'm generally in favor. As you say there are cases where the trinary logic of map[...]bool is actually needed, so it would be nice to have some kind of "nolint" comment or something.

michae2 avatar Aug 08 '22 16:08 michae2

Add an opt-out to disable the linter.

TFTRs!

bors r+

yuzefovich avatar Aug 19 '22 16:08 yuzefovich

Build failed (retrying...):

craig[bot] avatar Aug 19 '22 16:08 craig[bot]

Build succeeded:

craig[bot] avatar Aug 19 '22 18:08 craig[bot]