Skip to content

Commit a3aebe9

Browse files
committed
refactor: remove unused canSkip logic
1 parent 00cb105 commit a3aebe9

2 files changed

Lines changed: 18 additions & 40 deletions

File tree

pkg/cmd/dev.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -263,20 +263,3 @@ type GenerateSpecParams struct {
263263
StainlessConfig string `json:"stainless_config"`
264264
} `json:"source"`
265265
}
266-
267-
268-
func hasBlockingDiagnostic(diagnostics []stainless.BuildDiagnostic) bool {
269-
for _, d := range diagnostics {
270-
if !d.Ignored {
271-
switch d.Level {
272-
case stainless.BuildDiagnosticLevelFatal:
273-
case stainless.BuildDiagnosticLevelError:
274-
case stainless.BuildDiagnosticLevelWarning:
275-
return true
276-
case stainless.BuildDiagnosticLevelNote:
277-
continue
278-
}
279-
}
280-
}
281-
return false
282-
}

pkg/cmd/lint.go

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ type lintModel struct {
6464
error error
6565
watching bool
6666
skipped bool
67-
canSkip bool
6867
ctx context.Context
6968
cmd *cli.Command
7069
client stainless.Client
@@ -97,11 +96,6 @@ func (m lintModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9796
m.cmd = msg.cmd
9897
m.client = msg.client
9998

100-
if m.canSkip && !hasBlockingDiagnostic(m.diagnostics) {
101-
m.watching = false
102-
return m, tea.Quit
103-
}
104-
10599
if m.watching {
106100
return m, func() tea.Msg {
107101
if err := waitTillConfigChanges(m.ctx, m.cmd, m.wc); err != nil {
@@ -231,26 +225,28 @@ func getDiagnostics(ctx context.Context, cmd *cli.Command, client stainless.Clie
231225
return diagnostics, nil
232226
}
233227

234-
func (m lintModel) ShortHelp() []key.Binding {
235-
if m.canSkip {
236-
return []key.Binding{
237-
key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl-c", "quit")),
238-
key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "skip diagnostics")),
228+
func hasBlockingDiagnostic(diagnostics []stainless.BuildDiagnostic) bool {
229+
for _, d := range diagnostics {
230+
if !d.Ignored {
231+
switch d.Level {
232+
case stainless.BuildDiagnosticLevelFatal:
233+
case stainless.BuildDiagnosticLevelError:
234+
case stainless.BuildDiagnosticLevelWarning:
235+
return true
236+
case stainless.BuildDiagnosticLevelNote:
237+
continue
238+
}
239239
}
240-
} else {
241-
return []key.Binding{key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl-c", "quit"))}
242240
}
241+
return false
242+
}
243+
244+
func (m lintModel) ShortHelp() []key.Binding {
245+
return []key.Binding{key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl-c", "quit"))}
243246
}
244247

245248
func (m lintModel) FullHelp() [][]key.Binding {
246-
if m.canSkip {
247-
return [][]key.Binding{{
248-
key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl-c", "quit")),
249-
key.NewBinding(key.WithKeys("enter"), key.WithHelp("enter", "skip diagnostics")),
250-
}}
251-
} else {
252-
return [][]key.Binding{{key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl-c", "quit"))}}
253-
}
249+
return [][]key.Binding{{key.NewBinding(key.WithKeys("ctrl+c"), key.WithHelp("ctrl-c", "quit"))}}
254250
}
255251

256252
func runLinter(ctx context.Context, cmd *cli.Command, canSkip bool) error {
@@ -265,7 +261,6 @@ func runLinter(ctx context.Context, cmd *cli.Command, canSkip bool) error {
265261
m := lintModel{
266262
spinner: s,
267263
watching: cmd.Bool("watch"),
268-
canSkip: canSkip,
269264
ctx: ctx,
270265
cmd: cmd,
271266
client: client,
@@ -297,7 +292,7 @@ func runLinter(ctx context.Context, cmd *cli.Command, canSkip bool) error {
297292
}
298293

299294
// If not in watch mode and we have blocking diagnostics, exit with error code
300-
if !cmd.Bool("watch") && hasBlockingDiagnostic(finalModel.diagnostics) {
295+
if !cmd.Bool("watch") {
301296
os.Exit(1)
302297
}
303298

0 commit comments

Comments
 (0)