chore: enable forcetypeassert linter, fix issues (#38804)

Enable [`forcetypeassert`](https://github.com/gostaticanalysis/forcetypeassert)
linter to prevent unchecked type assertions. ~650 issues fixed, most
fixes were clean, some use `setting.PanicInDevOrTesting`.

The only behaviour changes are where code would previously send a 500 error
or panic, a 4xx error is now emitted.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-08-09 10:25:06 +00:00
committed by GitHub
co-authored by wxiaoguang
parent fac8bf2eca
commit 76a81b24f9
248 changed files with 1110 additions and 995 deletions
+3 -3
View File
@@ -75,7 +75,7 @@ func enumeratePackages(ctx *context.Context, filename string, pvs []*packages_mo
Name: "Gem::Version",
Value: []string{p.Version.Version},
},
p.Metadata.(*rubygems_module.Metadata).Platform,
packages_model.DescriptorMetadata[*rubygems_module.Metadata](p).Platform,
})
}
@@ -126,7 +126,7 @@ func ServePackageSpecification(ctx *context.Context) {
zw := zlib.NewWriter(ctx.Resp)
defer zw.Close()
metadata := pd.Metadata.(*rubygems_module.Metadata)
metadata := packages_model.DescriptorMetadata[*rubygems_module.Metadata](pd)
// create a Ruby Gem::Specification object
spec := &rubygems_module.RubyUserDef{
@@ -405,7 +405,7 @@ func makePackageVersionDependency(ctx *context.Context, version *packages_model.
return "", err
}
metadata := pd.Metadata.(*rubygems_module.Metadata)
metadata := packages_model.DescriptorMetadata[*rubygems_module.Metadata](pd)
fullFilename := makeGemFullFileName(pd.Package.Name, version.Version, metadata.Platform)
file, err := packages_model.GetFileForVersionByName(ctx, version.ID, fullFilename, "")
if err != nil {