简体   繁体   中英

reek complaints for DuplicateMethodCall format.json

I have this code reek complains for DuplicateMethodCall (calls format.json twice)

if object_error.blank?
  format.json { render json: order }
else
  format.json { render json: object_error, status: :unprocessable_entity }
end

What is the best way to do it in rails? or is this false positive?

I think there is no need in refactoring in this particular case.

This, and other variations occurs errors too:

format.json { render(object_error.blank? ? (json: order) : (json: object_error, status: :unprocessable_entity) }

And it's less readable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM