jaydoane commented on code in PR #5424:
URL: https://github.com/apache/couchdb/pull/5424#discussion_r1945201104
##########
src/couch_quickjs/src/couch_quickjs_scanner_plugin.erl:
##########
@@ -814,12 +814,16 @@ nouveau_add_fun(#proc{}, _) ->
ok.
clouseau_index_doc(#proc{} = Proc, {[_ | _]} = Doc) ->
- [Fields | _] = prompt(Proc, [<<"index_doc">>, Doc]),
- lists:sort(Fields).
+ case prompt(Proc, [<<"index_doc">>, Doc]) of
+ [Fields | _] -> lists:sort(Fields);
+ [] -> []
+ end.
nouveau_index_doc(#proc{} = Proc, {[_ | _]} = Doc) ->
- [Fields | _] = prompt(Proc, [<<"nouveau_index_doc">>, Doc]),
- lists:sort(Fields).
+ case prompt(Proc, [<<"nouveau_index_doc">>, Doc]) of
+ [Fields | _] -> lists:sort(Fields);
+ [] -> []
+ end.
Review Comment:
I guess you could dry this out a little with a helper function?
```erlang
maybe_sort(Name) ->
case prompt(Proc, [Name, Doc]) of
[Fields | _] -> lists:sort(Fields);
[] -> []
end.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]