Skip to content

Commit

Permalink
fix(lint): fixed some lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Sep 6, 2024
1 parent d477d92 commit aa59f17
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ func ExecuteSourceTape(c parser.Command, v *VHS) error {
cmd.Type == token.OUTPUT {
continue
}
fmt.Fprintf(out, "%s %s\n", GrayStyle.Render(displayPath+":"), Highlight(cmd, false))
_, _ = fmt.Fprintf(out, "%s %s\n", GrayStyle.Render(displayPath+":"), Highlight(cmd, false))
err := CommandFuncs[cmd.Type](cmd, v)
if err != nil {
return fmt.Errorf("failed to execute command %s: %w", cmd.Type.String(), err)
Expand Down
14 changes: 7 additions & 7 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ func LineNumber(line int) string {
func printError(out io.Writer, tape string, err parser.Error) {
lines := strings.Split(tape, "\n")

fmt.Fprint(out, LineNumber(err.Token.Line))
fmt.Fprintln(out, lines[err.Token.Line-1])
fmt.Fprint(out, strings.Repeat(" ", err.Token.Column+ErrorColumnOffset))
fmt.Fprintln(out, Underline(len(err.Token.Literal)), err.Msg)
fmt.Fprintln(out)
_, _ = fmt.Fprint(out, LineNumber(err.Token.Line))
_, _ = fmt.Fprintln(out, lines[err.Token.Line-1])
_, _ = fmt.Fprint(out, strings.Repeat(" ", err.Token.Column+ErrorColumnOffset))
_, _ = fmt.Fprintln(out, Underline(len(err.Token.Literal)), err.Msg)
_, _ = fmt.Fprintln(out)
}

func printErrors(out io.Writer, tape string, errs []error) {
Expand All @@ -49,10 +49,10 @@ func printErrors(out io.Writer, tape string, errs []error) {
for _, v := range err.Errors {
printError(out, tape, v)
}
fmt.Fprintln(out, ErrorStyle.Render(err.Error()))
_, _ = fmt.Fprintln(out, ErrorStyle.Render(err.Error()))

default:
fmt.Fprintln(out, ErrorStyle.Render(err.Error()))
_, _ = fmt.Fprintln(out, ErrorStyle.Render(err.Error()))
}
}
}
8 changes: 4 additions & 4 deletions evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator
var offset int
for i, cmd := range cmds {
if cmd.Type == token.SET || cmd.Type == token.OUTPUT || cmd.Type == token.REQUIRE {
fmt.Fprintln(out, Highlight(cmd, false))
_, _ = fmt.Fprintln(out, Highlight(cmd, false))
if cmd.Options != "Shell" {
err := Execute(cmd, &v)
if err != nil {
Expand Down Expand Up @@ -101,7 +101,7 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator
offset += i
break
}
fmt.Fprintln(out, Highlight(cmd, true))
_, _ = fmt.Fprintln(out, Highlight(cmd, true))
err := Execute(cmd, &v)
if err != nil {
return []error{err}
Expand Down Expand Up @@ -153,10 +153,10 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator
// We should remove if isSetting statement.
isSetting := cmd.Type == token.SET && cmd.Options != "TypingSpeed"
if isSetting || cmd.Type == token.REQUIRE {
fmt.Fprintln(out, Highlight(cmd, true))
_, _ = fmt.Fprintln(out, Highlight(cmd, true))
continue
}
fmt.Fprintln(out, Highlight(cmd, !v.recording || cmd.Type == token.SHOW || cmd.Type == token.HIDE || isSetting))
_, _ = fmt.Fprintln(out, Highlight(cmd, !v.recording || cmd.Type == token.SHOW || cmd.Type == token.HIDE || isSetting))
err := Execute(cmd, &v)
if err != nil {
teardown()
Expand Down
2 changes: 1 addition & 1 deletion publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func hostKeyCallback(path string) ssh.HostKeyCallback {
return fmt.Errorf("possible man-in-the-middle attack: %w", err)
}
// if want is empty, it means the host was not in the known_hosts file, so lets add it there.
fmt.Fprintln(kh, knownhosts.Line([]string{hostname}, key))
_, _ = fmt.Fprintln(kh, knownhosts.Line([]string{hostname}, key))
return nil
}
return fmt.Errorf("failed to check known_hosts: %w", err)
Expand Down
4 changes: 2 additions & 2 deletions record.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Record(_ *cobra.Command, _ []string) error {
log.Printf("error resizing pty: %s", err)
}

prevState, err := term.MakeRaw(int(os.Stdin.Fd()))
prevState, err := term.MakeRaw(int(os.Stdin.Fd())) //nolint: gosec
if err != nil {
return err
}
Expand Down Expand Up @@ -114,7 +114,7 @@ func Record(_ *cobra.Command, _ []string) error {

// PTY cleanup and restore terminal
_ = terminal.Close()
_ = term.Restore(int(os.Stdin.Fd()), prevState)
_ = term.Restore(int(os.Stdin.Fd()), prevState) //nolint: gosec

fmt.Println(inputToTape(tape.String()))
return nil
Expand Down
4 changes: 2 additions & 2 deletions vhs.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,15 +349,15 @@ func (vhs *VHS) Record(ctx context.Context) <-chan error {
if err := os.WriteFile(
filepath.Join(vhs.Options.Video.Input, fmt.Sprintf(cursorFrameFormat, counter)),
cursor,
os.ModePerm,
0o600,

Check failure on line 352 in vhs.go

View workflow job for this annotation

GitHub Actions / lint-soft

Magic number: 0o600, in <argument> detected (gomnd)

Check failure on line 352 in vhs.go

View workflow job for this annotation

GitHub Actions / lint-soft

Magic number: 0o600, in <argument> detected (gomnd)
); err != nil {
ch <- fmt.Errorf("error writing cursor frame: %w", err)
continue
}
if err := os.WriteFile(
filepath.Join(vhs.Options.Video.Input, fmt.Sprintf(textFrameFormat, counter)),
text,
os.ModePerm,
0o600,

Check failure on line 360 in vhs.go

View workflow job for this annotation

GitHub Actions / lint-soft

Magic number: 0o600, in <argument> detected (gomnd)

Check failure on line 360 in vhs.go

View workflow job for this annotation

GitHub Actions / lint-soft

Magic number: 0o600, in <argument> detected (gomnd)
); err != nil {
ch <- fmt.Errorf("error writing text frame: %w", err)
continue
Expand Down

0 comments on commit aa59f17

Please sign in to comment.