From 41649bf4f9d7a9b45604a940941fb9df413d1b2b Mon Sep 17 00:00:00 2001 From: John Kerl Date: Sun, 27 Oct 2024 12:11:28 -0400 Subject: [PATCH] Static-check fixes from @lespea #1657, batch 7/n (#1709) --- cmd/experiments/colors/main.go | 15 +++++++++------ pkg/bifs/base.go | 2 ++ pkg/dsl/cst/dump.go | 2 +- pkg/dsl/cst/statements.go | 1 - pkg/entrypoint/entrypoint.go | 4 +--- pkg/input/record_reader_json.go | 4 +--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cmd/experiments/colors/main.go b/cmd/experiments/colors/main.go index 3539d3c1e..2e41124d9 100644 --- a/cmd/experiments/colors/main.go +++ b/cmd/experiments/colors/main.go @@ -6,12 +6,15 @@ import ( "github.com/johnkerl/miller/v6/pkg/colorizer" ) -const boldString = "\u001b[1m" -const underlineString = "\u001b[4m" -const reversedString = "\u001b[7m" -const redString = "\u001b[1;31m" -const blueString = "\u001b[1;34m" -const defaultString = "\u001b[0m" +const ( + boldString = "\u001b[1m" + reversedString = "\u001b[7m" + redString = "\u001b[1;31m" + blueString = "\u001b[1;34m" + defaultString = "\u001b[0m" + + // underlineString = "\u001b[4m" +) func main() { fmt.Printf("Hello, world!\n") diff --git a/pkg/bifs/base.go b/pkg/bifs/base.go index 0f299048f..c259cc7fe 100644 --- a/pkg/bifs/base.go +++ b/pkg/bifs/base.go @@ -104,6 +104,8 @@ func _zero1(input1 *mlrval.Mlrval) *mlrval.Mlrval { } // Return one (unary) +// +//lint:ignore U1000 util function might be used later func __one1(input1 *mlrval.Mlrval) *mlrval.Mlrval { return mlrval.FromInt(1) } diff --git a/pkg/dsl/cst/dump.go b/pkg/dsl/cst/dump.go index c5e0d975e..1114043ff 100644 --- a/pkg/dsl/cst/dump.go +++ b/pkg/dsl/cst/dump.go @@ -199,7 +199,7 @@ func (node *DumpStatementNode) dumpToStderr( outputString string, state *runtime.State, ) error { - fmt.Fprintf(os.Stderr, outputString) + fmt.Fprint(os.Stderr, outputString) return nil } diff --git a/pkg/dsl/cst/statements.go b/pkg/dsl/cst/statements.go index eec090606..8e8edba72 100644 --- a/pkg/dsl/cst/statements.go +++ b/pkg/dsl/cst/statements.go @@ -104,7 +104,6 @@ func (root *RootNode) BuildStatementNode( default: return nil, fmt.Errorf("at CST BuildStatementNode: unhandled AST node %s", string(astNode.Type)) - break } return statement, nil } diff --git a/pkg/entrypoint/entrypoint.go b/pkg/entrypoint/entrypoint.go index 7426c726d..c8293c041 100644 --- a/pkg/entrypoint/entrypoint.go +++ b/pkg/entrypoint/entrypoint.go @@ -104,9 +104,7 @@ func processInPlace( // Save off the file names from the command line. fileNames := make([]string, len(originalOptions.FileNames)) - for i, fileName := range originalOptions.FileNames { - fileNames[i] = fileName - } + copy(fileNames, originalOptions.FileNames) for _, fileName := range fileNames { diff --git a/pkg/input/record_reader_json.go b/pkg/input/record_reader_json.go index 52844025e..63d9f7368 100644 --- a/pkg/input/record_reader_json.go +++ b/pkg/input/record_reader_json.go @@ -281,9 +281,7 @@ func (bsr *JSONCommentEnabledReader) Read(p []byte) (n int, err error) { func (bsr *JSONCommentEnabledReader) populateFromLine(p []byte) int { numBytesWritten := 0 if len(bsr.lineBytes) < len(p) { - for i := 0; i < len(bsr.lineBytes); i++ { - p[i] = bsr.lineBytes[i] - } + copy(p, bsr.lineBytes) numBytesWritten = len(bsr.lineBytes) bsr.lineBytes = nil } else {