staticcheck

This commit is contained in:
rsteube 2020-10-17 19:46:51 +02:00
parent 055b635fe8
commit fafdb1336e
7 changed files with 14 additions and 8 deletions

View File

@ -41,6 +41,9 @@ jobs:
- run:
name: "Check formatting"
command: diff -u <(echo -n) <(gofmt -d -s .)
- run:
name: "staticcheck"
command: go get honnef.co/go/tools/cmd/staticcheck && staticcheck ./...
release:
docker:
- image: circleci/golang:1.15

View File

@ -74,8 +74,8 @@ func ActionRepositoryTags() carapace.Action {
})
}
// TODO not yet working - also needs multiple characters to split on `:` `/`
func ActionContainerPath() carapace.Action {
// TODO not yet working - also needs multiple characters to split on `:` `/`
return carapace.ActionMultiParts(":", func(args []string, parts []string) carapace.Action {
switch len(parts) {
case 0:

View File

@ -184,8 +184,8 @@ func ActionRefs(refOption RefOption) carapace.Action {
})
}
// TODO multiparts action to complete step by step
func ActionUnstagedChanges() carapace.Action {
// TODO multiparts action to complete step by step
return carapace.ActionCallback(func(args []string) carapace.Action {
if output, err := exec.Command("git", "status", "--porcelain").Output(); err != nil {
return carapace.ActionMessage(err.Error())

View File

@ -34,8 +34,8 @@ func init() {
)
}
// TODO bit hacky as empty delimiter not yet implemented (carapce should support multiple delimiters anyway: []rune)
func ActionMode() carapace.Action {
// TODO bit hacky as empty delimiter not yet implemented (carapce should support multiple delimiters anyway: []rune)
return carapace.ActionMultiParts("", func(args, parts []string) carapace.Action {
current := carapace.CallbackValue
vals := []string{}

View File

@ -45,9 +45,9 @@ func (a Artifact) Location(repository string) string {
return fmt.Sprintf("%v/%v/%v/%v/%v-%v.jar", repository, strings.Replace(a.GroupId, ".", "/", -1), a.ArtifactId, a.Version, a.ArtifactId, a.Version)
}
type Project struct {
// TODO parent pom plugins
// TODO plugins locatad in pluginmanagement and profiles
type Project struct {
XMLName xml.Name `xml:"project"`
Plugins []Artifact `xml:"build>plugins>plugin"`
Profiles []string `xml:"profiles>profile>id"`
@ -61,8 +61,8 @@ func repositoryLocation() string {
return "" // TODO handle error
}
// TODO caching
func ActionGoalsAndPhases(file string) carapace.Action {
// TODO caching
return carapace.ActionCallback(func(args []string) carapace.Action {
if project, err := loadProject(file); err != nil {
return carapace.ActionMessage(err.Error())
@ -188,7 +188,7 @@ func loadPlugin(file string) (plugin *Plugin) {
if pluginFile, err := f.Open(); err == nil {
defer pluginFile.Close()
if content, err := ioutil.ReadAll(pluginFile); err == nil {
err = xml.Unmarshal(content, &plugin)
_ = xml.Unmarshal(content, &plugin)
}
}
}

View File

@ -129,8 +129,9 @@ func ActionDevices(includedDevices IncludedDevices) carapace.Action {
return carapace.ActionMessage(err.Error())
} else {
interfaces := []string{}
r := regexp.MustCompile("^[0-9a-zA-Z]")
for _, line := range strings.Split(string(output), "\n") {
if matches, _ := regexp.MatchString("^[0-9a-zA-Z]", line); matches {
if matches := r.MatchString(line); matches {
interfaces = append(interfaces, strings.Split(line, ":")[0])
}
}

2
staticcheck.conf Normal file
View File

@ -0,0 +1,2 @@
# vi: set ft=toml :
checks = ["all", "-ST1000", "-ST1003"]