Skip to content

Commit

Permalink
Mark os consts as deprecated (#88)
Browse files Browse the repository at this point in the history
Mark os consts as deprecated
  • Loading branch information
sashamelentyev authored Feb 5, 2023
1 parent 20cf01f commit c561d44
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 247 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [ main ]

env:
GO_VERSION: 1.19.2
GO_VERSION: 1.19.4

jobs:
run:
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ module github.com/sashamelentyev/usestdlibvars

go 1.19

require golang.org/x/tools v0.1.12
require golang.org/x/tools v0.5.0

require (
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 // indirect
golang.org/x/mod v0.7.0 // indirect
golang.org/x/sys v0.4.0 // indirect
)
13 changes: 7 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8 h1:h+EGohizhe9XlX18rfpa8k8RAc5XyaeamM+0VHRd4lc=
golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA=
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4=
golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k=
20 changes: 4 additions & 16 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func flags() flag.FlagSet {
flags.Bool(TimeLayoutFlag, false, "suggest the use of time.Layout")
flags.Bool(CryptoHashFlag, false, "suggest the use of crypto.Hash.String()")
flags.Bool(RPCDefaultPathFlag, false, "suggest the use of rpc.DefaultXXPath")
flags.Bool(OSDevNullFlag, false, "suggest the use of os.DevNull")
flags.Bool(OSDevNullFlag, false, "[DEPRECATED] suggest the use of os.DevNull")
flags.Bool(SQLIsolationLevelFlag, false, "suggest the use of sql.LevelXX.String()")
flags.Bool(TLSSignatureSchemeFlag, false, "suggest the use of tls.SignatureScheme.String()")
flags.Bool(ConstantKindFlag, false, "suggest the use of constant.Kind.String()")
flags.Bool(SyslogPriorityFlag, false, "suggest the use of syslog.Priority")
flags.Bool(SyslogPriorityFlag, false, "[DEPRECATED] suggest the use of syslog.Priority")
return *flags
}

Expand Down Expand Up @@ -461,13 +461,7 @@ func checkRPCDefaultPath(pass *analysis.Pass, basicLit *ast.BasicLit) {
}
}

func checkOSDevNull(pass *analysis.Pass, basicLit *ast.BasicLit) {
currentVal := getBasicLitValue(basicLit)

if newVal, ok := mapping.OSDevNull[currentVal]; ok {
report(pass, basicLit.Pos(), currentVal, newVal)
}
}
func checkOSDevNull(pass *analysis.Pass, basicLit *ast.BasicLit) {}

func checkSQLIsolationLevel(pass *analysis.Pass, basicLit *ast.BasicLit) {
currentVal := getBasicLitValue(basicLit)
Expand All @@ -493,13 +487,7 @@ func checkConstantKind(pass *analysis.Pass, basicLit *ast.BasicLit) {
}
}

func checkSyslogPriority(pass *analysis.Pass, basicLit *ast.BasicLit) {
currentVal := getBasicLitValue(basicLit)

if newVal, ok := mapping.SyslogPriority[currentVal]; ok {
report(pass, basicLit.Pos(), currentVal, newVal)
}
}
func checkSyslogPriority(pass *analysis.Pass, basicLit *ast.BasicLit) {}

// getBasicLitFromArgs gets the *ast.BasicLit of a function argument.
//
Expand Down
12 changes: 0 additions & 12 deletions pkg/analyzer/internal/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ func main() {
templateName: "test-issue32.go.tmpl",
fileName: "pkg/analyzer/testdata/src/a/http/issue32.go",
},
{
mapping: mapping.OSDevNull,
packageName: "os_test",
templateName: "test-template.go.tmpl",
fileName: "pkg/analyzer/testdata/src/a/os/devnull.go",
},
{
mapping: mapping.SQLIsolationLevel,
packageName: "sql_test",
Expand All @@ -107,12 +101,6 @@ func main() {
templateName: "test-template.go.tmpl",
fileName: "pkg/analyzer/testdata/src/a/constant/kind.go",
},
{
mapping: mapping.SyslogPriority,
packageName: "syslog_test",
templateName: "test-syslog.go.tmpl",
fileName: "pkg/analyzer/testdata/src/a/syslog/priority.go",
},
}

for _, operation := range operations {
Expand Down
4 changes: 0 additions & 4 deletions pkg/analyzer/internal/mapping/mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ var TimeLayout = map[string]string{
time.StampNano: "time.StampNano",
}

var OSDevNull = map[string]string{}

var SQLIsolationLevel = map[string]string{
// sql.LevelDefault.String(): "sql.LevelDefault.String()",
sql.LevelReadUncommitted.String(): "sql.LevelReadUncommitted.String()",
Expand Down Expand Up @@ -199,5 +197,3 @@ var ConstantKind = map[string]string{
constant.Float.String(): "constant.Float.String()",
constant.Complex.String(): "constant.Complex.String()",
}

var SyslogPriority = map[string]string{}
9 changes: 0 additions & 9 deletions pkg/analyzer/internal/mapping/osdevnull.go

This file was deleted.

40 changes: 0 additions & 40 deletions pkg/analyzer/internal/mapping/syslogpriority.go

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/analyzer/os_dev_test.go

This file was deleted.

10 changes: 0 additions & 10 deletions pkg/analyzer/syslog_priority_test.go

This file was deleted.

15 changes: 0 additions & 15 deletions pkg/analyzer/testdata/src/a/os/devnull.go

This file was deleted.

121 changes: 0 additions & 121 deletions pkg/analyzer/testdata/src/a/syslog/priority.go

This file was deleted.

0 comments on commit c561d44

Please sign in to comment.