This is an automated email from the ASF dual-hosted git repository.
zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git
The following commit(s) were added to refs/heads/main by this push:
new 8ff2e915 refactor(ci): use staticcheck from golangci-lint (#700)
8ff2e915 is described below
commit 8ff2e91588a8801f2fcf8f65f8f2bd4485c5dc43
Author: ferhat elmas <[email protected]>
AuthorDate: Mon Jan 26 20:32:56 2026 +0100
refactor(ci): use staticcheck from golangci-lint (#700)
Instead of maintaining two things, one tool handles both.
Signed-off-by: ferhat elmas <[email protected]>
---
.github/workflows/go-ci.yml | 4 ----
.golangci.yml | 1 +
catalog/rest/rest_test.go | 14 ++++++++------
exprs.go | 22 +++++++++++++---------
io/blob.go | 8 ++++----
manifest.go | 2 +-
schema.go | 4 ++--
table/metadata.go | 2 +-
table/metadata_builder_internal_test.go | 1 +
table/table_test.go | 2 +-
10 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/.github/workflows/go-ci.yml b/.github/workflows/go-ci.yml
index 900706c5..46bba509 100644
--- a/.github/workflows/go-ci.yml
+++ b/.github/workflows/go-ci.yml
@@ -49,14 +49,10 @@ jobs:
go-version: ${{ matrix.go }}
cache: true
cache-dependency-path: go.sum
- - name: Install staticcheck
- run: GOTOOLCHAIN='go1.24.9' go install
honnef.co/go/tools/cmd/[email protected]
- name: Run golangci-lint
uses:
golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7
with:
version: v2.0.2
args: --timeout=10m
- - name: Lint
- run: staticcheck ./...
- name: Run tests
run: go test -v ./...
diff --git a/.golangci.yml b/.golangci.yml
index 1d63a7cb..090e4ab6 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -23,6 +23,7 @@ linters:
- misspell
- nlreturn
- perfsprint
+ - staticcheck
settings:
errcheck:
exclude-functions:
diff --git a/catalog/rest/rest_test.go b/catalog/rest/rest_test.go
index 91ae11c8..561e0205 100644
--- a/catalog/rest/rest_test.go
+++ b/catalog/rest/rest_test.go
@@ -490,7 +490,8 @@ func (r *RestCatalogSuite) TestListTablesPagination() {
r.Equal(strconv.Itoa(defaultPageSize), pageSize)
var response map[string]any
- if pageToken == "" {
+ switch pageToken {
+ case "":
response = map[string]any{
"identifiers": []any{
map[string]any{
@@ -504,7 +505,7 @@ func (r *RestCatalogSuite) TestListTablesPagination() {
},
"next-page-token": "token1",
}
- } else if pageToken == "token1" {
+ case "token1":
r.Equal("token1", pageToken)
response = map[string]any{
"identifiers": []any{
@@ -519,7 +520,7 @@ func (r *RestCatalogSuite) TestListTablesPagination() {
},
"next-page-token": "token2",
}
- } else {
+ default:
r.Equal("token2", pageToken)
response = map[string]any{
"identifiers": []any{
@@ -1782,7 +1783,8 @@ func (r *RestCatalogSuite) TestListViewsPagination() {
r.Equal(strconv.Itoa(defaultPageSize), pageSize)
var response map[string]any
- if pageToken == "" {
+ switch pageToken {
+ case "":
response = map[string]any{
"identifiers": []any{
map[string]any{
@@ -1796,7 +1798,7 @@ func (r *RestCatalogSuite) TestListViewsPagination() {
},
"next-page-token": "token1",
}
- } else if pageToken == "token1" {
+ case "token1":
r.Equal("token1", pageToken)
response = map[string]any{
"identifiers": []any{
@@ -1811,7 +1813,7 @@ func (r *RestCatalogSuite) TestListViewsPagination() {
},
"next-page-token": "token2",
}
- } else {
+ default:
r.Equal("token2", pageToken)
response = map[string]any{
"identifiers": []any{
diff --git a/exprs.go b/exprs.go
index 47afe40a..68ced28c 100644
--- a/exprs.go
+++ b/exprs.go
@@ -723,7 +723,7 @@ func (ul *unboundLiteralPredicate) Bind(schema *Schema,
caseSensitive bool) (Boo
}
if (ul.op == OpStartsWith || ul.op == OpNotStartsWith) &&
- !(bound.Type().Equals(PrimitiveTypes.String) ||
bound.Type().Equals(PrimitiveTypes.Binary)) {
+ (!bound.Type().Equals(PrimitiveTypes.String) &&
!bound.Type().Equals(PrimitiveTypes.Binary)) {
return nil, fmt.Errorf("%w: StartsWith and NotStartsWith must
bind to String type, not %s",
ErrType, bound.Type())
}
@@ -853,15 +853,17 @@ func SetPredicate(op Operation, t UnboundTerm, lits
[]Literal) BooleanExpression
switch len(lits) {
case 0:
- if op == OpIn {
+ switch op {
+ case OpIn:
return AlwaysFalse{}
- } else if op == OpNotIn {
+ case OpNotIn:
return AlwaysTrue{}
}
case 1:
- if op == OpIn {
+ switch op {
+ case OpIn:
return LiteralPredicate(OpEQ, t, lits[0])
- } else if op == OpNotIn {
+ case OpNotIn:
return LiteralPredicate(OpNEQ, t, lits[0])
}
}
@@ -926,15 +928,17 @@ func createBoundSetPredicate(op Operation, term
BoundTerm, lits Set[Literal]) (B
switch typedSet.Len() {
case 0:
- if op == OpIn {
+ switch op {
+ case OpIn:
return AlwaysFalse{}, nil
- } else if op == OpNotIn {
+ case OpNotIn:
return AlwaysTrue{}, nil
}
case 1:
- if op == OpIn {
+ switch op {
+ case OpIn:
return createBoundLiteralPredicate(OpEQ, term,
typedSet.Members()[0])
- } else if op == OpNotIn {
+ case OpNotIn:
return createBoundLiteralPredicate(OpNEQ, term,
typedSet.Members()[0])
}
}
diff --git a/io/blob.go b/io/blob.go
index fa09f7c5..98970af2 100644
--- a/io/blob.go
+++ b/io/blob.go
@@ -47,7 +47,7 @@ func (f *blobOpenFile) ReadAt(p []byte, off int64) (n int,
err error) {
if f.b.newRangeReader != nil {
rdr, err = f.b.newRangeReader(f.ctx, f.key, off, int64(len(p)))
} else {
- rdr, err = f.b.Bucket.NewRangeReader(f.ctx, f.key, off,
int64(len(p)), nil)
+ rdr, err = f.b.NewRangeReader(f.ctx, f.key, off, int64(len(p)),
nil)
}
if err != nil {
return 0, err
@@ -130,7 +130,7 @@ func (bfs *blobFileIO) Remove(name string) error {
return &fs.PathError{Op: "remove", Path: name, Err: err}
}
- return bfs.Bucket.Delete(bfs.ctx, name)
+ return bfs.Delete(bfs.ctx, name)
}
func (bfs *blobFileIO) Create(name string) (FileWriter, error) {
@@ -144,7 +144,7 @@ func (bfs *blobFileIO) WriteFile(name string, content
[]byte) error {
return &fs.PathError{Op: "write file", Path: name, Err: err}
}
- return bfs.Bucket.WriteAll(bfs.ctx, name, content, nil)
+ return bfs.WriteAll(bfs.ctx, name, content, nil)
}
// NewWriter returns a Writer that writes to the blob stored at path.
@@ -165,7 +165,7 @@ func (bfs *blobFileIO) NewWriter(ctx context.Context, path
string, overwrite boo
}
if !overwrite {
- if exists, err := bfs.Bucket.Exists(ctx, path); exists {
+ if exists, err := bfs.Exists(ctx, path); exists {
if err != nil {
return nil, &fs.PathError{Op: "new writer",
Path: path, Err: err}
}
diff --git a/manifest.go b/manifest.go
index 5e591a99..48bae7a6 100644
--- a/manifest.go
+++ b/manifest.go
@@ -181,7 +181,7 @@ type manifestFileV1 struct {
}
func (m *manifestFileV1) toFile() *manifestFile {
- m.manifestFile.version = 1
+ m.version = 1
m.Content = ManifestContentData
m.SeqNumber, m.MinSeqNumber = initialSequenceNumber,
initialSequenceNumber
diff --git a/schema.go b/schema.go
index a13b8a32..f3bd9ce0 100644
--- a/schema.go
+++ b/schema.go
@@ -1292,7 +1292,7 @@ func (s *setFreshIDs) Primitive(p PrimitiveType) Type {
// it is nil then a simple incrementing counter is used starting at 1.
func AssignFreshSchemaIDs(sc *Schema, nextID func() int) (*Schema, error) {
if nextID == nil {
- var id int = 0
+ id := 0
nextID = func() int {
id++
@@ -1505,7 +1505,7 @@ func sanitizeName(n string) string {
b.Grow(len(n))
first := n[0]
- if !(unicode.IsLetter(rune(first)) || first == '_') {
+ if !unicode.IsLetter(rune(first)) && first != '_' {
b.WriteString(sanitize(rune(first)))
} else {
b.WriteByte(first)
diff --git a/table/metadata.go b/table/metadata.go
index 5ddedf8d..794c58f8 100644
--- a/table/metadata.go
+++ b/table/metadata.go
@@ -1616,7 +1616,7 @@ func initMetadataV1Deser() *metadataV1 {
meta := metadataV1{
commonMetadata: initCommonMetadataForDeserialization(),
}
- meta.commonMetadata.DefaultSortOrderID = 0
+ meta.DefaultSortOrderID = 0
return &meta
}
diff --git a/table/metadata_builder_internal_test.go
b/table/metadata_builder_internal_test.go
index 8fe67123..7840497a 100644
--- a/table/metadata_builder_internal_test.go
+++ b/table/metadata_builder_internal_test.go
@@ -76,6 +76,7 @@ func builderWithoutChanges(formatVersion int) MetadataBuilder
{
panic(err)
}
if err = builder.SetLoc("s3://bucket/test/location"); err != nil {
+ panic(err)
}
if err = builder.AddSchema(&tableSchema); err != nil {
panic(err)
diff --git a/table/table_test.go b/table/table_test.go
index cf5ae1ba..addc9346 100644
--- a/table/table_test.go
+++ b/table/table_test.go
@@ -334,7 +334,7 @@ func (t *TableWritingTestSuite) SetupSuite() {
}
func (t *TableWritingTestSuite) SetupTest() {
- t.location = filepath.ToSlash(strings.Replace(t.T().TempDir(), "#", "",
-1))
+ t.location = filepath.ToSlash(strings.ReplaceAll(t.T().TempDir(), "#",
""))
}
func (t *TableWritingTestSuite) TearDownSuite() {