Skip to content

Commit

Permalink
Merge pull request #2038 from rsteube/add-nilaway
Browse files Browse the repository at this point in the history
added nilaway
  • Loading branch information
rsteube authored Nov 25, 2023
2 parents 33838b3 + 8b3c7d4 commit 2c98283
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
55 changes: 55 additions & 0 deletions completers/nilaway_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/golang"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "nilaway [-flag] [package]",
Short: "Static Analysis tool to detect potential Nil panics in Go code",
Long: "https://github.com/uber-go/nilaway",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()
rootCmd.Flags().SetInterspersed(false)

rootCmd.Flags().BoolS("V", "V", false, "print version and exit")
rootCmd.Flags().StringS("c", "c", "", "display offending line with this many lines of context")
rootCmd.Flags().StringS("cpuprofile", "cpuprofile", "", "write CPU profile to this file")
rootCmd.Flags().StringS("debug", "debug", "", "debug flags, any subset of \"fpstv\"")
rootCmd.Flags().StringS("exclude-errors-in-files", "exclude-errors-in-files", "", "A comma-separated list of file prefixes to exclude from error reporting")
rootCmd.Flags().StringS("exclude-file-docstrings", "exclude-file-docstrings", "", "Comma-separated list of docstrings to exclude from analysis")
rootCmd.Flags().StringS("exclude-pkgs", "exclude-pkgs", "", "Comma-separated list of packages to exclude from analysis")
rootCmd.Flags().BoolS("fix", "fix", false, "apply all suggested fixes")
rootCmd.Flags().BoolS("flags", "flags", false, "print analyzer flags in JSON")
rootCmd.Flags().StringS("include-errors-in-files", "include-errors-in-files", "", "A comma-separated list of file prefixes to report errors")
rootCmd.Flags().StringS("include-pkgs", "include-pkgs", "", "Comma-separated list of packages to analyze")
rootCmd.Flags().BoolS("json", "json", false, "emit JSON output")
rootCmd.Flags().StringS("memprofile", "memprofile", "", "write memory profile to this file")
rootCmd.Flags().StringS("pretty-print", "pretty-print", "", "Pretty print the error messages")
rootCmd.Flags().BoolS("test", "test", false, "indicates whether test files should be analyzed, too")
rootCmd.Flags().StringS("trace", "trace", "", "write trace log to this file")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"cpuprofile": carapace.ActionFiles(),
"debug": carapace.ActionValues(), // TODO
"exclude-errors-in-files": carapace.ActionFiles().UniqueList(","),
"exclude-pkgs": golang.ActionPackages().UniqueList(","),
"include-errors-in-files": carapace.ActionFiles().UniqueList(","),
"include-pkgs": golang.ActionPackages().UniqueList(","),
"memprofile": carapace.ActionFiles(),
"pretty-print": carapace.ActionValues(), // TODO
"trace": carapace.ActionFiles(),
})

carapace.Gen(rootCmd).PositionalCompletion(
golang.ActionPackages(),
)
}
7 changes: 7 additions & 0 deletions completers/nilaway_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/nilaway_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit 2c98283

Please sign in to comment.