YARD:文档无用的或无意的回报
问题描述:
我有一个不纯的功能,像这样:YARD:文档无用的或无意的回报
# Impure function: Sets the status for a report_schedule, uses last_sent to
# calculate status
# @param report_schedule [Hash]
# @return [String] Non-useful: value of last_sent that was set
def self.set_report_schedule_status(report_schedule)
# Some logic that calculates status of report_schedule
report_schedule['status'] = status
report_schedule['last_sent'] = Time.now.to_s
end
我要的这个功能做的是建立status
和last_sent
,但这里的副作用是,它返回Time.now.to_s
。有没有合适的方法来记录这一点? 或者是我的函数定义错误或应该以return nil
结尾。
答
应该只是增加return nil
红宝石自动追加返回的方法执行的最后一件事