1
1
mirror of https://github.com/wader/fq.git synced 2024-12-25 14:23:18 +03:00

Merge pull request #361 from wader/bump-github-golangci-lint-1.48.0

Update github-golangci-lint from 1.47.3 to 1.48.0
This commit is contained in:
Mattias Wadman 2022-08-05 00:30:53 +02:00 committed by GitHub
commit e903dac47f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 46 additions and 37 deletions

View File

@ -7,7 +7,7 @@ on:
pull_request: pull_request:
env: env:
GOLANGCILINT_VERSION: 1.47.3 GOLANGCILINT_VERSION: 1.48.0
jobs: jobs:
lint: lint:

View File

@ -4,13 +4,13 @@ package main
import ( import (
"bytes" "bytes"
"io/ioutil" "io"
"os" "os"
"strconv" "strconv"
) )
func main() { func main() {
bs, err := ioutil.ReadAll(os.Stdin) bs, err := io.ReadAll(os.Stdin)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -3,7 +3,7 @@ package main
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"io/ioutil" "io"
"log" "log"
"os" "os"
"strconv" "strconv"
@ -82,7 +82,7 @@ func main() {
_ = json.NewDecoder(r).Decode(&data) _ = json.NewDecoder(r).Decode(&data)
} }
templateBytes, err := ioutil.ReadAll(os.Stdin) templateBytes, err := io.ReadAll(os.Stdin)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -1,4 +1,5 @@
// Package all registers all builtin formats with the default registry // Package all registers all builtin formats with the default registry
//
//nolint:revive //nolint:revive
package all package all

View File

@ -8,6 +8,7 @@ const (
) )
// TODO: change to CamelCase? // TODO: change to CamelCase?
//
//nolint:revive //nolint:revive
const ( const (
ALL = "all" ALL = "all"

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -46,8 +45,8 @@ func (ft *fuzzTest) Platform() interp.Platform { return interp.Platform{} }
func (ft *fuzzTest) Stdin() interp.Input { func (ft *fuzzTest) Stdin() interp.Input {
return fuzzTestInput{FileReader: interp.FileReader{R: bytes.NewBuffer(ft.b)}} return fuzzTestInput{FileReader: interp.FileReader{R: bytes.NewBuffer(ft.b)}}
} }
func (ft *fuzzTest) Stdout() interp.Output { return fuzzTestOutput{ioutil.Discard} } func (ft *fuzzTest) Stdout() interp.Output { return fuzzTestOutput{io.Discard} }
func (ft *fuzzTest) Stderr() interp.Output { return fuzzTestOutput{ioutil.Discard} } func (ft *fuzzTest) Stderr() interp.Output { return fuzzTestOutput{io.Discard} }
func (ft *fuzzTest) InterruptChan() chan struct{} { return nil } func (ft *fuzzTest) InterruptChan() chan struct{} { return nil }
func (ft *fuzzTest) Environ() []string { return nil } func (ft *fuzzTest) Environ() []string { return nil }
func (ft *fuzzTest) Args() []string { func (ft *fuzzTest) Args() []string {
@ -85,7 +84,7 @@ func FuzzFormats(f *testing.F) {
return err return err
} }
b, readErr := ioutil.ReadFile(path) b, readErr := os.ReadFile(path)
if readErr != nil { if readErr != nil {
f.Fatal(err) f.Fatal(err)
} }

View File

@ -227,10 +227,14 @@ const (
// $00 ISO-8859-1 [ISO-8859-1]. Terminated with $00. // $00 ISO-8859-1 [ISO-8859-1]. Terminated with $00.
// $01 UTF-16 [UTF-16] encoded Unicode [UNICODE] with BOM. All // $01 UTF-16 [UTF-16] encoded Unicode [UNICODE] with BOM. All
// strings in the same frame SHALL have the same byteorder. //
// Terminated with $00 00. // strings in the same frame SHALL have the same byteorder.
// Terminated with $00 00.
//
// $02 UTF-16BE [UTF-16] encoded Unicode [UNICODE] without BOM. // $02 UTF-16BE [UTF-16] encoded Unicode [UNICODE] without BOM.
// Terminated with $00 00. //
// Terminated with $00 00.
//
// $03 UTF-8 [UTF-8] encoded Unicode [UNICODE]. Terminated with $00. // $03 UTF-8 [UTF-8] encoded Unicode [UNICODE]. Terminated with $00.
var encodingNames = scalar.UToSymStr{ var encodingNames = scalar.UToSymStr{
encodingISO8859_1: "iso_8859-1", encodingISO8859_1: "iso_8859-1",

View File

@ -4,6 +4,7 @@ import "github.com/wader/fq/pkg/scalar"
// from https://www.tcpdump.org/linktypes.html // from https://www.tcpdump.org/linktypes.html
// TODO cleanup // TODO cleanup
//
//nolint:revive //nolint:revive
const ( const (
LinkTypeNULL = 0 LinkTypeNULL = 0

View File

@ -1,4 +1,5 @@
// Code below generated from ebml_matroska.xml // Code below generated from ebml_matroska.xml
//
//nolint:revive //nolint:revive
package ebml_matroska package ebml_matroska

View File

@ -5,6 +5,7 @@ import (
) )
// based on ffmpeg libavformat/isom.c ff_mp4_obj_type // based on ffmpeg libavformat/isom.c ff_mp4_obj_type
//
//nolint:revive //nolint:revive
const ( const (
MPEGObjectTypeMOV_TEXT = 0x08 MPEGObjectTypeMOV_TEXT = 0x08
@ -191,6 +192,7 @@ var MPEGAudioObjectTypeNames = scalar.UToScalar{
} }
// based on ffmpeg/libavutil/pixfmt.h // based on ffmpeg/libavutil/pixfmt.h
//
//nolint:revive //nolint:revive
var ISO_23091_2_ColourPrimariesMap = scalar.UToScalar{ var ISO_23091_2_ColourPrimariesMap = scalar.UToScalar{
1: {Sym: "bt709", Description: "ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B"}, 1: {Sym: "bt709", Description: "ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP 177 Annex B"},

View File

@ -73,7 +73,8 @@ func decodeEscapeValueAbsFn(b1 int, b2 int, b3 int) func(d *decode.D) uint64 {
} }
// add values and escaped values // add values and escaped values
//nolint: deadcode,unused //
//nolint:deadcode,unused
func decodeEscapeValueAddFn(b1 int, b2 int, b3 int) func(d *decode.D) uint64 { func decodeEscapeValueAddFn(b1 int, b2 int, b3 int) func(d *decode.D) uint64 {
return decodeEscapeValueFn(0, b1, b2, b3) return decodeEscapeValueFn(0, b1, b2, b3)
} }

View File

@ -195,7 +195,8 @@ var videoMessageH264PacketTypeNames = scalar.UToSymStr{
} }
// TODO: invalid warning that timestampDelta is unused // TODO: invalid warning that timestampDelta is unused
//nolint: unused
//nolint:unused
type messageHeader struct { type messageHeader struct {
timestamp uint64 timestamp uint64
timestampDelta uint64 timestampDelta uint64

View File

@ -24,6 +24,7 @@
// //
// skip errcheck to keep code similar to gojq version // skip errcheck to keep code similar to gojq version
//
//nolint:errcheck //nolint:errcheck
package colorjson package colorjson

View File

@ -11,7 +11,6 @@
package difftest package difftest
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -139,7 +138,7 @@ func TestWithOptions(t *testing.T, opts Options) {
for _, p := range paths { for _, p := range paths {
t.Run(p, func(t *testing.T) { t.Run(p, func(t *testing.T) {
t.Helper() t.Helper()
input, err := ioutil.ReadFile(p) input, err := os.ReadFile(p)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -149,13 +148,13 @@ func TestWithOptions(t *testing.T, opts Options) {
t.Fatal(err) t.Fatal(err)
} }
expectedOutput, expectedOutputErr := ioutil.ReadFile(outputPath) expectedOutput, expectedOutputErr := os.ReadFile(outputPath)
if opts.WriteOutput { if opts.WriteOutput {
if expectedOutputErr == nil && string(expectedOutput) == output { if expectedOutputErr == nil && string(expectedOutput) == output {
return return
} }
if err := ioutil.WriteFile(outputPath, []byte(output), 0644); err != nil { //nolint:gosec if err := os.WriteFile(outputPath, []byte(output), 0644); err != nil { //nolint:gosec
t.Fatal(err) t.Fatal(err)
} }
return return

View File

@ -16,7 +16,8 @@ import (
) )
// Cast gojq value to go value // Cast gojq value to go value
//nolint: forcetypeassert, unconvert //
//nolint:forcetypeassert,unconvert
func CastFn[T any](v any, structFn func(input any, result any) error) (T, bool) { func CastFn[T any](v any, structFn func(input any, result any) error) (T, bool) {
var t T var t T
switch any(t).(type) { switch any(t).(type) {

View File

@ -4,13 +4,14 @@
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
// You may obtain a copy of the License at // You may obtain a copy of the License at
// //
// http://www.apache.org/licenses/LICENSE-2.0 // http://www.apache.org/licenses/LICENSE-2.0
// //
// Unless required by applicable law or agreed to in writing, software // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, // distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
//
//nolint:revive //nolint:revive
package mathextra package mathextra
@ -19,11 +20,11 @@ import "unsafe"
// Float16 represents a 16-bit floating point number, containing a single sign bit, 5 exponent bits // Float16 represents a 16-bit floating point number, containing a single sign bit, 5 exponent bits
// and 10 fractional bits. This corresponds to IEEE 754-2008 binary16 (or half precision float) type. // and 10 fractional bits. This corresponds to IEEE 754-2008 binary16 (or half precision float) type.
// //
// MSB LSB // MSB LSB
// ╔════╦════╤════╤════╤════╤════╦════╤════╤════╤════╤════╤════╤════╤════╤════╤════╗ // ╔════╦════╤════╤════╤════╤════╦════╤════╤════╤════╤════╤════╤════╤════╤════╤════╗
// ║Sign║ E₄ │ E₃ │ E₂ │ E₁ │ E₀ ║ F₉ │ F₈ │ F₇ │ F₆ │ F₅ │ F₄ │ F₃ │ F₂ │ F₁ │ F₀ ║ // ║Sign║ E₄ │ E₃ │ E₂ │ E₁ │ E₀ ║ F₉ │ F₈ │ F₇ │ F₆ │ F₅ │ F₄ │ F₃ │ F₂ │ F₁ │ F₀ ║
// ╚════╩════╧════╧════╧════╧════╩════╧════╧════╧════╧════╧════╧════╧════╧════╧════╝ // ╚════╩════╧════╧════╧════╧════╩════╧════╧════╧════╧════╧════╧════╧════╧════╧════╝
// Where E is the exponent bits and F is the fractional bits. // Where E is the exponent bits and F is the fractional bits.
type Float16 uint16 type Float16 uint16
const ( const (

View File

@ -5,7 +5,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/big" "math/big"
"regexp" "regexp"
@ -1129,7 +1128,7 @@ func (d *D) FieldFormatReaderLen(name string, nBits int64, fn func(r io.Reader)
if err != nil { if err != nil {
d.IOPanic(err, "FieldFormatReaderLen: fn") d.IOPanic(err, "FieldFormatReaderLen: fn")
} }
rBuf, err := ioutil.ReadAll(r) rBuf, err := io.ReadAll(r)
if err != nil { if err != nil {
d.IOPanic(err, "FieldFormatReaderLen: ReadAll") d.IOPanic(err, "FieldFormatReaderLen: ReadAll")
} }
@ -1149,7 +1148,7 @@ func (d *D) TryFieldReaderRangeFormat(name string, startBit int64, nBits int64,
return 0, nil, nil, nil, err return 0, nil, nil, nil, err
} }
r := bitio.NewIOReadSeeker(br) r := bitio.NewIOReadSeeker(br)
rb, err := ioutil.ReadAll(fn(r)) rb, err := io.ReadAll(fn(r))
if err != nil { if err != nil {
return 0, nil, nil, nil, err return 0, nil, nil, nil, err
} }

View File

@ -145,7 +145,8 @@ func (d *D) tryText(nBytes int, e encoding.Encoding) (string, error) {
// read length prefixed text (ex pascal short string) // read length prefixed text (ex pascal short string)
// lBits length prefix // lBits length prefix
// fixedBytes if != -1 read nBytes but trim to length // fixedBytes if != -1 read nBytes but trim to length
//nolint: unparam //
//nolint:unparam
func (d *D) tryTextLenPrefixed(lenBits int, fixedBytes int, e encoding.Encoding) (string, error) { func (d *D) tryTextLenPrefixed(lenBits int, fixedBytes int, e encoding.Encoding) (string, error) {
if lenBits < 0 { if lenBits < 0 {
return "", fmt.Errorf("tryTextLenPrefixed lenBits must be >= 0 (%d)", lenBits) return "", fmt.Errorf("tryTextLenPrefixed lenBits must be >= 0 (%d)", lenBits)

View File

@ -2,7 +2,6 @@ package fqtest
import ( import (
"context" "context"
"io/ioutil"
"os" "os"
"strconv" "strconv"
"testing" "testing"
@ -19,7 +18,7 @@ func TestPath(t *testing.T, registry *interp.Registry) {
ColorDiff: os.Getenv("DIFF_COLOR") != "", ColorDiff: os.Getenv("DIFF_COLOR") != "",
WriteOutput: os.Getenv("WRITE_ACTUAL") != "", WriteOutput: os.Getenv("WRITE_ACTUAL") != "",
Fn: func(t *testing.T, path, input string) (string, string, error) { Fn: func(t *testing.T, path, input string) (string, string, error) {
b, err := ioutil.ReadFile(path) b, err := os.ReadFile(path)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"io/ioutil"
"math/big" "math/big"
"github.com/wader/fq/internal/aheadreadseeker" "github.com/wader/fq/internal/aheadreadseeker"
@ -217,7 +216,7 @@ func (i *Interp) _open(c any) any {
} }
if fRS == nil { if fRS == nil {
buf, err := ioutil.ReadAll(ctxreadseeker.New(i.EvalInstance.Ctx, &ioextra.ReadErrSeeker{Reader: f})) buf, err := io.ReadAll(ctxreadseeker.New(i.EvalInstance.Ctx, &ioextra.ReadErrSeeker{Reader: f}))
if err != nil { if err != nil {
f.Close() f.Close()
return err return err

View File

@ -5,7 +5,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/big" "math/big"
"reflect" "reflect"
"strings" "strings"
@ -143,7 +142,7 @@ func (i *Interp) _registry(c any) any {
if err != nil { if err != nil {
return err return err
} }
b, err := ioutil.ReadAll(f) b, err := io.ReadAll(f)
if err != nil { if err != nil {
return err return err
} }

View File

@ -11,7 +11,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"io/ioutil"
"math/big" "math/big"
"path" "path"
"strconv" "strconv"
@ -917,7 +916,7 @@ func (i *Interp) Eval(ctx context.Context, c any, expr string, opts EvalOpts) (g
output := opts.output output := opts.output
if opts.output == nil { if opts.output == nil {
output = ioutil.Discard output = io.Discard
} }
runCtx, runCtxCancelFn := i.interruptStack.Push(ctx) runCtx, runCtxCancelFn := i.interruptStack.Push(ctx)