this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: make vet happy

$ go vet ./...
# cuelang.org/go/cue/errors
cue/errors/errors.go:326:15: method Is(err error, target error) bool should have signature Is(error) bool
cue/errors/errors.go:335:15: method As(err error, target interface{}) bool should have signature As(any) bool
# cuelang.org/go/cue/ast/astutil
cue/ast/astutil/resolve.go:207:6: unreachable code

The unreachable code warning is an easy one: just like in other bits of
disabled code, comment it out.

The Is/As signature warning is slightly more worrying.
Presumably due to a mistake, cue/errors.list never actually satisfied
the interfaces used by Go's errors.As and errors.Is.
The added parameter was never used, reinforcing that theory.

Adjust the two methods. We don't strictly need a regression test, given
that `go vet` will now spot that mistake in CI.

And, as per the above, add `go vet` to CI.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Ie6f65a89fb41f232beede0ab732b14f0a0b831a1
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/537656
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+75 -13
+3
.github/workflows/test.yml
··· 89 89 run: go generate ./... 90 90 - name: Test 91 91 run: go test ./... 92 + - if: matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04' 93 + name: Check 94 + run: go vet ./... 92 95 - if: ${{ matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04' }} 93 96 name: Test with -race 94 97 run: go test -race ./...
+15 -1
cmd/cue/cmd/testdata/script/cmd_github.txt
··· 215 215 run: go generate ./... 216 216 - name: Test 217 217 run: go test ./... 218 + - if: matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04' 219 + name: Check 220 + run: go vet ./... 218 221 - if: ${{ matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04' }} 219 222 name: Test with -race 220 223 run: go test -race ./... ··· 1140 1143 steps: [_#writeNetrcFile, _#installGo, _#checkoutCode, _#earlyChecks, _#cacheGoModules, _#step & { 1141 1144 if: "${{ \(_#isMaster) }}" 1142 1145 run: "echo CUE_LONG=true >> $GITHUB_ENV" 1143 - }, _#goGenerate, _#goTest, _#goTestRace & { 1146 + }, _#goGenerate, _#goTest, _#goCheck, _#goTestRace & { 1144 1147 if: "${{ matrix.go-version == '\(_#latestStableGo)' && matrix.os == '\(_#linuxMachine)' }}" 1145 1148 }, _#checkGitClean, _#pullThroughProxy, _#failCLBuild] 1146 1149 } ··· 1406 1409 _#goTest: _#step & { 1407 1410 name: "Test" 1408 1411 run: "go test ./..." 1412 + } 1413 + _#goCheck: _#step & { 1414 + // These checks can vary between platforms, as different code can be built 1415 + // based on GOOS and GOARCH build tags. 1416 + // However, CUE does not have any such build tags yet, and we don't use 1417 + // dependencies that vary wildly between platforms. 1418 + // For now, to save CI resources, just run the checks on one matrix job. 1419 + // TODO: consider adding more checks as per https://github.com/golang/go/issues/42119. 1420 + if: "matrix.go-version == '\(_#latestStableGo)' && matrix.os == '\(_#linuxMachine)'" 1421 + name: "Check" 1422 + run: "go vet ./..." 1409 1423 } 1410 1424 _#goTestRace: _#step & { 1411 1425 name: "Test with -race"
+3 -3
cue/ast/astutil/resolve.go
··· 204 204 if _, ok := existing.node.(*ast.ImportSpec); ok { 205 205 return 206 206 // TODO: 207 - s.errFn(n.Pos(), "conflicting declaration %s\n"+ 208 - "\tprevious declaration at %s", 209 - name, existing.node.Pos()) 207 + // s.errFn(n.Pos(), "conflicting declaration %s\n"+ 208 + // "\tprevious declaration at %s", 209 + // name, existing.node.Pos()) 210 210 } else { 211 211 s.errFn(n.Pos(), "alias %q redeclared in same scope", name) 212 212 }
+2 -2
cue/errors/errors.go
··· 323 323 // The zero value for an list is an empty list ready to use. 324 324 type list []Error 325 325 326 - func (p list) Is(err, target error) bool { 326 + func (p list) Is(target error) bool { 327 327 for _, e := range p { 328 328 if errors.Is(e, target) { 329 329 return true ··· 332 332 return false 333 333 } 334 334 335 - func (p list) As(err error, target interface{}) bool { 335 + func (p list) As(target interface{}) bool { 336 336 for _, e := range p { 337 337 if errors.As(e, target) { 338 338 return true
+39 -7
cue/testdata/eval/github.txtar
··· 58 58 steps: [_#writeNetrcFile, _#installGo, _#checkoutCode, _#earlyChecks, _#cacheGoModules, _#step & { 59 59 if: "${{ \(_#isMaster) }}" 60 60 run: "echo CUE_LONG=true >> $GITHUB_ENV" 61 - }, _#goGenerate, _#goTest, _#goTestRace & { 61 + }, _#goGenerate, _#goTest, _#goCheck, _#goTestRace & { 62 62 if: "${{ matrix.go-version == '\(_#latestStableGo)' && matrix.os == '\(_#linuxMachine)' }}" 63 63 }, _#checkGitClean, _#pullThroughProxy, _#failCLBuild] 64 64 } ··· 324 324 _#goTest: _#step & { 325 325 name: "Test" 326 326 run: "go test ./..." 327 + } 328 + _#goCheck: _#step & { 329 + // These checks can vary between platforms, as different code can be built 330 + // based on GOOS and GOARCH build tags. 331 + // However, CUE does not have any such build tags yet, and we don't use 332 + // dependencies that vary wildly between platforms. 333 + // For now, to save CI resources, just run the checks on one matrix job. 334 + // TODO: consider adding more checks as per https://github.com/golang/go/issues/42119. 335 + if: "matrix.go-version == '\(_#latestStableGo)' && matrix.os == '\(_#linuxMachine)'" 336 + name: "Check" 337 + run: "go vet ./..." 327 338 } 328 339 _#goTestRace: _#step & { 329 340 name: "Test with -race" ··· 1150 1161 run: (string){ "go test ./..." } 1151 1162 } 1152 1163 8: (#struct){ 1164 + if: (string){ "matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04'" } 1165 + name: (string){ "Check" } 1166 + run: (string){ "go vet ./..." } 1167 + } 1168 + 9: (#struct){ 1153 1169 name: (string){ "Test with -race" } 1154 1170 run: (string){ "go test -race ./..." } 1155 1171 if: (string){ "${{ matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04' }}" } 1156 1172 } 1157 - 9: (#struct){ 1173 + 10: (#struct){ 1158 1174 name: (string){ "Check that git is clean post generate and tests" } 1159 1175 run: (string){ "test -z \"$(git status --porcelain)\" || (git status; git diff; false)" } 1160 1176 } 1161 - 10: (#struct){ 1177 + 11: (#struct){ 1162 1178 name: (string){ "Pull this commit through the proxy on master" } 1163 1179 run: (string){ "v=$(git rev-parse HEAD)\ncd $(mktemp -d)\ngo mod init mod.com\nGOPROXY=https://proxy.golang.org go get -d cuelang.org/go/cmd/cue@$v" } 1164 1180 if: (string){ "${{ github.ref == 'refs/heads/master' }}" } 1165 1181 } 1166 - 11: (#struct){ 1182 + 12: (#struct){ 1167 1183 if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }}" } 1168 1184 name: (string){ "Post any failures for this matrix entry" } 1169 1185 run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":-1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } ··· 1667 1683 run: (string){ "go test ./..." } 1668 1684 } 1669 1685 8: (#struct){ 1686 + if: (string){ "matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04'" } 1687 + name: (string){ "Check" } 1688 + run: (string){ "go vet ./..." } 1689 + } 1690 + 9: (#struct){ 1670 1691 name: (string){ "Test with -race" } 1671 1692 run: (string){ "go test -race ./..." } 1672 1693 if: (string){ "${{ matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04' }}" } 1673 1694 } 1674 - 9: (#struct){ 1695 + 10: (#struct){ 1675 1696 name: (string){ "Check that git is clean post generate and tests" } 1676 1697 run: (string){ "test -z \"$(git status --porcelain)\" || (git status; git diff; false)" } 1677 1698 } 1678 - 10: (#struct){ 1699 + 11: (#struct){ 1679 1700 name: (string){ "Pull this commit through the proxy on master" } 1680 1701 run: (string){ "v=$(git rev-parse HEAD)\ncd $(mktemp -d)\ngo mod init mod.com\nGOPROXY=https://proxy.golang.org go get -d cuelang.org/go/cmd/cue@$v" } 1681 1702 if: (string){ "${{ github.ref == 'refs/heads/master' }}" } 1682 1703 } 1683 - 11: (#struct){ 1704 + 12: (#struct){ 1684 1705 if: (string){ "${{ startsWith(github.ref, 'refs/heads/ci/') && failure() }}" } 1685 1706 name: (string){ "Post any failures for this matrix entry" } 1686 1707 run: (string){ "curl -f -s -n -H \"Content-Type: application/json\" --request POST --data \"{\\\"tag\\\":\\\"trybot\\\",\\\"message\\\":\\\"Build failed for ${{ runner.os }}-${{ matrix.go-version }}; see ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }} for more details\\\",\\\"labels\\\":{\\\"TryBot-Result\\\":-1}}\" https://review.gerrithub.io/a/changes/$(basename $(dirname $GITHUB_REF))/revisions/$(basename $GITHUB_REF)/review" } ··· 2173 2194 name: (string){ "Test" } 2174 2195 run: (string){ "go test ./..." } 2175 2196 } 2197 + _#goCheck(:ci): (#struct){ 2198 + if: (string){ "matrix.go-version == '1.18.x' && matrix.os == 'ubuntu-20.04'" } 2199 + name: (string){ "Check" } 2200 + run: (string){ "go vet ./..." } 2201 + } 2176 2202 _#goTestRace(:ci): (#struct){ 2177 2203 name: (string){ "Test with -race" } 2178 2204 run: (string){ "go test -race ./..." } ··· 2259 2285 }), 2260 2286 〈4;_#goGenerate〉, 2261 2287 〈4;_#goTest〉, 2288 + 〈4;_#goCheck〉, 2262 2289 (〈4;_#goTestRace〉 & { 2263 2290 if: "${{ matrix.go-version == '\(〈5;_#latestStableGo〉)' && matrix.os == '\(〈5;_#linuxMachine〉)' }}" 2264 2291 }), ··· 2549 2576 _#goTest: (〈0;_#step〉 & { 2550 2577 name: "Test" 2551 2578 run: "go test ./..." 2579 + }) 2580 + _#goCheck: (〈0;_#step〉 & { 2581 + if: "matrix.go-version == '\(〈1;_#latestStableGo〉)' && matrix.os == '\(〈1;_#linuxMachine〉)'" 2582 + name: "Check" 2583 + run: "go vet ./..." 2552 2584 }) 2553 2585 _#goTestRace: (〈0;_#step〉 & { 2554 2586 name: "Test with -race"
+13
internal/ci/workflows.cue
··· 81 81 }, 82 82 _#goGenerate, 83 83 _#goTest, 84 + _#goCheck, 84 85 _#goTestRace & { 85 86 if: "${{ matrix.go-version == '\(_#latestStableGo)' && matrix.os == '\(_#linuxMachine)' }}" 86 87 }, ··· 410 411 _#goTest: _#step & { 411 412 name: "Test" 412 413 run: "go test ./..." 414 + } 415 + 416 + _#goCheck: _#step & { 417 + // These checks can vary between platforms, as different code can be built 418 + // based on GOOS and GOARCH build tags. 419 + // However, CUE does not have any such build tags yet, and we don't use 420 + // dependencies that vary wildly between platforms. 421 + // For now, to save CI resources, just run the checks on one matrix job. 422 + // TODO: consider adding more checks as per https://github.com/golang/go/issues/42119. 423 + if: "matrix.go-version == '\(_#latestStableGo)' && matrix.os == '\(_#linuxMachine)'" 424 + name: "Check" 425 + run: "go vet ./..." 413 426 } 414 427 415 428 _#goTestRace: _#step & {