Skip to content

Commit 75ca383

Browse files
authored
Fix some static check warnings (#252)
firefox/capabilities.go:67:2: only the first constant in this group has an explicit type (SA9004) internal/seleniumtest/seleniumtest.go:719:6: func v is unused (U1000) internal/seleniumtest/seleniumtest.go:1022:8: should use time.Since instead of time.Now().Sub (S1012) remote.go:936:7: should use strings.EqualFold instead (SA6005) selenium.go:220:2: only the first constant in this group has an explicit type (SA9004) selenium_test.go:42:3: should use fmt.Fprintf instead of fmt.Fprint(fmt.Sprintf(...)) (S1038) selenium_test.go:145:10: this result of append is never used, except maybe in other appends (SA4010) selenium_test.go:149:3: this value of opts is never used (SA4006) selenium_test.go:149:10: this result of append is never used, except maybe in other appends (SA4010)
1 parent 0862687 commit 75ca383

5 files changed

Lines changed: 14 additions & 19 deletions

File tree

firefox/capabilities.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ type LogLevel string
6565
// Levels of logging that can be specified in the Log structure.
6666
const (
6767
Trace LogLevel = "trace"
68-
Debug = "debug"
69-
Config = "config"
70-
Info = "info"
71-
Warn = "warn"
72-
Error = "error"
73-
Fatal = "fatal"
68+
Debug LogLevel = "debug"
69+
Config LogLevel = "config"
70+
Info LogLevel = "info"
71+
Warn LogLevel = "warn"
72+
Error LogLevel = "error"
73+
Fatal LogLevel = "fatal"
7474
)
7575

7676
// Log specifies how Firefox should log debug data.

internal/seleniumtest/seleniumtest.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,6 @@ func testGetCookies(t *testing.T, c Config) {
716716
}
717717
}
718718

719-
func v(s string) semver.Version {
720-
return semver.MustParse(s)
721-
}
722-
723719
func testAddCookie(t *testing.T, c Config) {
724720
wd := newRemote(t, newTestCapabilities(t, c), c)
725721
defer quitRemote(t, wd)
@@ -1019,7 +1015,7 @@ func testLog(t *testing.T, c Config) {
10191015
}
10201016
// Make sure the timestamp conversion is vaguely correct. In
10211017
// practice, this difference should be in the milliseconds range.
1022-
if time.Now().Sub(l.Timestamp) > time.Hour {
1018+
if time.Since(l.Timestamp) > time.Hour {
10231019
t.Errorf("Message has timestamp %s > 1 hour ago: %v", l.Timestamp, l)
10241020
}
10251021
}

remote.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ func (c cookie) sanitize() Cookie {
933933
return ""
934934
}
935935
for _, v := range []SameSite{SameSiteNone, SameSiteLax, SameSiteStrict} {
936-
if strings.ToLower(string(v)) == strings.ToLower(s) {
936+
if strings.EqualFold(string(v), s) {
937937
return v
938938
}
939939
}

selenium.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ type SameSite string
218218

219219
const (
220220
SameSiteNone SameSite = "None"
221-
SameSiteLax = "Lax"
222-
SameSiteStrict = "Strict"
223-
SameSiteEmpty = ""
221+
SameSiteLax SameSite = "Lax"
222+
SameSiteStrict SameSite = "Strict"
223+
SameSiteEmpty SameSite = ""
224224
)
225225

226226
// WebDriver defines methods supported by WebDriver drivers.

selenium_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var (
3939
func TestMain(m *testing.M) {
4040
flag.Parse()
4141
if err := setDriverPaths(); err != nil {
42-
fmt.Fprint(os.Stderr, fmt.Sprintf("Exiting early: unable to get the driver paths -- %s", err.Error()))
42+
fmt.Fprintf(os.Stderr, "Exiting early: unable to get the driver paths -- %s", err.Error())
4343
os.Exit(1)
4444
}
4545
os.Exit(m.Run())
@@ -140,13 +140,12 @@ func runChromeTests(t *testing.T, c seleniumtest.Config) {
140140
c.Browser = "chrome"
141141
c.Headless = *headless
142142

143-
var opts []selenium.ServiceOption
144143
if *startFrameBuffer {
145-
opts = append(opts, selenium.StartFrameBuffer())
144+
c.ServiceOptions = append(c.ServiceOptions, selenium.StartFrameBuffer())
146145
}
147146
if testing.Verbose() {
148147
selenium.SetDebug(true)
149-
opts = append(opts, selenium.Output(os.Stderr))
148+
c.ServiceOptions = append(c.ServiceOptions, selenium.Output(os.Stderr))
150149
}
151150

152151
port, err := pickUnusedPort()

0 commit comments

Comments
 (0)