From a3dcf769481e0f33df8a94e262dc9842b182d8a6 Mon Sep 17 00:00:00 2001 From: refaktor Date: Wed, 6 Dec 2023 00:25:10 +0100 Subject: [PATCH] partial fixes based on golangci-lint --- .golangci.yml | 2 +- evaldo/builtins_io.go | 2 +- evaldo/builtins_structures.go | 3 --- evaldo/evaldo.go | 10 ++++------ evaldo/repl.go | 11 +++++------ main.go | 12 +++++------- 6 files changed, 16 insertions(+), 24 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 135ac91d..ac989609 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -75,7 +75,7 @@ linters-settings: - name: unused-parameter gosec: exclude-rules: - - id: G504 + - G504 linters: diff --git a/evaldo/builtins_io.go b/evaldo/builtins_io.go index 844f6f1c..db1daf7f 100755 --- a/evaldo/builtins_io.go +++ b/evaldo/builtins_io.go @@ -285,7 +285,7 @@ func __https_s_get(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 // Print the HTTP Status Code and Status Name //mt.Println("HTTP Response Status:", resp.StatusCode, http.StatusText(resp.StatusCode)) defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, _ := ioutil.ReadAll(resp.Body) if resp.StatusCode >= 200 && resp.StatusCode <= 299 { return *env.NewString(string(body)) diff --git a/evaldo/builtins_structures.go b/evaldo/builtins_structures.go index bdc343a3..1c841559 100644 --- a/evaldo/builtins_structures.go +++ b/evaldo/builtins_structures.go @@ -122,9 +122,6 @@ func do_structures(ps *env.ProgramState, data env.Dict, rmap env.Dict) env.Objec EvalBlockInj(ps, JsonToRye(val), true) ps.Ser = ser } - - } else { - // fmt.Println("not found") } } return nil diff --git a/evaldo/evaldo.go b/evaldo/evaldo.go index 46c2c668..3e44ce0a 100755 --- a/evaldo/evaldo.go +++ b/evaldo/evaldo.go @@ -758,12 +758,10 @@ func CallBuiltin(bi env.Builtin, ps *env.ProgramState, arg0_ env.Object, toLeft if arg0_ != nil && !pipeSecond { //fmt.Println("ARG0 = LEFT") arg0 = arg0_ - if !toLeft { - //fmt.Println("L TO R *** ") - //evalExprFn = EvalExpression_ - } else { - //fmt.Println("TO THE *** LEFT") - } + //if !toLeft { + //fmt.Println("L TO R *** ") + //evalExprFn = EvalExpression_ + // } } else if firstVal != nil && pipeSecond { arg0 = firstVal } else if bi.Argsn > 0 && bi.Cur0 == nil { diff --git a/evaldo/repl.go b/evaldo/repl.go index 979e795e..b842139e 100644 --- a/evaldo/repl.go +++ b/evaldo/repl.go @@ -33,7 +33,8 @@ func genPrompt(shellEd *ShellEd, line string) (string, string) { if shellEd.Mode != "" { a := shellEd.Askfor if len(a) > 0 { - x, a := a[0], a[1:] + x := a[0] + a = a[1:] shellEd.Askfor = a return "{ Rye - value of " + x + " } ", x } else if shellEd.Return == nil { @@ -87,9 +88,9 @@ func maybeDoShedCommands(line string, es *env.ProgramState, shellEd *ShellEd) { } func maybeDoShedCommandsBlk(line string, es *env.ProgramState, block *env.Block, shed_pause *bool) { - if block != nil { - //block.Trace("TOP") - } + //if block != nil { + //block.Trace("TOP") + //} line1 := strings.Split(line, " ") switch line1[0] { case "#in": @@ -265,8 +266,6 @@ func DoRyeRepl(es *env.ProgramState, showResults bool) { } if es.Res != nil && shellEd.Mode != "" && !shellEd.Pause && es.Res == shellEd.Return { fmt.Println(" <- the correct value was returned") - } else { - // fmt.Println("") } } diff --git a/main.go b/main.go index f265fc89..a2b9fa9a 100755 --- a/main.go +++ b/main.go @@ -108,8 +108,6 @@ func main_ryk() { log.Fatal(err) } input = string(content) - } else { - // fmt.Print("no preload") } block, genv := loader.LoadString(input, false) @@ -140,7 +138,7 @@ func main_ryk() { if len(os.Args) >= 5 { if os.Args[argIdx] == "--begin" { block, genv := loader.LoadString(os.Args[argIdx+1], false) - es := env.AddToProgramState(es, block.(env.Block).Series, genv) + es = env.AddToProgramState(es, block.(env.Block).Series, genv) evaldo.EvalBlockInj(es, es.ForcedResult, true) es.Ser.Reset() argIdx += 2 @@ -216,7 +214,7 @@ func main_ryk() { if len(os.Args) >= argIdx+2 { if os.Args[argIdx] == "--end" { block, genv := loader.LoadString(os.Args[argIdx+1], false) - es := env.AddToProgramState(es, block.(env.Block).Series, genv) + es = env.AddToProgramState(es, block.(env.Block).Series, genv) evaldo.EvalBlockInj(es, es.ForcedResult, true) es.Ser.Reset() } @@ -298,7 +296,7 @@ func main_cgi_file(file string, sig bool) { block, genv = loader.LoadString(content, sig) switch val := block.(type) { case env.Block: - es := env.AddToProgramState(es, block.(env.Block).Series, genv) + es = env.AddToProgramState(es, block.(env.Block).Series, genv) evaldo.RegisterBuiltins(es) contrib.RegisterBuiltins(es, &evaldo.BuiltinNames) @@ -314,7 +312,7 @@ func main_cgi_file(file string, sig bool) { } -func main_rye_repl(in io.Reader, out io.Writer, subc bool) { +func main_rye_repl(_ io.Reader, _ io.Writer, subc bool) { input := " 123 " // "name: \"Rye\" version: \"0.011 alpha\"" user, _ := user.Current() @@ -368,7 +366,7 @@ func main_rysh() { //line = line[:len(line)-1] fmt.Println() shellEditor = false - cursorPos = len(line) + // cursorPos = len(line) fmt.Print("YOLO") break }