6 ms·
Evaluating Rails Projects
- seven 12y agoAnother thing to do: rake stats # Report code statistics (KLOCs, etc) from the application
- samullen 12y agoA friend of mine also recommended seeing how RESTful the app is, which I think's a great idea as well. Probably going to follow up on the article with a PDF download to summarize all the todos and allow notes to be taken.
- danielharan 12y agoMake sure you add all the extra dirs where code might be hiding ::STATS_DIRECTORIES << ["Admin", "app/admin"] ::STATS_DIRECTORIES << ["Cells", "app/cells"] ...
- rmetzler 12y agoYou could also upload the Gemfile / Gemfile.lock to a service like versioneye [1] which will then tell you which gems are outdated and what the current versions are. [1] https://www.versioneye.com/ https://www.versioneye.com/
- smackjer 12y ago"bundle outdated" will do that too.
- nickjj 12y agoThere's this too: https://github.com/nickjj/gemshine https://github.com/nickjj/gemshine It will recursively check a directory for gemfiles and then compare your installed version against the latest version. It uses bundle outdated under the hood.
- rubiquity 12y agoGreat post. I do a lot of these same things whenever I join a new app or am evaluating a project to take on. There's definitely some doozies of Rails apps out there. I also like to pry open the ApplicationController pretty quickly. You'll usually find all sorts of interesting logic and tight coupling in there. In the example app you used, the models actually look pretty light on lines of code. I'm willing to bet the Views were full of conditionals, which is another thing I keep an eye out for. A search tool like ack or grep are also incredibly useful to follow a trail of any interesting scent you might pick up.
- enraged_camel 12y ago>>In the example app you used, the models actually look pretty light on lines of code. I'm willing to bet the Views were full of conditionals, which is another thing I keep an eye out for. I'm a Rails newbie so please excuse my ignorance... What is the connection between models being light on code and views being full of conditionals? What I assume you mean is that your models should also have view logic so that your templates aren't full of if-then statements. But isn't that what decorators are for?
- rubiquity 12y agoNo, the models shouldn't have view logic such as formatting, that belongs in Presenters. What I was implying is that the views likely have boolean logic/conditionals that are checking various states of the model and then rendering partials/HTML content based on that. Of course, there could also be model logic in the controllers and helpers as well.
- samullen 12y agoMost of the code was from a personal project, so the reason the models were light is because they weren't a 1:1 representation of the database. I try to practice good OOP and stay with Sandi Metz' rules: http://robots.thoughtbot.com/sandi-metz-rules-for-developers http://robots.thoughtbot.com/sandi-metz-rules-for-developers
- 12y ago
- era86 12y agoThis is great and all, but now I've done some analysis on my own project and it depresses me. Thanks, dude. Thanks a lot.
- samullen 12y agoAh ha! My evil plan is finally revealed.
- waterfowl 12y ago"source code management system i.e. SCM"? i.e. a VCS? They're not limited in utility to code.
- ffn 12y agoThis is good stuff, reminds me of all horrible cancer I've had to deal with working on certain projects in past. This hopefully isn't an issue with anyone else out there, but there also should be a check for complexity in the views. Dealing with junk like anonymous classes, capture abuse, stateful partials, bloated clashing helpers, rjs, etc. have been worse for my health than 20 years of chain smoking, heavy drinking, and being stabbed.
- kawsper 12y agoCould you elaborate on the capture abuse ?
- danielharan 12y ago"For the controllers directory, expect higher scores; good scores are less than 20." Ahem, anyone else run that and get scores like these? $ flog app/controllers/ 7658.1: flog total 17.4: flog/method average 174.4: BidsController#show app/controllers/bids_controller.rb:17 126.0: CompanyDocumentsController#update_verifications app/controllers/company_documents_controller.rb:85
- steveklabnik 12y agoControllers are usually the most 'big ball of mud' in Rails apps, which is why the whole "fat model, skinny controller" thing caught on.
- danielharan 12y agoRunning the same command on models... just crashes. Our God object (not User) weighs in at 1647.3. Yep, just one single model.
- peteforde 12y agoMinor errata: Rails was released in beta during the fall of 2004. The first Rails conference (Canada on Rails) was in early 2005 and the 1st edition of AWDwR came out in August 2005. I believe Rails hit v1.0 in December of 2005, but by that point it was already a thriving ecosystem.
- ejstembler 12y agoGood article. In addition to running flog, I also run brakeman and rails_best_practices.