Skip to content

Add tagalign linter #2084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 26, 2023
7 changes: 7 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ linters:
- staticcheck
- stylecheck
- typecheck
- tagalign
- unconvert
- unparam
- unused
Expand Down Expand Up @@ -154,3 +155,9 @@ linters-settings:
- "all"
- "-SA6002" # Storing non-pointer values in sync.Pool allocates memory
- "-SA1019" # Using a deprecated function, variable, constant or field
tagalign:
align: true
sort: true
strict: true
order:
- serialize
6 changes: 3 additions & 3 deletions codec/test_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -933,11 +933,11 @@ func TestSliceLengthOverflow(codec GeneralCodec, t testing.TB) {
}

type MultipleVersionsStruct struct {
BothTags string `tag1:"true" tag2:"true"`
BothTags string `tag1:"true" tag2:"true"`
SingleTag1 string `tag1:"true"`
SingleTag2 string `tag2:"true"`
SingleTag2 string ` tag2:"true"`
EitherTags1 string `tag1:"false" tag2:"true"`
EitherTags2 string `tag1:"true" tag2:"false"`
EitherTags2 string `tag1:"true" tag2:"false"`
NoTags string `tag1:"false" tag2:"false"`
}

Expand Down
8 changes: 4 additions & 4 deletions snow/consensus/snowball/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ var (

// Parameters required for snowball consensus
type Parameters struct {
K int `json:"k" yaml:"k"`
Alpha int `json:"alpha" yaml:"alpha"`
BetaVirtuous int `json:"betaVirtuous" yaml:"betaVirtuous"`
BetaRogue int `json:"betaRogue" yaml:"betaRogue"`
K int `json:"k" yaml:"k"`
Alpha int `json:"alpha" yaml:"alpha"`
BetaVirtuous int `json:"betaVirtuous" yaml:"betaVirtuous"`
BetaRogue int `json:"betaRogue" yaml:"betaRogue"`
ConcurrentRepolls int `json:"concurrentRepolls" yaml:"concurrentRepolls"`
OptimalProcessing int `json:"optimalProcessing" yaml:"optimalProcessing"`

Expand Down
10 changes: 5 additions & 5 deletions snow/engine/avalanche/vertex/stateless_vertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ func (v statelessVertex) Txs() [][]byte {

type innerStatelessVertex struct {
Version uint16 `json:"version"`
ChainID ids.ID `serializeV0:"true" serializeV1:"true" json:"chainID"`
Height uint64 `serializeV0:"true" serializeV1:"true" json:"height"`
Epoch uint32 `serializeV0:"true" json:"epoch"`
ParentIDs []ids.ID `serializeV0:"true" serializeV1:"true" len:"128" json:"parentIDs"`
Txs [][]byte `serializeV0:"true" len:"128" json:"txs"`
ChainID ids.ID `json:"chainID" serializeV0:"true" serializeV1:"true"`
Height uint64 `json:"height" serializeV0:"true" serializeV1:"true"`
Epoch uint32 `json:"epoch" serializeV0:"true"`
ParentIDs []ids.ID `json:"parentIDs" len:"128" serializeV0:"true" serializeV1:"true"`
Txs [][]byte `json:"txs" len:"128" serializeV0:"true"`
}

func (v innerStatelessVertex) Verify() error {
Expand Down
18 changes: 9 additions & 9 deletions subnets/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
var errAllowedNodesWhenNotValidatorOnly = errors.New("allowedNodes can only be set when ValidatorOnly is true")

type GossipConfig struct {
AcceptedFrontierValidatorSize uint `json:"gossipAcceptedFrontierValidatorSize" yaml:"gossipAcceptedFrontierValidatorSize"`
AcceptedFrontierValidatorSize uint `json:"gossipAcceptedFrontierValidatorSize" yaml:"gossipAcceptedFrontierValidatorSize"`
AcceptedFrontierNonValidatorSize uint `json:"gossipAcceptedFrontierNonValidatorSize" yaml:"gossipAcceptedFrontierNonValidatorSize"`
AcceptedFrontierPeerSize uint `json:"gossipAcceptedFrontierPeerSize" yaml:"gossipAcceptedFrontierPeerSize"`
OnAcceptValidatorSize uint `json:"gossipOnAcceptValidatorSize" yaml:"gossipOnAcceptValidatorSize"`
OnAcceptNonValidatorSize uint `json:"gossipOnAcceptNonValidatorSize" yaml:"gossipOnAcceptNonValidatorSize"`
OnAcceptPeerSize uint `json:"gossipOnAcceptPeerSize" yaml:"gossipOnAcceptPeerSize"`
AppGossipValidatorSize uint `json:"appGossipValidatorSize" yaml:"appGossipValidatorSize"`
AppGossipNonValidatorSize uint `json:"appGossipNonValidatorSize" yaml:"appGossipNonValidatorSize"`
AppGossipPeerSize uint `json:"appGossipPeerSize" yaml:"appGossipPeerSize"`
AcceptedFrontierPeerSize uint `json:"gossipAcceptedFrontierPeerSize" yaml:"gossipAcceptedFrontierPeerSize"`
OnAcceptValidatorSize uint `json:"gossipOnAcceptValidatorSize" yaml:"gossipOnAcceptValidatorSize"`
OnAcceptNonValidatorSize uint `json:"gossipOnAcceptNonValidatorSize" yaml:"gossipOnAcceptNonValidatorSize"`
OnAcceptPeerSize uint `json:"gossipOnAcceptPeerSize" yaml:"gossipOnAcceptPeerSize"`
AppGossipValidatorSize uint `json:"appGossipValidatorSize" yaml:"appGossipValidatorSize"`
AppGossipNonValidatorSize uint `json:"appGossipNonValidatorSize" yaml:"appGossipNonValidatorSize"`
AppGossipPeerSize uint `json:"appGossipPeerSize" yaml:"appGossipPeerSize"`
}

type Config struct {
Expand All @@ -37,7 +37,7 @@ type Config struct {
ValidatorOnly bool `json:"validatorOnly" yaml:"validatorOnly"`
// AllowedNodes is the set of node IDs that are explicitly allowed to connect to this Subnet when
// ValidatorOnly is enabled.
AllowedNodes set.Set[ids.NodeID] `json:"allowedNodes" yaml:"allowedNodes"`
AllowedNodes set.Set[ids.NodeID] `json:"allowedNodes" yaml:"allowedNodes"`
ConsensusParameters snowball.Parameters `json:"consensusParameters" yaml:"consensusParameters"`

// ProposerMinBlockDelay is the minimum delay this node will enforce when
Expand Down
4 changes: 2 additions & 2 deletions vms/avm/txs/initial_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var (
)

type InitialState struct {
FxIndex uint32 `serialize:"true" json:"fxIndex"`
FxIndex uint32 `serialize:"true" json:"fxIndex"`
FxID ids.ID `serialize:"false" json:"fxID"`
Outs []verify.State `serialize:"true" json:"outputs"`
Outs []verify.State `serialize:"true" json:"outputs"`
}

func (is *InitialState) InitCtx(ctx *snow.Context) {
Expand Down
4 changes: 2 additions & 2 deletions vms/avm/txs/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ var (

type Operation struct {
avax.Asset `serialize:"true"`
UTXOIDs []*avax.UTXOID `serialize:"true" json:"inputIDs"`
UTXOIDs []*avax.UTXOID `serialize:"true" json:"inputIDs"`
FxID ids.ID `serialize:"false" json:"fxID"`
Op fxs.FxOperation `serialize:"true" json:"operation"`
Op fxs.FxOperation `serialize:"true" json:"operation"`
}

func (op *Operation) Verify() error {
Expand Down
4 changes: 2 additions & 2 deletions vms/components/avax/transferables.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type TransferableOutput struct {
Asset `serialize:"true"`
// FxID has serialize false because we don't want this to be encoded in bytes
FxID ids.ID `serialize:"false" json:"fxID"`
Out TransferableOut `serialize:"true" json:"output"`
Out TransferableOut `serialize:"true" json:"output"`
}

func (out *TransferableOutput) InitCtx(ctx *snow.Context) {
Expand Down Expand Up @@ -142,7 +142,7 @@ type TransferableInput struct {
Asset `serialize:"true"`
// FxID has serialize false because we don't want this to be encoded in bytes
FxID ids.ID `serialize:"false" json:"fxID"`
In TransferableIn `serialize:"true" json:"input"`
In TransferableIn `serialize:"true" json:"input"`
}

// Input returns the feature extension input that this Input is using.
Expand Down