mirror of
https://github.com/github/codeql.git
synced 2026-04-22 23:35:14 +02:00
Merge pull request #14364 from owen-mc/go/improve-output-of-check-formatting-in-makefile
Go: improve output of check formatting in makefile
This commit is contained in:
@@ -32,7 +32,12 @@ autoformat:
|
||||
find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -w
|
||||
|
||||
check-formatting:
|
||||
test -z "$$(find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -l)"
|
||||
@output=$$(find . -path '**/vendor' -prune -or -type f -iname '*.go' ! -empty -print0 | xargs -0 grep -L "//\s*autoformat-ignore" | xargs gofmt -l 2>&1); \
|
||||
if [ -n "$$output" ]; then \
|
||||
echo "The following files need to be reformatted using gofmt or have compilation errors:"; \
|
||||
echo "$$output"; \
|
||||
fi; \
|
||||
test -z "$$output"
|
||||
|
||||
ifeq ($(QHELP_OUT_DIR),)
|
||||
# If not otherwise specified, compile qhelp to markdown in place
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
func bad(w http.ResponseWriter, req *http.Request, []byte secret) (interface{}, error) {
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func bad(w http.ResponseWriter, req *http.Request, secret []byte) (interface{}, error) {
|
||||
|
||||
secretHeader := "X-Secret"
|
||||
|
||||
@@ -8,4 +15,4 @@ func bad(w http.ResponseWriter, req *http.Request, []byte secret) (interface{},
|
||||
return nil, fmt.Errorf("header %s=%s did not match expected secret", secretHeader, headerSecret)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
func good(w http.ResponseWriter, req *http.Request, []byte secret) (interface{}, error) {
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func good(w http.ResponseWriter, req *http.Request, secret []byte) (interface{}, error) {
|
||||
|
||||
secretHeader := "X-Secret"
|
||||
|
||||
@@ -7,4 +15,4 @@ func good(w http.ResponseWriter, req *http.Request, []byte secret) (interface{},
|
||||
return nil, fmt.Errorf("header %s=%s did not match expected secret", secretHeader, headerSecret)
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func bad() interface{} {
|
||||
name := os.Args[1:]
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func good() (interface{}, error) {
|
||||
name := os.Args[1]
|
||||
hasBadChar, _ := regexp.MatchString(".*[?].*", name)
|
||||
|
||||
Reference in New Issue
Block a user