Skip to content

Commit a9b1541

Browse files
committed
Rename gosprintfhostport to nosprintfhostport
1 parent 6293bb4 commit a9b1541

File tree

6 files changed

+21
-16
lines changed

6 files changed

+21
-16
lines changed

.golangci.example.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1662,7 +1662,6 @@ linters:
16621662
- goprintffuncname
16631663
- gosec
16641664
- gosimple
1665-
- gosprintfhostport
16661665
- govet
16671666
- ifshort
16681667
- importas
@@ -1680,6 +1679,7 @@ linters:
16801679
- nlreturn
16811680
- noctx
16821681
- nolintlint
1682+
- nosprintfhostport
16831683
- paralleltest
16841684
- prealloc
16851685
- predeclared
@@ -1753,7 +1753,6 @@ linters:
17531753
- goprintffuncname
17541754
- gosec
17551755
- gosimple
1756-
- gosprintfhostport
17571756
- govet
17581757
- ifshort
17591758
- importas
@@ -1771,6 +1770,7 @@ linters:
17711770
- nlreturn
17721771
- noctx
17731772
- nolintlint
1773+
- nosprintfhostport
17741774
- paralleltest
17751775
- prealloc
17761776
- predeclared

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ require (
8383
github.com/spf13/pflag v1.0.5
8484
github.com/spf13/viper v1.11.0
8585
github.com/ssgreg/nlreturn/v2 v2.2.1
86+
github.com/stbenjam/no-sprintf-host-port v0.1.0
8687
github.com/stretchr/testify v1.7.1
8788
github.com/sylvia7788/contextcheck v1.0.4
8889
github.com/tdakkota/asciicheck v0.1.1
@@ -156,7 +157,6 @@ require (
156157
github.com/spf13/afero v1.8.2 // indirect
157158
github.com/spf13/cast v1.4.1 // indirect
158159
github.com/spf13/jwalterweatherman v1.1.0 // indirect
159-
github.com/stbenjam/go-sprintf-host-port v0.0.1
160160
github.com/stretchr/objx v0.1.1 // indirect
161161
github.com/subosito/gotenv v1.2.0 // indirect
162162
github.com/tklauser/go-sysconf v0.3.10 // indirect

go.sum

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/gosprintfhostport.go renamed to pkg/golinters/nosprintfhostport.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package golinters
22

33
import (
4-
"github.com/stbenjam/go-sprintf-host-port/pkg/analyzer"
4+
"github.com/stbenjam/no-sprintf-host-port/pkg/analyzer"
55
"golang.org/x/tools/go/analysis"
66

77
"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
88
)
99

10-
func NewGoSprintfHostPort() *goanalysis.Linter {
10+
func NewNoSprintfHostPort() *goanalysis.Linter {
1111
a := analyzer.Analyzer
1212

1313
return goanalysis.NewLinter(

pkg/lint/lintersdb/manager.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,6 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
421421
WithAlternativeNames(megacheckName).
422422
WithURL("https://github.com/dominikh/go-tools/tree/master/simple"),
423423

424-
linter.NewConfig(golinters.NewGoSprintfHostPort()).
425-
WithSince("v1.46.0").
426-
WithPresets(linter.PresetStyle).
427-
WithURL("https://github.com/stbenjam/go-sprintf-host-port"),
428-
429424
linter.NewConfig(golinters.NewGovet(govetCfg)).
430425
WithSince("v1.0.0").
431426
WithLoadForGoAnalysis().
@@ -536,6 +531,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
536531
WithPresets(linter.PresetStyle).
537532
WithURL("https://github.com/firefart/nonamedreturns"),
538533

534+
linter.NewConfig(golinters.NewNoSprintfHostPort()).
535+
WithSince("v1.46.0").
536+
WithPresets(linter.PresetStyle).
537+
WithURL("https://github.com/stbenjam/no-sprintf-host-port"),
538+
539539
linter.NewConfig(golinters.NewParallelTest()).
540540
WithSince("v1.33.0").
541541
WithPresets(linter.PresetStyle, linter.PresetTest).

test/testdata/gosprintfhostport.go renamed to test/testdata/nosprintfhostport.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//args: -Egosprintfhostport
1+
//args: -Enosprintfhostport
22
package testdata
33

44
import (
@@ -7,15 +7,18 @@ import (
77
)
88

99
func _() {
10-
_ = fmt.Sprintf("gopher://%s/foo", net.JoinHostPort("foo", "80"))
1110

1211
_ = fmt.Sprintf("postgres://%s:%[email protected]/%s", "foo", "bar", "baz")
1312

14-
_ = fmt.Sprintf("http://%s/foo", net.JoinHostPort("foo", "80"))
13+
_ = fmt.Sprintf("http://api.%s/foo", "example.com")
1514

1615
_ = fmt.Sprintf("http://api.%s:6443/foo", "example.com")
1716

18-
_ = fmt.Sprintf("http://api.%s/foo", "example.com")
17+
_ = fmt.Sprintf("http://%s/foo", net.JoinHostPort("foo", "80"))
18+
19+
_ = fmt.Sprintf("9invalidscheme://%s:%d", "myHost", 70)
20+
21+
_ = fmt.Sprintf("gopher://%s/foo", net.JoinHostPort("foo", "80"))
1922

2023
_ = fmt.Sprintf("telnet+ssl://%s/foo", net.JoinHostPort("foo", "80"))
2124

@@ -29,6 +32,8 @@ func _() {
2932

3033
_ = fmt.Sprintf("telnet+ssl://%s:%d", "myHost", 23) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf"
3134

35+
_ = fmt.Sprintf("weird3.6://%s:%d", "myHost", 23) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf"
36+
3237
_ = fmt.Sprintf("https://user@%s:%d", "myHost", 8443) // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf"
3338

3439
_ = fmt.Sprintf("postgres://%s:%s@%s:5050/%s", "foo", "bar", "baz", "qux") // ERROR "host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf"

0 commit comments

Comments
 (0)