Skip to content

Commit 869fe1a

Browse files
committed
Rename gosprintfhostport to nosprintfhostport
1 parent d8a4c12 commit 869fe1a

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

.golangci.example.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,6 @@ linters:
16601660
- goprintffuncname
16611661
- gosec
16621662
- gosimple
1663-
- gosprintfhostport
16641663
- govet
16651664
- ifshort
16661665
- importas
@@ -1678,6 +1677,7 @@ linters:
16781677
- nlreturn
16791678
- noctx
16801679
- nolintlint
1680+
- nosprintfhostport
16811681
- paralleltest
16821682
- prealloc
16831683
- predeclared
@@ -1751,7 +1751,6 @@ linters:
17511751
- goprintffuncname
17521752
- gosec
17531753
- gosimple
1754-
- gosprintfhostport
17551754
- govet
17561755
- ifshort
17571756
- importas
@@ -1769,6 +1768,7 @@ linters:
17691768
- nlreturn
17701769
- noctx
17711770
- nolintlint
1771+
- nosprintfhostport
17721772
- paralleltest
17731773
- prealloc
17741774
- predeclared

go.mod

+2-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ require (
153153
github.com/spf13/afero v1.6.0 // indirect
154154
github.com/spf13/cast v1.4.1 // indirect
155155
github.com/spf13/jwalterweatherman v1.1.0 // indirect
156-
github.com/stbenjam/go-sprintf-host-port v0.0.1
157156
github.com/stretchr/objx v0.1.1 // indirect
158157
github.com/subosito/gotenv v1.2.0 // indirect
159158
github.com/tklauser/go-sysconf v0.3.10 // indirect
@@ -171,3 +170,5 @@ require (
171170
gopkg.in/yaml.v2 v2.4.0 // indirect
172171
mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect
173172
)
173+
174+
require github.com/stbenjam/no-sprintf-host-port v0.1.0

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().
@@ -531,6 +526,11 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
531526
WithURL("https://github.com/sonatard/noctx").
532527
WithNoopFallback(m.cfg),
533528

529+
linter.NewConfig(golinters.NewNoSprintfHostPort()).
530+
WithSince("v1.46.0").
531+
WithPresets(linter.PresetStyle).
532+
WithURL("https://github.com/stbenjam/no-sprintf-host-port"),
533+
534534
linter.NewConfig(golinters.NewParallelTest()).
535535
WithSince("v1.33.0").
536536
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)