Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aymanbagabas committed Jul 31, 2024
1 parent ca5832b commit 0191234
Show file tree
Hide file tree
Showing 23 changed files with 72 additions and 70 deletions.
6 changes: 3 additions & 3 deletions cmd/soft/browse/browse.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ tea.Model = &model{}

func (m *model) SetSize(w, h int) {
m.common.SetSize(w, h)
style := m.common.Styles.App.Copy()
style := m.common.Styles.App
wm := style.GetHorizontalFrameSize()
hm := style.GetVerticalFrameSize()
if m.showFooter {
Expand Down Expand Up @@ -206,7 +206,7 @@ func (m *model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

// View implements tea.Model.
func (m *model) View() string {
style := m.common.Styles.App.Copy()
style := m.common.Styles.App
wm, hm := style.GetHorizontalFrameSize(), style.GetVerticalFrameSize()
if m.showFooter {
hm += m.footer.Height()
Expand All @@ -219,7 +219,7 @@ func (m *model) View() string {
case errorState:
err := m.common.Styles.ErrorTitle.Render("Bummer")
err += m.common.Styles.ErrorBody.Render(m.error.Error())
view = m.common.Styles.Error.Copy().
view = m.common.Styles.Error.
Width(m.common.Width -
wm -
m.common.Styles.ErrorBody.GetHorizontalFrameSize()).
Expand Down
2 changes: 1 addition & 1 deletion cmd/soft/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var (

<-done

ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()
if err := s.Shutdown(ctx); err != nil {
return err
Expand Down
6 changes: 4 additions & 2 deletions pkg/access/access.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ func ParseAccessLevel(s string) AccessLevel {
}
}

var _ encoding.TextMarshaler = AccessLevel(0)
var _ encoding.TextUnmarshaler = (*AccessLevel)(nil)
var (
_ encoding.TextMarshaler = AccessLevel(0)
_ encoding.TextUnmarshaler = (*AccessLevel)(nil)
)

// ErrInvalidAccessLevel is returned when an invalid access level is provided.
var ErrInvalidAccessLevel = errors.New("invalid access level")
Expand Down
7 changes: 2 additions & 5 deletions pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ var (
}, []string{"repo"})
)

var (

// ErrServerClosed indicates that the server has been closed.
ErrServerClosed = fmt.Errorf("git: %w", net.ErrClosed)
)
// ErrServerClosed indicates that the server has been closed.
var ErrServerClosed = fmt.Errorf("git: %w", net.ErrClosed)

// GitDaemon represents a Git daemon.
type GitDaemon struct {
Expand Down
6 changes: 4 additions & 2 deletions pkg/db/migrate/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ func migrateDown(ctx context.Context, tx *db.Tx, version int, name string) error
return execMigration(ctx, tx, version, name, true)
}

var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
var (
matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
)

func toSnakeCase(str string) string {
str = strings.ReplaceAll(str, "-", "_")
Expand Down
6 changes: 2 additions & 4 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import (
"github.com/go-git/go-git/v5/plumbing/format/pktline"
)

var (
// ErrNoBranches is returned when a repo has no branches.
ErrNoBranches = errors.New("no branches found")
)
// ErrNoBranches is returned when a repo has no branches.
var ErrNoBranches = errors.New("no branches found")

// WritePktline encodes and writes a pktline to the given writer.
func WritePktline(w io.Writer, v ...interface{}) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/git/lfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (t *lfsTransfer) Upload(oid string, size int64, r io.Reader, _ transfer.Arg
}

// Verify implements transfer.Backend.
func (t *lfsTransfer) Verify(oid string, size int64, args transfer.Args) (transfer.Status, error) {
func (t *lfsTransfer) Verify(oid string, size int64, _ transfer.Args) (transfer.Status, error) {
obj, err := t.store.GetLFSObjectByOid(t.ctx, t.dbx, t.repo.ID(), oid)
if err != nil {
if errors.Is(err, db.ErrRecordNotFound) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/ssh/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewUI(c common.Common, initialRepo string) *UI {
}

func (ui *UI) getMargins() (wm, hm int) {
style := ui.common.Styles.App.Copy()
style := ui.common.Styles.App
switch ui.activePage {
case selectionPage:
hm += ui.common.Styles.ServerName.GetHeight() +
Expand Down Expand Up @@ -271,7 +271,7 @@ func (ui *UI) View() string {
case errorState:
err := ui.common.Styles.ErrorTitle.Render("Bummer")
err += ui.common.Styles.ErrorBody.Render(ui.error.Error())
view = ui.common.Styles.Error.Copy().
view = ui.common.Styles.Error.
Width(ui.common.Width -
wm -
ui.common.Styles.ErrorBody.GetHorizontalFrameSize()).
Expand Down
6 changes: 2 additions & 4 deletions pkg/ui/common/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"github.com/muesli/termenv"
)

var (
// DefaultColorProfile is the default color profile used by the SSH server.
DefaultColorProfile = termenv.ANSI256
)
// DefaultColorProfile is the default color profile used by the SSH server.
var DefaultColorProfile = termenv.ANSI256

func strptr(s string) *string {
return &s
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/components/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func New(c common.Common, content, extension string) *Code {
TabWidth: defaultTabWidth,
SideNotePercent: defaultSideNotePercent,
Viewport: vp.New(c),
NoContentStyle: c.Styles.NoContent.Copy().SetString("No Content."),
NoContentStyle: c.Styles.NoContent.SetString("No Content."),
}
st := common.StyleConfig()
r.styleConfig = st
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/components/footer/footer.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (f *Footer) View() string {
if f.keymap == nil {
return ""
}
s := f.common.Styles.Footer.Copy().
s := f.common.Styles.Footer.
Width(f.common.Width)
helpView := f.help.View(f.keymap)
return f.common.Zone.Mark(
Expand Down
4 changes: 2 additions & 2 deletions pkg/ui/components/tabs/tabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ func (t *Tabs) View() string {
s := strings.Builder{}
sep := t.TabSeparator
for i, tab := range t.tabs {
style := t.TabInactive.Copy()
style := t.TabInactive
prefix := " "
if i == t.activeTab {
style = t.TabActive.Copy()
style = t.TabActive
prefix = t.TabDot.Render("• ")
}
if t.UseDot {
Expand Down
7 changes: 4 additions & 3 deletions pkg/ui/pages/repo/filesitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
nameStyle = s.Active.FileName
sizeStyle = s.Active.FileSize
modeStyle = s.Active.FileMode
fmt.Fprint(w, s.Selector.Render(">"))
fmt.Fprint(w, s.Selector.Render(">")) //nolint:errcheck
} else {
nameStyle = s.Normal.FileName
sizeStyle = s.Normal.FileSize
modeStyle = s.Normal.FileMode
fmt.Fprint(w, s.Selector.Render(" "))
fmt.Fprint(w, s.Selector.Render(" ")) //nolint:errcheck
}
sizeStyle = sizeStyle.Copy().
sizeStyle = sizeStyle.
Width(8).
Align(lipgloss.Right).
MarginLeft(1)
Expand All @@ -142,6 +142,7 @@ func (d FileItemDelegate) Render(w io.Writer, m list.Model, index int, listItem
truncate := d.common.Renderer.NewStyle().MaxWidth(m.Width() -
s.Selector.GetHorizontalFrameSize() -
s.Selector.GetWidth())
//nolint:errcheck
fmt.Fprint(w,
d.common.Zone.Mark(
i.ID(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/pages/repo/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func (l *Log) View() string {
msg += "s"
}
msg += "…"
return l.common.Styles.SpinnerContainer.Copy().
return l.common.Styles.SpinnerContainer.
Height(l.common.Height).
Render(msg)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/pages/repo/logitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (d LogItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
// title truncation symbol (1)
9),
)
hashStyle := styles.Hash.Copy().
hashStyle := styles.Hash.
Align(lipgloss.Right).
PaddingLeft(1).
Width(m.Width() -
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/pages/repo/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Readme struct {
// NewReadme creates a new readme model.
func NewReadme(common common.Common) *Readme {
readme := code.New(common, "", "")
readme.NoContentStyle = readme.NoContentStyle.Copy().SetString("No readme found.")
readme.NoContentStyle = readme.NoContentStyle.SetString("No readme found.")
readme.UseGlamour = true
s := spinner.New(spinner.WithSpinner(spinner.Dot),
spinner.WithStyle(common.Styles.Spinner))
Expand Down
4 changes: 2 additions & 2 deletions pkg/ui/pages/repo/refsitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l

t := i.Tag
if t != nil {
msgSt := st.ItemDesc.Copy().Faint(false)
msgSt := st.ItemDesc.Faint(false)
msg := t.Message()
nl := strings.Index(msg, "\n")
if nl > 0 {
Expand Down Expand Up @@ -186,7 +186,7 @@ func (d RefItemDelegate) Render(w io.Writer, m list.Model, index int, listItem l
lipgloss.Width(sha) -
1 // 1 is for the left padding
if hashMargin >= 0 {
hash = strings.Repeat(" ", hashMargin) + st.ItemHash.Copy().
hash = strings.Repeat(" ", hashMargin) + st.ItemHash.
Align(lipgloss.Right).
PaddingLeft(1).
Render(sha)
Expand Down
10 changes: 5 additions & 5 deletions pkg/ui/pages/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ func (r *Repo) View() string {
wm, hm := r.getMargins()
hm += r.common.Styles.Tabs.GetHeight() +
r.common.Styles.Tabs.GetVerticalFrameSize()
s := r.common.Styles.Repo.Base.Copy().
s := r.common.Styles.Repo.Base.
Width(r.common.Width - wm).
Height(r.common.Height - hm)
mainStyle := r.common.Styles.Repo.Body.Copy().
mainStyle := r.common.Styles.Repo.Body.
Height(r.common.Height - hm)
var main string
var statusbar string
Expand Down Expand Up @@ -339,7 +339,7 @@ func (r *Repo) headerView() string {
r.common.Styles.Repo.HeaderDesc.Render(desc),
)
}
urlStyle := r.common.Styles.URLStyle.Copy().
urlStyle := r.common.Styles.URLStyle.
Width(r.common.Width - lipgloss.Width(desc) - 1).
Align(lipgloss.Right)
var url string
Expand All @@ -354,7 +354,7 @@ func (r *Repo) headerView() string {

header = lipgloss.JoinHorizontal(lipgloss.Left, header, url)

style := r.common.Styles.Repo.Header.Copy().Width(r.common.Width)
style := r.common.Styles.Repo.Header.Width(r.common.Width)
return style.Render(
truncate.Render(header),
)
Expand Down Expand Up @@ -425,7 +425,7 @@ func switchTabCmd(m common.TabComponent) tea.Cmd {

func renderLoading(c common.Common, s spinner.Model) string {
msg := fmt.Sprintf("%s loading…", s.View())
return c.Styles.SpinnerContainer.Copy().
return c.Styles.SpinnerContainer.
Height(c.Height).
Render(msg)
}
6 changes: 3 additions & 3 deletions pkg/ui/pages/selection/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (d *ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem lis
if m.Width()-styles.Base.GetHorizontalFrameSize()-lipgloss.Width(updatedStr)-lipgloss.Width(title) <= 0 {
updatedStr = ""
}
updatedStyle := styles.Updated.Copy().
updatedStyle := styles.Updated.
Align(lipgloss.Right).
Width(m.Width() - styles.Base.GetHorizontalFrameSize() - lipgloss.Width(title))
updated := updatedStyle.Render(updatedStr)
Expand All @@ -189,8 +189,8 @@ func (d *ItemDelegate) Render(w io.Writer, m list.Model, index int, listItem lis
}

if isFiltered {
unmatched := styles.Title.Copy().Inline(true)
matched := unmatched.Copy().Underline(true)
unmatched := styles.Title.Inline(true)
matched := unmatched.Underline(true)
title = lipgloss.StyleRunes(title, matchedRunes, matched, unmatched)
}
title = styles.Title.Render(title)
Expand Down
8 changes: 4 additions & 4 deletions pkg/ui/pages/selection/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ func New(c common.Common) *Selection {
}
t := tabs.New(c, ts)
t.TabSeparator = c.Renderer.NewStyle()
t.TabInactive = c.Styles.TopLevelNormalTab.Copy()
t.TabActive = c.Styles.TopLevelActiveTab.Copy()
t.TabDot = c.Styles.TopLevelActiveTabDot.Copy()
t.TabInactive = c.Styles.TopLevelNormalTab
t.TabActive = c.Styles.TopLevelActiveTab
t.TabDot = c.Styles.TopLevelActiveTabDot
t.UseDot = true
sel := &Selection{
common: c,
Expand All @@ -63,7 +63,7 @@ func New(c common.Common) *Selection {
}
readme := code.New(c, "", "")
readme.UseGlamour = true
readme.NoContentStyle = c.Styles.NoContent.Copy().
readme.NoContentStyle = c.Styles.NoContent.
SetString(defaultNoContent)
selector := selector.New(c,
[]selector.IdentifiableItem{},
Expand Down
Loading

0 comments on commit 0191234

Please sign in to comment.