[fork_check] Clean up unused file
I introduced this file in
commit 7fafae0f3d68b0a57a4532f7e2bd0fed7a2a1bf3, then renamed it during
code review (to "internal/go_checks/fork_check/main.go") but forgot to
delete it from the original location.
Change-Id: I7e2f1c49f0b3730cd441a673baa06a4e1162f8d9
Reviewed-on: https://fuchsia-review.googlesource.com/c/shac-project/shac/+/911232
Fuchsia-Auto-Submit: Oliver Newman <olivernewman@google.com>
Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
Reviewed-by: Danny Rosen <dannyrosen@google.com>
diff --git a/cmd/fork_check/main.go b/cmd/fork_check/main.go
deleted file mode 100644
index 56eb61c..0000000
--- a/cmd/fork_check/main.go
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2023 The Shac Authors
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-// Package main implements a check that the os/exec.Cmd Start() and Run()
-// functions aren't called directly.
-//
-// Instead, callers should use the execsupport package.
-package main
-
-import (
- "go/ast"
-
- "golang.org/x/tools/go/analysis"
- "golang.org/x/tools/go/analysis/multichecker"
-)
-
-func run(pass *analysis.Pass) (any, error) {
- for _, f := range pass.Files {
- ast.Inspect(f, func(n ast.Node) bool {
- if n == nil {
- return false
- }
- call, ok := n.(*ast.CallExpr)
- if !ok {
- return true
- }
- selector, ok := call.Fun.(*ast.SelectorExpr)
- if !ok {
- return true
- }
- funcName := selector.Sel.Name
- if funcName != "Start" && funcName != "Run" {
- return true
- }
-
- var obj *ast.Ident
- switch o := selector.X.(type) {
- case *ast.Ident:
- obj = o
- case *ast.SelectorExpr:
- obj = o.Sel
- default:
- return true
- }
-
- // Skip function calls that aren't struct methods.
- if obj == nil {
- return true
- }
-
- typ := pass.TypesInfo.ObjectOf(obj).Type()
- if typ.String() == "*os/exec.Cmd" {
- pass.Reportf(n.Pos(), "do not call %s.%s() directly, use execsupport.%s(%s) instead",
- obj.Name, funcName, funcName, obj.Name)
- }
- return false
- })
- }
- return nil, nil
-}
-
-func main() {
- multichecker.Main(
- &analysis.Analyzer{
- Name: "directexec",
- Doc: "do not call os/exec.Cmd Start or Run functions directly",
- Run: run,
- },
- )
-}