Skip to content

Commit

Permalink
Fix golint warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Chad Wilson <chadw@thoughtworks.com>
  • Loading branch information
chadlwilson committed Aug 14, 2024
1 parent 874ca2e commit e7e4e32
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 28 deletions.
11 changes: 6 additions & 5 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ func RunInBackground(apiPort string, specDirs []string) {
if apiPort != "" {
port, err = strconv.Atoi(apiPort)
if err != nil {
logger.Fatalf(true, fmt.Sprintf("Invalid port number: %s", apiPort))
logger.Fatalf(true, "Invalid port number: %s", apiPort)
}
os.Setenv(common.APIPortEnvVariableName, apiPort)
} else {
port, err = conn.GetPortFromEnvironmentVariable(common.APIPortEnvVariableName)
if err != nil {
logger.Fatalf(true, fmt.Sprintf("Failed to start API Service. %s \n", err.Error()))
logger.Fatalf(true, "Failed to start API Service. %s \n", err.Error())
}
}
runAPIServiceIndefinitely(port, specDirs)
Expand All @@ -140,18 +140,19 @@ func Start(specsDir []string) *conn.GaugeConnectionHandler {
apiHandler := &gaugeAPIMessageHandler{specInfoGatherer: sig}
gaugeConnectionHandler, err := conn.NewGaugeConnectionHandler(0, apiHandler)
if err != nil {
logger.Fatalf(true, err.Error())
logger.Fatalf(true, err.Error()) //nolint:govet
}
errChan := make(chan error)
go func() {
_, err := gaugeConnectionHandler.AcceptConnection(config.RunnerConnectionTimeout(), errChan)
if err != nil {
logger.Fatalf(true, err.Error())
logger.Fatalf(true, err.Error()) //nolint:govet
}
}()
go func() {
e := <-errChan
logger.Fatalf(true, e.Error())
//nolint:govet
logger.Fatalf(true, e.Error()) //nolint:govet
}()
return gaugeConnectionHandler
}
10 changes: 5 additions & 5 deletions api/lang/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type lspWriter struct {
}

func (w lspWriter) Write(p []byte) (n int, err error) {
logger.Debugf(false, string(p))
logger.Debugf(false, string(p)) //nolint:govet
return os.Stderr.Write(p)
}

Expand Down Expand Up @@ -61,25 +61,25 @@ func initialize(ctx context.Context, conn *jsonrpc2.Conn) {

func logDebug(req *jsonrpc2.Request, msg string, args ...interface{}) {
m := fmt.Sprintf(getLogFormatFor(req, msg), args...)
logger.Debugf(false, m)
logger.Debugf(false, m) //nolint:govet
logToLsp(lsp.Log, m)
}

func logInfo(req *jsonrpc2.Request, msg string, args ...interface{}) {
m := fmt.Sprintf(getLogFormatFor(req, msg), args...)
logger.Infof(false, m)
logger.Infof(false, m) //nolint:govet
logToLsp(lsp.Info, m)
}

func logWarning(req *jsonrpc2.Request, msg string, args ...interface{}) {
m := fmt.Sprintf(getLogFormatFor(req, msg), args...)
logger.Warningf(false, m)
logger.Warningf(false, m) //nolint:govet
logToLsp(lsp.MTWarning, m)
}

func logError(req *jsonrpc2.Request, msg string, args ...interface{}) {
m := fmt.Sprintf(getLogFormatFor(req, msg), args...)
logger.Errorf(false, m)
logger.Errorf(false, m) //nolint:govet
logToLsp(lsp.MTError, m)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ func initPackageFlags() {

var exit = func(err error, additionalText string) {
if err != nil {
logger.Errorf(true, err.Error())
logger.Errorf(true, err.Error()) //nolint:govet
}
if additionalText != "" {
logger.Infof(true, additionalText)
logger.Infof(true, additionalText) //nolint:govet
}
os.Exit(1)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
if err != nil {
logger.Fatalf(true, err.Error())

Check failure on line 27 in cmd/config.go

View workflow job for this annotation

GitHub Actions / lint

printf: non-constant format string in call to github.com/getgauge/gauge/logger.Fatalf (govet)
}
logger.Infof(true, text)
logger.Infof(true, text) //nolint:govet
return
}
if len(args) == 0 {
Expand Down
18 changes: 9 additions & 9 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ package cmd

import (
"fmt"
"os"
"strconv"
"strings"
gauge "github.com/getgauge/gauge/gauge"
"github.com/getgauge/gauge/config"
"github.com/getgauge/gauge/env"
"github.com/getgauge/gauge/execution"
"github.com/getgauge/gauge/execution/rerun"
gauge "github.com/getgauge/gauge/gauge"
"github.com/getgauge/gauge/logger"
"github.com/getgauge/gauge/plugin/install"
"github.com/getgauge/gauge/util"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"os"
"strconv"
"strings"
)

const (
Expand Down Expand Up @@ -129,7 +129,7 @@ func init() {
f.StringVarP(&tagsToFilterForParallelRun, onlyName, "o", onlyDefault, "Execute only the specs and scenarios tagged with given tags in parallel, rest will be run in serial. Applicable only if run in parallel.")
err := f.MarkHidden(onlyName)
if err != nil {
logger.Errorf(false, fmt.Sprintf("Unable to mark '%s' flag as hidden: %s", onlyName, err.Error()))
logger.Errorf(false, "Unable to mark '%s' flag as hidden: %s", onlyName, err.Error())
}
f.IntVarP(&group, groupName, "g", groupDefault, "Specify which group of specification to execute based on -n flag")
f.StringVarP(&strategy, strategyName, "", strategyDefault, "Set the parallelization strategy for execution. Possible options are: `eager`, `lazy`")
Expand All @@ -142,7 +142,7 @@ func init() {
f.BoolVarP(&skipCommandSave, skipCommandSaveName, "", skipCommandSaveDefault, "Skip saving last command in lastRunCmd.json")
err = f.MarkHidden(skipCommandSaveName)
if err != nil {
logger.Errorf(false, fmt.Sprintf("Unable to mark '%s' flag as hidden: %s", skipCommandSaveName, err.Error()))
logger.Errorf(false, "Unable to mark '%s' flag as hidden: %s", skipCommandSaveName, err.Error())
}

f.StringArrayVar(&scenarios, scenarioName, scenarioNameDefault, "Set scenarios for running specs with scenario name")
Expand All @@ -159,12 +159,12 @@ func executeFailed(cmd *cobra.Command) {
handleFlags(cmd, append([]string{"gauge"}, lastState...))
err = cmd.Flags().Set(skipCommandSaveName, "true")
if err != nil {
logger.Errorf(false, fmt.Sprintf("Unable to set '%s' flag as 'true': %s", skipCommandSaveName, err.Error()))
logger.Errorf(false, "Unable to set '%s' flag as 'true': %s", skipCommandSaveName, err.Error())
}
logger.Debugf(true, "Executing => %s\n", strings.Join(os.Args, " "))
err = cmd.Execute()
if err != nil {
logger.Errorf(true, fmt.Sprintf("Unable to execute command %s: %s", cmd.Name(), err.Error()))
logger.Errorf(true, "Unable to execute command %s: %s", cmd.Name(), err.Error())
}
}

Expand All @@ -173,7 +173,7 @@ func handleFlags(cmd *cobra.Command, args []string) {
if !util.ListContains(overrideRerunFlags, flag.Name) && flag.Changed {
err := flag.Value.Set(flag.DefValue)
if err != nil {
logger.Errorf(false, fmt.Sprintf("Unable to set default value in '%s' flag: %s", flag.Name, err.Error()))
logger.Errorf(false, "Unable to set default value in '%s' flag: %s", flag.Name, err.Error())
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func isCircular(key, value string) error {
}
_, err := properties.LoadString(fmt.Sprintf("%s=%s", key, value))
if err != nil {
return fmt.Errorf(err.Error())
return fmt.Errorf(err.Error()) //nolint:govet
}
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion filter/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func FilterSpecs(specs []*gauge.Specification) []*gauge.Specification {
if ExecuteTags != "" && len(specs) > 0 {
logger.Debugf(true, "The following specifications satisfy filter criteria:")
for _, s := range specs {
logger.Debugf(true, util.RelPathToProjectRoot(s.FileName))
logger.Debugf(true, util.RelPathToProjectRoot(s.FileName)) //nolint:govet
}
}
return specs
Expand Down
2 changes: 1 addition & 1 deletion parser/conceptParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func AddConcepts(conceptFiles []string, conceptDictionary *gauge.ConceptDictiona
concepts, parseRes := new(ConceptParser).ParseFile(conceptFile)
if parseRes != nil && parseRes.Warnings != nil {
for _, warning := range parseRes.Warnings {
logger.Warningf(true, warning.String())
logger.Warningf(true, warning.String()) //nolint:govet
}
}
parseErrors, err := AddConcept(concepts, conceptFile, conceptDictionary)
Expand Down
4 changes: 2 additions & 2 deletions plugin/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,10 @@ func UpdatePlugins(silent bool) {
// TODO: Merge both HandleInstallResult and HandleUpdateResult, eliminate boolean exitIfFailure
func HandleInstallResult(result InstallResult, pluginName string, exitIfFailure bool) bool {
if result.Info != "" {
logger.Debugf(true, result.Info)
logger.Debugf(true, result.Info) //nolint:govet
}
if result.Warning != "" {
logger.Warningf(true, result.Warning)
logger.Warningf(true, result.Warning) //nolint:govet
}
if result.Skipped {
return true
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

// CurrentGaugeVersion represents the current version of Gauge
var CurrentGaugeVersion = &Version{1, 6, 7}
var CurrentGaugeVersion = &Version{1, 6, 8}

// BuildMetadata represents build information of current release (e.g, nightly build information)
var BuildMetadata = ""
Expand Down

0 comments on commit e7e4e32

Please sign in to comment.