Skip to content

Commit

Permalink
fix: improve GetSolutionCode empty lines check
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jan 31, 2023
1 parent f8cdeae commit e6f2a02
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lang/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import (

"github.com/AlecAivazis/survey/v2"
"github.com/hashicorp/go-hclog"
"github.com/spf13/viper"

"github.com/j178/leetgo/config"
"github.com/j178/leetgo/leetcode"
"github.com/j178/leetgo/utils"
"github.com/spf13/viper"
)

const (
Expand Down Expand Up @@ -459,7 +460,13 @@ func GetSolutionCode(q *leetcode.QuestionData) (string, error) {
}
}

if len(codeLinesToKeep) == 0 {
nonEmptyLines := 0
for _, line := range codeLinesToKeep {
if strings.TrimSpace(line) != "" {
nonEmptyLines++
}
}
if nonEmptyLines == 0 {
return "", fmt.Errorf("no code found in %s", codeFile.Path)
}

Expand Down

0 comments on commit e6f2a02

Please sign in to comment.