fix: lint (#637)

This commit is contained in:
Carlos Alexandro Becker
2025-06-17 15:49:26 -03:00
committed by GitHub
parent f5984b23ee
commit 710bb769af
15 changed files with 48 additions and 55 deletions
+1 -1
View File
@@ -667,7 +667,7 @@ func ExecuteSetWindowBar(c parser.Command, v *VHS) error {
return nil
}
// ExecuteSetWindowBar sets window bar size.
// ExecuteSetWindowBarSize sets window bar size.
func ExecuteSetWindowBarSize(c parser.Command, v *VHS) error {
windowBarSize, err := strconv.Atoi(c.Args)
if err != nil {
+2 -2
View File
@@ -174,7 +174,7 @@ func (r *roundedrect) At(x, y int) color.Color {
return color.Alpha{white}
}
// Make a mask to round a terminal's corners.
// MakeBorderRadiusMask a mask to round a terminal's corners.
func MakeBorderRadiusMask(width, height, radius int, targetpng string) {
img := image.NewGray(
image.Rectangle{
@@ -209,7 +209,7 @@ func MakeBorderRadiusMask(width, height, radius int, targetpng string) {
}
}
// Make a window bar and save it to a file.
// MakeWindowBar a window bar and save it to a file.
func MakeWindowBar(termWidth, termHeight int, opts StyleOptions, file string) {
var err error
switch opts.WindowBar {
+1
View File
@@ -76,6 +76,7 @@ func Evaluate(ctx context.Context, tape string, out io.Writer, opts ...Evaluator
minHeight += video.Style.WindowBarSize
}
if video.Style.Height < minHeight || video.Style.Width < minWidth {
//nolint:staticcheck
v.Errors = append(
v.Errors,
fmt.Errorf(
+1
View File
@@ -1,3 +1,4 @@
// Package lipgloss is an example package.
package lipgloss
// Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet. Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit commodo officia dolor Lorem duis laboris cupidatat officia voluptate. Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa duis.
+3 -14
View File
@@ -1,3 +1,6 @@
// Package neofetch is an example package.
//
//nolint:unused
package neofetch
import (
@@ -41,17 +44,3 @@ func clamp(v, low, high int) int {
}
return min(high, max(low, v))
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
+28 -28
View File
@@ -112,15 +112,15 @@ func calcTermDimensions(style StyleOptions) (int, int) {
func (fb *FilterComplexBuilder) WithWindowBar(barStream int) *FilterComplexBuilder {
if fb.style.WindowBar != "" {
fb.filterComplex.WriteString(";")
fb.filterComplex.WriteString(
fmt.Sprintf(`
_, _ = fmt.Fprintf(
fb.filterComplex,
`
[%d]loop=-1[loopbar];
[loopbar][%s]overlay=0:%d[withbar]
`,
barStream,
fb.prevStageName,
fb.style.WindowBarSize,
),
barStream,
fb.prevStageName,
fb.style.WindowBarSize,
)
fb.prevStageName = "withbar"
@@ -133,14 +133,14 @@ func (fb *FilterComplexBuilder) WithWindowBar(barStream int) *FilterComplexBuild
func (fb *FilterComplexBuilder) WithBorderRadius(cornerMarkStream int) *FilterComplexBuilder {
if fb.style.BorderRadius != 0 {
fb.filterComplex.WriteString(";")
fb.filterComplex.WriteString(
fmt.Sprintf(`
[%d]loop=-1[loopmask];
[%s][loopmask]alphamerge[rounded]
`,
cornerMarkStream,
fb.prevStageName,
),
_, _ = fmt.Fprintf(
fb.filterComplex,
`
[%d]loop=-1[loopmask];
[%s][loopmask]alphamerge[rounded]
`,
cornerMarkStream,
fb.prevStageName,
)
fb.prevStageName = "rounded"
}
@@ -155,16 +155,16 @@ func (fb *FilterComplexBuilder) WithMarginFill(marginStream int) *FilterComplexB
// ffmpeg will complain if the final filter ends with a semicolon,
// so we add one BEFORE we start adding filters.
fb.filterComplex.WriteString(";")
fb.filterComplex.WriteString(
fmt.Sprintf(`
_, _ = fmt.Fprintf(
fb.filterComplex,
`
[%d]scale=%d:%d[bg];
[bg][%s]overlay=(W-w)/2:(H-h)/2:shortest=1[withbg]
`,
marginStream,
fb.style.Width,
fb.style.Height,
fb.prevStageName,
),
marginStream,
fb.style.Width,
fb.style.Height,
fb.prevStageName,
)
fb.prevStageName = "withbg"
}
@@ -175,13 +175,13 @@ func (fb *FilterComplexBuilder) WithMarginFill(marginStream int) *FilterComplexB
// WithGIF adds gif options to ffmepg filter_complex.
func (fb *FilterComplexBuilder) WithGIF() *FilterComplexBuilder {
fb.filterComplex.WriteString(";")
fb.filterComplex.WriteString(
fmt.Sprintf(`
[%s]split[plt_a][plt_b];
[plt_a]palettegen=max_colors=256[plt];
[plt_b][plt]paletteuse[palette]`,
fb.prevStageName,
),
_, _ = fmt.Fprintf(
fb.filterComplex,
`
[%s]split[plt_a][plt_b];
[plt_a]palettegen=max_colors=256[plt];
[plt_b][plt]paletteuse[palette]`,
fb.prevStageName,
)
fb.prevStageName = "palette"
+1 -3
View File
@@ -1,8 +1,6 @@
module github.com/charmbracelet/vhs
go 1.23.0
toolchain go1.24.1
go 1.24.1
require (
github.com/agnivade/levenshtein v1.2.1
+1
View File
@@ -1,3 +1,4 @@
// Package lexer provides a lexer for the VHS Tape language.
package lexer
import "github.com/charmbracelet/vhs/token"
+1
View File
@@ -1,3 +1,4 @@
// Package parser provides a parser for the VHS Tape language.
package parser
import (
+2 -2
View File
@@ -94,7 +94,7 @@ func Record(_ *cobra.Command, _ []string) error {
in := io.MultiWriter(tape, terminal)
if shell != defaultShell {
tape.WriteString(fmt.Sprintf("%s Shell %s\n", token.SET, shell))
_, _ = fmt.Fprintf(tape, "%s Shell %s\n", token.SET, shell)
}
go func() {
@@ -104,7 +104,7 @@ func Record(_ *cobra.Command, _ []string) error {
time.Sleep(sleepThreshold)
if length == tape.Len() {
// Tape has not changed in a while, write a Sleep command.
tape.WriteString(fmt.Sprintf("\n%s\n", token.SLEEP))
_, _ = fmt.Fprintf(tape, "\n%s\n", token.SLEEP)
}
}
}()
+2 -2
View File
@@ -10,10 +10,10 @@ import (
func dropUserPrivileges(gid int, uid int) error {
if err := syscall.Setgid(gid); err != nil {
return fmt.Errorf("Setgid error: %s", err)
return fmt.Errorf("setgid error: %s", err)
}
if err := syscall.Setuid(uid); err != nil {
return fmt.Errorf("Setuid error: %s", err)
return fmt.Errorf("setuid error: %s", err)
}
return nil
}
+1 -1
View File
@@ -33,7 +33,7 @@ func (v *VHS) SaveOutput() error {
var err error
// Create output file (once)
once.Do(func() {
err = os.MkdirAll(filepath.Dir(v.Options.Test.Output), os.ModePerm)
err = os.MkdirAll(filepath.Dir(v.Options.Test.Output), 0o750)
if err != nil {
file, err = os.CreateTemp(os.TempDir(), "vhs-*.txt")
return
+2
View File
@@ -1,3 +1,5 @@
// Package token provides the token types and structures for the VHS Tape
// language.
package token
import (
+1 -1
View File
@@ -187,7 +187,7 @@ func (vhs *VHS) Setup() {
vhs.Page.MustEval("term.fit")
_ = os.RemoveAll(vhs.Options.Video.Input)
_ = os.MkdirAll(vhs.Options.Video.Input, os.ModePerm)
_ = os.MkdirAll(vhs.Options.Video.Input, 0o750)
}
const cleanupWaitTime = 100 * time.Millisecond
+1 -1
View File
@@ -99,7 +99,7 @@ func makeMedia(opts VideoOptions, targetFile string) *exec.Cmd {
// ensureDir ensures that the file path of the output can be created by
// creating all the necessary nested folders.
func ensureDir(output string) {
err := os.MkdirAll(filepath.Dir(output), os.ModePerm)
err := os.MkdirAll(filepath.Dir(output), 0o750)
if err != nil {
fmt.Println(ErrorStyle.Render("Unable to create output directory: "), output)
}