mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Add golang.org/x/tools modernize static analyzer and fix violations (#15946)
* Ran gopls modernize to fix everything go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... * Override rules_go provided dependency for golang.org/x/tools to v0.38.0. To update this, checked out rules_go, then ran `bazel run //go/tools/releaser -- upgrade-dep -mirror=false org_golang_x_tools` and copied the patches. * Fix buildtag violations and ignore buildtag violations in external * Introduce modernize analyzer package. * Add modernize "any" analyzer. * Fix violations of any analyzer * Add modernize "appendclipped" analyzer. * Fix violations of appendclipped * Add modernize "bloop" analyzer. * Add modernize "fmtappendf" analyzer. * Add modernize "forvar" analyzer. * Add modernize "mapsloop" analyzer. * Add modernize "minmax" analyzer. * Fix violations of minmax analyzer * Add modernize "omitzero" analyzer. * Add modernize "rangeint" analyzer. * Fix violations of rangeint. * Add modernize "reflecttypefor" analyzer. * Fix violations of reflecttypefor analyzer. * Add modernize "slicescontains" analyzer. * Add modernize "slicessort" analyzer. * Add modernize "slicesdelete" analyzer. This is disabled by default for now. See https://go.dev/issue/73686. * Add modernize "stringscutprefix" analyzer. * Add modernize "stringsbuilder" analyzer. * Fix violations of stringsbuilder analyzer. * Add modernize "stringsseq" analyzer. * Add modernize "testingcontext" analyzer. * Add modernize "waitgroup" analyzer. * Changelog fragment * gofmt * gazelle * Add modernize "newexpr" analyzer. * Disable newexpr until go1.26 * Add more details in WORKSPACE on how to update the override * @nalepae feedback on min() * gofmt * Fix violations of forvar
This commit is contained in:
@@ -27,7 +27,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -25,7 +25,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -22,7 +22,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -34,7 +34,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
// This threshold should be lowered to 50 over time.
|
||||
const over = 100
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspectResult, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -23,7 +23,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
insp, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -33,7 +33,7 @@ var selectedInterfaces = []string{
|
||||
"interface.WriteOnlyBeaconState",
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -29,7 +29,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -18,7 +18,7 @@ const Doc = "This analyzer requires that log statements do not use errors in tem
|
||||
const errImproperUsage = "use log.WithError rather than templated log statements with errors"
|
||||
|
||||
// Map of logrus templated log functions.
|
||||
var logFns = map[string]interface{}{
|
||||
var logFns = map[string]any{
|
||||
"Debugf": nil,
|
||||
"Infof": nil,
|
||||
"Printf": nil,
|
||||
@@ -37,7 +37,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspect, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -22,7 +22,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -38,7 +38,7 @@ func optimalSort(sizes gcSizes, str *types.Struct) string {
|
||||
fields := make([]*types.Var, nf)
|
||||
alignofs := make([]int64, nf)
|
||||
sizeofs := make([]int64, nf)
|
||||
for i := 0; i < nf; i++ {
|
||||
for i := range nf {
|
||||
fields[i] = str.Field(i)
|
||||
ft := fields[i].Type()
|
||||
alignofs[i] = sizes.Alignof(ft)
|
||||
@@ -62,7 +62,7 @@ func optimalSize(str *types.Struct, sizes *gcSizes) int64 {
|
||||
fields := make([]*types.Var, nf)
|
||||
alignofs := make([]int64, nf)
|
||||
sizeofs := make([]int64, nf)
|
||||
for i := 0; i < nf; i++ {
|
||||
for i := range nf {
|
||||
fields[i] = str.Field(i)
|
||||
ft := fields[i].Type()
|
||||
alignofs[i] = sizes.Alignof(ft)
|
||||
@@ -197,7 +197,7 @@ func (s *gcSizes) Sizeof(T types.Type) int64 {
|
||||
|
||||
var o int64
|
||||
max := int64(1)
|
||||
for i := 0; i < nf; i++ {
|
||||
for i := range nf {
|
||||
ft := t.Field(i).Type()
|
||||
a, sz := s.Alignof(ft), s.Sizeof(ft)
|
||||
if a > max {
|
||||
|
||||
5
tools/analyzers/modernize/README.md
Normal file
5
tools/analyzers/modernize/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Modernize
|
||||
|
||||
These are analyzers that are re-exported from golang.org/x/tools/go/analysis/passes/modernize.
|
||||
|
||||
nogo expects a package to contain a single analyzer, while modernize exposes the named analyzers and an analyzer suite. This is incompatible with nogo so we have re-exported each analyzer.
|
||||
9
tools/analyzers/modernize/any/BUILD.bazel
Normal file
9
tools/analyzers/modernize/any/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/any",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/any/analyzer.go
Normal file
5
tools/analyzers/modernize/any/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package any
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.AnyAnalyzer
|
||||
9
tools/analyzers/modernize/appendclipped/BUILD.bazel
Normal file
9
tools/analyzers/modernize/appendclipped/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/appendclipped",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/appendclipped/analyzer.go
Normal file
5
tools/analyzers/modernize/appendclipped/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package appendclipped
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.AppendClippedAnalyzer
|
||||
9
tools/analyzers/modernize/bloop/BUILD.bazel
Normal file
9
tools/analyzers/modernize/bloop/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/bloop",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/bloop/analyzer.go
Normal file
5
tools/analyzers/modernize/bloop/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package bloop
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.BLoopAnalyzer
|
||||
9
tools/analyzers/modernize/fmtappendf/BUILD.bazel
Normal file
9
tools/analyzers/modernize/fmtappendf/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/fmtappendf",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/fmtappendf/analyzer.go
Normal file
5
tools/analyzers/modernize/fmtappendf/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package fmtappendf
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.FmtAppendfAnalyzer
|
||||
9
tools/analyzers/modernize/forvar/BUILD.bazel
Normal file
9
tools/analyzers/modernize/forvar/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/forvar",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/forvar/analyzer.go
Normal file
5
tools/analyzers/modernize/forvar/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package forvar
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.ForVarAnalyzer
|
||||
9
tools/analyzers/modernize/mapsloop/BUILD.bazel
Normal file
9
tools/analyzers/modernize/mapsloop/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/mapsloop",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/mapsloop/analyzer.go
Normal file
5
tools/analyzers/modernize/mapsloop/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package mapsloop
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.MapsLoopAnalyzer
|
||||
9
tools/analyzers/modernize/minmax/BUILD.bazel
Normal file
9
tools/analyzers/modernize/minmax/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/minmax",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/minmax/analyzer.go
Normal file
5
tools/analyzers/modernize/minmax/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package minmax
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.MinMaxAnalyzer
|
||||
9
tools/analyzers/modernize/newexpr/BUILD.bazel
Normal file
9
tools/analyzers/modernize/newexpr/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/newexpr",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/newexpr/analyzer.go
Normal file
5
tools/analyzers/modernize/newexpr/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package newexpr
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.NewExprAnalyzer
|
||||
9
tools/analyzers/modernize/omitzero/BUILD.bazel
Normal file
9
tools/analyzers/modernize/omitzero/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/omitzero",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/omitzero/analyzer.go
Normal file
5
tools/analyzers/modernize/omitzero/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package omitzero
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.OmitZeroAnalyzer
|
||||
9
tools/analyzers/modernize/rangeint/BUILD.bazel
Normal file
9
tools/analyzers/modernize/rangeint/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/rangeint",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/rangeint/analyzer.go
Normal file
5
tools/analyzers/modernize/rangeint/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package rangeint
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.RangeIntAnalyzer
|
||||
9
tools/analyzers/modernize/reflecttypefor/BUILD.bazel
Normal file
9
tools/analyzers/modernize/reflecttypefor/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/reflecttypefor",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/reflecttypefor/analyzer.go
Normal file
5
tools/analyzers/modernize/reflecttypefor/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package reflecttypefor
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.ReflectTypeForAnalyzer
|
||||
9
tools/analyzers/modernize/slicescontains/BUILD.bazel
Normal file
9
tools/analyzers/modernize/slicescontains/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/slicescontains",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/slicescontains/analyzer.go
Normal file
5
tools/analyzers/modernize/slicescontains/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package slicescontains
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.SlicesContainsAnalyzer
|
||||
9
tools/analyzers/modernize/slicesdelete/BUILD.bazel
Normal file
9
tools/analyzers/modernize/slicesdelete/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/slicesdelete",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/slicesdelete/analyzer.go
Normal file
5
tools/analyzers/modernize/slicesdelete/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package slicesdelete
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.SlicesDeleteAnalyzer
|
||||
9
tools/analyzers/modernize/slicessort/BUILD.bazel
Normal file
9
tools/analyzers/modernize/slicessort/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/slicessort",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/slicessort/analyzer.go
Normal file
5
tools/analyzers/modernize/slicessort/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package slicessort
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.SlicesSortAnalyzer
|
||||
9
tools/analyzers/modernize/stringsbuilder/BUILD.bazel
Normal file
9
tools/analyzers/modernize/stringsbuilder/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/stringsbuilder",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/stringsbuilder/analyzer.go
Normal file
5
tools/analyzers/modernize/stringsbuilder/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package stringsbuilder
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.StringsBuilderAnalyzer
|
||||
9
tools/analyzers/modernize/stringscutprefix/BUILD.bazel
Normal file
9
tools/analyzers/modernize/stringscutprefix/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/stringscutprefix",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/stringscutprefix/analyzer.go
Normal file
5
tools/analyzers/modernize/stringscutprefix/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package stringscutprefix
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.StringsCutPrefixAnalyzer
|
||||
9
tools/analyzers/modernize/stringsseq/BUILD.bazel
Normal file
9
tools/analyzers/modernize/stringsseq/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/stringsseq",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/stringsseq/analyzer.go
Normal file
5
tools/analyzers/modernize/stringsseq/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package stringsseq
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.StringsSeqAnalyzer
|
||||
9
tools/analyzers/modernize/testingcontext/BUILD.bazel
Normal file
9
tools/analyzers/modernize/testingcontext/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/testingcontext",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/testingcontext/analyzer.go
Normal file
5
tools/analyzers/modernize/testingcontext/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package testingcontext
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.TestingContextAnalyzer
|
||||
9
tools/analyzers/modernize/waitgroup/BUILD.bazel
Normal file
9
tools/analyzers/modernize/waitgroup/BUILD.bazel
Normal file
@@ -0,0 +1,9 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["analyzer.go"],
|
||||
importpath = "github.com/OffchainLabs/prysm/v7/tools/analyzers/modernize/waitgroup",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_golang_x_tools//go/analysis/passes/modernize:go_default_library"],
|
||||
)
|
||||
5
tools/analyzers/modernize/waitgroup/analyzer.go
Normal file
5
tools/analyzers/modernize/waitgroup/analyzer.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package waitgroup
|
||||
|
||||
import "golang.org/x/tools/go/analysis/passes/modernize"
|
||||
|
||||
var Analyzer = modernize.WaitGroupAnalyzer
|
||||
@@ -25,7 +25,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -22,7 +22,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -31,7 +31,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -65,7 +65,7 @@ func (m mode) ErrorFound() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspectResult, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
@@ -163,7 +163,7 @@ func stmtSelector(node ast.Node, pass *analysis.Pass, keepTrackOf *tracker, insp
|
||||
}
|
||||
case *ast.IfStmt:
|
||||
stmts := stmt.Body.List
|
||||
for i := 0; i < len(stmts); i++ {
|
||||
for i := range stmts {
|
||||
keepTrackOf = stmtSelector(stmts[i], pass, keepTrackOf, inspect)
|
||||
}
|
||||
keepTrackOf = stmtSelector(stmt.Else, pass, keepTrackOf, inspect)
|
||||
|
||||
@@ -32,7 +32,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -23,7 +23,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
@@ -24,7 +24,7 @@ var Analyzer = &analysis.Analyzer{
|
||||
Run: run,
|
||||
}
|
||||
|
||||
func run(pass *analysis.Pass) (interface{}, error) {
|
||||
func run(pass *analysis.Pass) (any, error) {
|
||||
inspection, ok := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
|
||||
if !ok {
|
||||
return nil, errors.New("analyzer is not type *inspector.Inspector")
|
||||
|
||||
Reference in New Issue
Block a user