Skip to content
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

chore: suggest using errors.New instead of fmt.Errorf with no parameters #6835

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/dynamic_startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"context"
"encoding/hex"
"errors"
"fmt"
"path/filepath"
"strconv"
Expand Down Expand Up @@ -35,11 +36,11 @@ func ValidateDynamicStartupFlags(accessPublicKey, accessAddress string, startPha
}

if accessAddress == "" {
return fmt.Errorf("invalid flag --dynamic-startup-access-address can not be empty")
return errors.New("invalid flag --dynamic-startup-access-address can not be empty")
}

if startPhase <= flow.EpochPhaseUndefined {
return fmt.Errorf("invalid flag --dynamic-startup-startup-epoch-phase unknown epoch phase")
return errors.New("invalid flag --dynamic-startup-startup-epoch-phase unknown epoch phase")
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion cmd/execution_config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"errors"
"fmt"
"path/filepath"
"strings"
Expand Down Expand Up @@ -141,7 +142,7 @@ func (exeConf *ExecutionConfig) SetupFlags(flags *pflag.FlagSet) {
func (exeConf *ExecutionConfig) ValidateFlags() error {
if exeConf.enableBlockDataUpload {
if exeConf.gcpBucketName == "" && exeConf.s3BucketName == "" {
return fmt.Errorf("invalid flag. gcp-bucket-name or s3-bucket-name required when blockdata-uploader is enabled")
return errors.New("invalid flag. gcp-bucket-name or s3-bucket-name required when blockdata-uploader is enabled")
}
}
if exeConf.executionDataAllowedPeers != "" {
Expand Down
14 changes: 7 additions & 7 deletions cmd/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (fnb *FlowNodeBuilder) EnqueuePingService() {
return head.Height, nil
},
HotstuffViewFun: func() (uint64, error) {
return 0, fmt.Errorf("hotstuff view reporting disabled")
return 0, errors.New("hotstuff view reporting disabled")
},
}

Expand Down Expand Up @@ -688,7 +688,7 @@ func (fnb *FlowNodeBuilder) EnqueueAdminServerInit() error {

if (fnb.AdminCert != NotSet || fnb.AdminKey != NotSet || fnb.AdminClientCAs != NotSet) &&
!(fnb.AdminCert != NotSet && fnb.AdminKey != NotSet && fnb.AdminClientCAs != NotSet) {
return fmt.Errorf("admin cert / key and client certs must all be provided to enable mutual TLS")
return errors.New("admin cert / key and client certs must all be provided to enable mutual TLS")
}

// create the updatable config manager
Expand Down Expand Up @@ -789,7 +789,7 @@ func (fnb *FlowNodeBuilder) PrintBuildVersionDetails() {

func (fnb *FlowNodeBuilder) initNodeInfo() error {
if fnb.BaseConfig.nodeIDHex == NotSet {
return fmt.Errorf("cannot start without node ID")
return errors.New("cannot start without node ID")
}

nodeID, err := flow.HexStringToIdentifier(fnb.BaseConfig.nodeIDHex)
Expand Down Expand Up @@ -1114,7 +1114,7 @@ func (fnb *FlowNodeBuilder) initSecretsDB() error {
}

if fnb.BaseConfig.secretsdir == NotSet {
return fmt.Errorf("missing required flag '--secretsdir'")
return errors.New("missing required flag '--secretsdir'")
}

err := os.MkdirAll(fnb.BaseConfig.secretsdir, 0700)
Expand Down Expand Up @@ -1457,7 +1457,7 @@ func (fnb *FlowNodeBuilder) initLocal() error {
}

if info.Role != flow.RoleExecution {
return fmt.Errorf("observer mode is only available for execution nodes")
return errors.New("observer mode is only available for execution nodes")
}

id := flow.IdentitySkeleton{
Expand Down Expand Up @@ -1506,10 +1506,10 @@ func (fnb *FlowNodeBuilder) initLocal() error {

// ensure that the configured staking/network keys are consistent with the protocol state
if !self.NetworkPubKey.Equals(fnb.NetworkKey.PublicKey()) {
return fmt.Errorf("configured networking key does not match protocol state")
return errors.New("configured networking key does not match protocol state")
}
if !self.StakingPubKey.Equals(fnb.StakingKey.PublicKey()) {
return fmt.Errorf("configured staking key does not match protocol state")
return errors.New("configured staking key does not match protocol state")
}

fnb.Me, err = local.New(self.IdentitySkeleton, fnb.StakingKey)
Expand Down