Last Updated: February 25, 2016
·
406
· mfpiccolo

Rails ActiveRecord Stinks

Don't believe me, just look at the the Rails code climate page.
ActiveRecord was just recently bumped up to a nice and smelly D while ActiveRecord::QueryMethods gets a flat out F with a complexity rating of 559. (Check out this blog post to read more about the score and code climate grades.)

That is pretty stinky. Well... what do we do now? Never use ActiveRecord again? Rewrite Rails from scratch and keep saying to yourself "This time we won't make it all complicated."

Probably not either of those will do. We all know that ActiveRecord is awesome and makes our lives as Rails web developers much easier. We could consider getting involved in the Rails project and try to decrease the code complexity. Athough this is a great idea, it involves a lot of commitment and you have to be a master in ruby.

The real takeaway from this is take code metrics for what they are worth. If you happen to be doing something complex, don't be suprised if your code metrics reflex that complexity.

Here is a great blog post by Piotr Solnica on the subject:
Common Pitfalls Of Code Metrics