ruby-beautify
ruby-beautify copied to clipboard
Bad identation when using arrays with embebed objects
When I have this code, it's all ok:
def my_function array = [{ }] end
But, when I change to this: def my_function array = [{ } ] end
That is, put the closing bracket, the end keyword identation fails when I beautify it.
Regards! :-)
It happens the same when I Have this:
The plain code is this:
data_daily_aggregated_week = client[:alerts].find().aggregate([{
"$match": search_options
}, {
"$group": {
"_id": {
"hour": {
"$dateToString": {
format: '%H',
date: {
"$subtract": ["$pubISODate", 3 * 3600 * 1000] # - 3 Hours
}
}
},
"day": {
"$dayOfWeek": "$pubISODate"
}
},
"count": {
"$sum": 1,
}
},
}, {
"$match": {
"_id.day": {
"$in": [1,7]
}
}
}, {
"$group": {
"_id": "$_id.hour",
"count": {
"$sum": "$count"
}
}
}, {
"$project": {
"hour": "$_id",
"count": "$count"
}
},
"$sort": {
"hour": 1
}])
Good catch, I'll add it to the list. Hoping to fix all the open bugs by end of month, mid next month.
Gonna take some work as I've got ot od some backend changes.
Thanks !, I will continue working with my "fix" to it, but it take some time to me to discover that :-P Newbies maybe will appreciate the fix :-)
Good Job!
@giovannibenussi I'm not really sure what your expected behaviour would be here. I would find
def my_function
(indent)array = [{
(indent)(indent)(indent)code
(indent)}]
end
fairly puzzling.
@hzulla I use that form when I create an array of hash like this:
@erniebrodeur - I have an idea how to fix this and will try to submit a PR for this next week.
Sure, if you do put in a PR.
@erniebrodeur - ok, my idea didn't work out. :-/ So don't expect a PR for this issue.