Inspectopedia 2024.3 Help

Irregular usage of 'iota'

Reports irregular usage of iota within a constant declaration.

The iota identifier is reset for every constant declaration and automatically incremented for every constant specification. Within one constant specification, the identifier keeps its value. Explicitly referring to iota does not reset the counter.

For more information, refer to Iota in the Go specification.

This inspection is triggered if two constant specifications have a textually identical expression list containing at least one reference to iota and there are exclusively constant specifications without an expression list in between them.

Consider omitting the redundant expression list or writing out the expression list every time.

Example:

const ( a = iota // 0 b // 1 c = iota // 2 )

Triggers the inspection as the iota in the definition of c is redundant.

Example:

const ( a, aa = iota, iota // 0, 0 b, bb // 1, 1 c, cc = iota + 40, iota // 42, 2 )

Does not trigger the inspection as none of the expression lists is redundant.

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

GoIrregularIota
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Go | Probable bugs

Inspection Details

By default bundled with:

GoLand 2024.3, Qodana for Go 2024.3,

Can be installed with plugin:

Go, 243.23131

Last modified: 03 December 2024