Skip to content

Commit

Permalink
Refactoring (swaggo#708):
Browse files Browse the repository at this point in the history
- increase code readability by union conditions
- moved result variable declaration inside function body
  • Loading branch information
KuboOrk committed Jan 20, 2022
1 parent 11237d1 commit d7a5867
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,9 @@ func fillDefinitionDescription(definition *spec.Schema, file *ast.File, typeSpec

// extractDeclarationDescription gets first description
// from attribute descriptionAttr in commentGroups (ast.CommentGroup)
func extractDeclarationDescription(commentGroups ...*ast.CommentGroup) (description string) {
func extractDeclarationDescription(commentGroups ...*ast.CommentGroup) string {
var description string

for _, commentGroup := range commentGroups {
if commentGroup == nil {
continue
Expand All @@ -1016,11 +1018,10 @@ func extractDeclarationDescription(commentGroups ...*ast.CommentGroup) (descript
for _, comment := range commentGroup.List {
commentText := strings.TrimSpace(strings.TrimLeft(comment.Text, "/"))
attribute := strings.Split(commentText, " ")[0]
if strings.ToLower(attribute) != descriptionAttr && !isHandlingDescription {
continue
}

if strings.ToLower(attribute) != descriptionAttr && isHandlingDescription {
if strings.ToLower(attribute) != descriptionAttr {
if !isHandlingDescription {
continue
}
break
}

Expand Down

0 comments on commit d7a5867

Please sign in to comment.