Use staticcheck GitHub Action (#563)
Этот коммит содержится в:
родитель
7f75c5d4ee
коммит
ea50e4bdfc
8 изменённых файлов: 30 добавлений и 61 удалений
14
.github/workflows/test.yml
предоставленный
14
.github/workflows/test.yml
предоставленный
|
@ -29,13 +29,13 @@ jobs:
|
|||
- name: Run gofmt
|
||||
run: gofmt -d -e . 2>&1 | tee outfile && test -z "$(cat outfile)" && rm outfile
|
||||
- name: Run staticcheck
|
||||
if: matrix.go-version == '1.17.x'
|
||||
run: |
|
||||
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog
|
||||
bin/staticcheck_linux_amd64_2021.1.2 github.com/cucumber/godog/cmd/godog
|
||||
# Disable for now because of failing checks
|
||||
# TODO: Add back in when fixes are made
|
||||
# bin/staticcheck_linux_amd64_2021.1.2 ./...
|
||||
if: matrix.go-version == '1.20.x'
|
||||
uses: dominikh/staticcheck-action@v1.3.0
|
||||
with:
|
||||
version: "2023.1.3"
|
||||
install-go: false
|
||||
cache-key: ${{ matrix.go }}
|
||||
|
||||
- name: Run go vet
|
||||
run: |
|
||||
go vet ./...
|
||||
|
|
Двоичные данные
bin/staticcheck_linux_amd64_2021.1.2
Двоичные данные
bin/staticcheck_linux_amd64_2021.1.2
Двоичный файл не отображается.
|
@ -164,13 +164,13 @@ func (f *Base) Summary() {
|
|||
if totalSc == 0 {
|
||||
fmt.Fprintln(f.out, "No scenarios")
|
||||
} else {
|
||||
fmt.Fprintln(f.out, fmt.Sprintf("%d scenarios (%s)", totalSc, strings.Join(scenarios, ", ")))
|
||||
fmt.Fprintf(f.out, "%d scenarios (%s)\n", totalSc, strings.Join(scenarios, ", "))
|
||||
}
|
||||
|
||||
if totalSt == 0 {
|
||||
fmt.Fprintln(f.out, "No steps")
|
||||
} else {
|
||||
fmt.Fprintln(f.out, fmt.Sprintf("%d steps (%s)", totalSt, strings.Join(steps, ", ")))
|
||||
fmt.Fprintf(f.out, "%d steps (%s)\n", totalSt, strings.Join(steps, ", "))
|
||||
}
|
||||
|
||||
elapsedString := elapsed.String()
|
||||
|
|
|
@ -51,34 +51,6 @@ const (
|
|||
ansiForegroundCyan = "36"
|
||||
ansiForegroundWhite = "37"
|
||||
ansiForegroundDefault = "39"
|
||||
|
||||
ansiBackgroundBlack = "40"
|
||||
ansiBackgroundRed = "41"
|
||||
ansiBackgroundGreen = "42"
|
||||
ansiBackgroundYellow = "43"
|
||||
ansiBackgroundBlue = "44"
|
||||
ansiBackgroundMagenta = "45"
|
||||
ansiBackgroundCyan = "46"
|
||||
ansiBackgroundWhite = "47"
|
||||
ansiBackgroundDefault = "49"
|
||||
|
||||
ansiLightForegroundGray = "90"
|
||||
ansiLightForegroundRed = "91"
|
||||
ansiLightForegroundGreen = "92"
|
||||
ansiLightForegroundYellow = "93"
|
||||
ansiLightForegroundBlue = "94"
|
||||
ansiLightForegroundMagenta = "95"
|
||||
ansiLightForegroundCyan = "96"
|
||||
ansiLightForegroundWhite = "97"
|
||||
|
||||
ansiLightBackgroundGray = "100"
|
||||
ansiLightBackgroundRed = "101"
|
||||
ansiLightBackgroundGreen = "102"
|
||||
ansiLightBackgroundYellow = "103"
|
||||
ansiLightBackgroundBlue = "104"
|
||||
ansiLightBackgroundMagenta = "105"
|
||||
ansiLightBackgroundCyan = "106"
|
||||
ansiLightBackgroundWhite = "107"
|
||||
)
|
||||
|
||||
var colorMap = map[string]string{
|
||||
|
@ -93,10 +65,6 @@ var colorMap = map[string]string{
|
|||
ansiForegroundDefault: "",
|
||||
}
|
||||
|
||||
func (cw *tagColorWriter) flushBuffer() (int, error) {
|
||||
return cw.flushTo(cw.w)
|
||||
}
|
||||
|
||||
func (cw *tagColorWriter) resetBuffer() (int, error) {
|
||||
return cw.flushTo(nil)
|
||||
}
|
||||
|
@ -147,7 +115,6 @@ func (cw *tagColorWriter) Write(p []byte) (int, error) {
|
|||
switch ch {
|
||||
case firstCsiChar:
|
||||
cw.paramStartBuf.WriteByte(ch)
|
||||
break
|
||||
case secondeCsiChar:
|
||||
cw.paramStartBuf.WriteByte(ch)
|
||||
cw.state = secondCsiCode
|
||||
|
|
|
@ -15,9 +15,8 @@ type MultiFormatter struct {
|
|||
}
|
||||
|
||||
type formatter struct {
|
||||
fmt formatters.FormatterFunc
|
||||
out io.Writer
|
||||
close bool
|
||||
fmt formatters.FormatterFunc
|
||||
out io.Writer
|
||||
}
|
||||
|
||||
type repeater []formatters.Formatter
|
||||
|
|
|
@ -11,10 +11,10 @@ import (
|
|||
)
|
||||
|
||||
// some snippet formatting regexps
|
||||
var snippetExprCleanup = regexp.MustCompile("([\\/\\[\\]\\(\\)\\\\^\\$\\.\\|\\?\\*\\+\\'])")
|
||||
var snippetExprQuoted = regexp.MustCompile("(\\W|^)\"(?:[^\"]*)\"(\\W|$)")
|
||||
var snippetMethodName = regexp.MustCompile("[^a-zA-Z\\_\\ ]")
|
||||
var snippetNumbers = regexp.MustCompile("(\\d+)")
|
||||
var snippetExprCleanup = regexp.MustCompile(`([\/\[\]\(\)\\^\$\.\|\?\*\+\'])`)
|
||||
var snippetExprQuoted = regexp.MustCompile(`(\W|^)"(?:[^"]*)"(\W|$)`)
|
||||
var snippetMethodName = regexp.MustCompile(`[^a-zA-Z\_\ ]`)
|
||||
var snippetNumbers = regexp.MustCompile(`(\d+)`)
|
||||
|
||||
var snippetHelperFuncs = template.FuncMap{
|
||||
"backticked": func(s string) string {
|
||||
|
|
|
@ -16,13 +16,15 @@ import (
|
|||
messages "github.com/cucumber/messages/go/v21"
|
||||
)
|
||||
|
||||
type ctxKey string
|
||||
|
||||
func TestShouldSupportContext(t *testing.T) {
|
||||
ctx := context.WithValue(context.Background(), "original", 123)
|
||||
ctx := context.WithValue(context.Background(), ctxKey("original"), 123)
|
||||
|
||||
fn := func(ctx context.Context, a int64, b int32, c int16, d int8) context.Context {
|
||||
assert.Equal(t, 123, ctx.Value("original"))
|
||||
assert.Equal(t, 123, ctx.Value(ctxKey("original")))
|
||||
|
||||
return context.WithValue(ctx, "updated", 321)
|
||||
return context.WithValue(ctx, ctxKey("updated"), 321)
|
||||
}
|
||||
|
||||
def := &models.StepDefinition{
|
||||
|
@ -35,17 +37,18 @@ func TestShouldSupportContext(t *testing.T) {
|
|||
def.Args = []interface{}{"1", "1", "1", "1"}
|
||||
ctx, err := def.Run(ctx)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 123, ctx.Value("original"))
|
||||
assert.Equal(t, 321, ctx.Value("updated"))
|
||||
assert.Equal(t, 123, ctx.Value(ctxKey("original")))
|
||||
assert.Equal(t, 321, ctx.Value(ctxKey("updated")))
|
||||
}
|
||||
|
||||
func TestShouldSupportContextAndError(t *testing.T) {
|
||||
ctx := context.WithValue(context.Background(), "original", 123)
|
||||
|
||||
ctx := context.WithValue(context.Background(), ctxKey("original"), 123)
|
||||
|
||||
fn := func(ctx context.Context, a int64, b int32, c int16, d int8) (context.Context, error) {
|
||||
assert.Equal(t, 123, ctx.Value("original"))
|
||||
assert.Equal(t, 123, ctx.Value(ctxKey("original")))
|
||||
|
||||
return context.WithValue(ctx, "updated", 321), nil
|
||||
return context.WithValue(ctx, ctxKey("updated"), 321), nil
|
||||
}
|
||||
|
||||
def := &models.StepDefinition{
|
||||
|
@ -58,8 +61,8 @@ func TestShouldSupportContextAndError(t *testing.T) {
|
|||
def.Args = []interface{}{"1", "1", "1", "1"}
|
||||
ctx, err := def.Run(ctx)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 123, ctx.Value("original"))
|
||||
assert.Equal(t, 321, ctx.Value("updated"))
|
||||
assert.Equal(t, 123, ctx.Value(ctxKey("original")))
|
||||
assert.Equal(t, 321, ctx.Value(ctxKey("updated")))
|
||||
}
|
||||
|
||||
func TestShouldSupportEmptyHandlerReturn(t *testing.T) {
|
||||
|
@ -374,7 +377,7 @@ func TestStepDefinition_Run_StringConversionToFunctionType(t *testing.T) {
|
|||
// }
|
||||
|
||||
type testStruct struct {
|
||||
a string
|
||||
_ string
|
||||
}
|
||||
|
||||
func TestShouldSupportDocStringToStringConversion(t *testing.T) {
|
||||
|
|
|
@ -303,7 +303,7 @@ func (s *Storage) mustFirst(table, index string, args ...interface{}) interface{
|
|||
if err != nil {
|
||||
panic(err)
|
||||
} else if v == nil {
|
||||
err = fmt.Errorf("Couldn't find index: %q in table: %q with args: %+v", index, table, args)
|
||||
err = fmt.Errorf("couldn't find index: %q in table: %q with args: %+v", index, table, args)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче