RESCUE SQUADRAILS EDITIONAncient City Ruby 2015
View Slide
I ❤ 'ancient' city
ben.lovell.720p.S01_E02.mkv
london
england
not yoga, drunk
psa: don't stare into the eclipse
ben lovell ltd ™ © ®giving no fucks since 2014
❤
railssucks
$ rails new life_is_good
@benlovelltwitter/github/irc
I reallysuck!
Here’s some commitsI made just the other day
! "
Programming is likeskipping merrily betweencar crashes
WHY!!!!?!
EphemeralTeams
Make it workMake it rightMake it fast
Is it done yet?Is it done yet?Is it done yet?
!!!
RailsDerailed
three hard problemsin computer science
1. cache invalidation
2. naming things
DHH
Changingrequirements
sorryYour project isnot a special ❄
guess what?software changes
Quit whining!
No. 1best job?
$ git clone ...
Huge pile of shit?
!"GTFO?
5Steps
1Step
Perceptionchange it!
I seedeadpeople
Being apositiveinfluence
Opinions aspull requests
Broken windows
Always leave the campcleaner than you found it
It’s better toseek forgivenessthan ask permission
2step
Metrics
CI
!
Effect aconsistent style
Make itapproachable
Rubocop
2nd most stylish rubyist
$ gem install rubocop~/code/frontend % rubocopInspecting 313 files.....................................................C...................................................................................................................................................................................................................................................................Offenses:app/helpers/profile_helper.rb:2:1: C: Extra empty line detected at body beginning.313 files inspected, 1 offense detected
Auto correction?
~/code/frontend % rubocop -aInspecting 313 files.....................................................COffenses:app/helpers/profile_helper.rb:2:1: C: [Corrected] Extraempty line detected at body beginning.313 files inspected, 1 offense detected, 1 offense corrected
Sorcery!
Test Coverage
$ gem install SimpleCov
You're sitting on athrone of lies
Cyclomatic Complexity
$ gem install metric_fu-Saikuro
Coverage + Cyclomatic ComplexityInform your tests
DuplicationDuplicationDuplicationDuplication
$ gem install flay~/code/frontend % flay app/**/*.rb -fTotal score (lower is better) = 2561) Similar code found in :call (mass = 148)app/controllers/styleguide_controller.rb:63app/controllers/styleguide_controller.rb:2212) Similar code found in :defn (mass = 108)app/helpers/application_helper.rb:2app/helpers/application_helper.rb:9app/helpers/application_helper.rb:16app/helpers/application_helper.rb:23app/helpers/application_helper.rb:30app/helpers/application_helper.rb:37
Not allduplication
Good DRYBad DRY
singleunambiguousauthoritativerepresentation
Churn
$ gem install churn~/code/blog % churnFiles+----------------------------------------------------------+---------------+| file_path | times_changed |+----------------------------------------------------------+---------------+| Gemfile | 20 || app/helpers/application_helper.rb | 14 || app/models/article.rb | 11 || spec/models/text_filter_spec.rb | 11 || spec/controllers/articles_controller_spec.rb | 11 || spec/controllers/setup_controller_spec.rb | 11 || spec/rails_helper.rb | 10 || app/models/blog.rb | 10 || spec/models/article_spec.rb | 10 || spec/controllers/admin/content_controller_spec.rb | 10 || spec/helpers/application_helper_spec.rb | 10 |+----------------------------------------------------------+---------------+
All the metrics!$ gem install metric_fucane, churn, flog, flay, reekroodi, saikuro, code statisticsrails best practices
code climate?
MetricOverflow!
Only capture thatyou plan to action
Make itknown
Dashboard
Gamify
3step
Tests
% tree spec/modelsspec/models├── authentication_token_spec.rb├── challenge_spec.rb├── entry_spec.rb├── facebook_token_spec.rb├── follow_spec.rb├── followed_list_spec.rb├── item_spec.rb├── list_fulfilment_criterion_spec.rb├── list_spec.rb├── prize_spec.rb├── rating_spec.rb└── user_spec.rb0 directories, 12 files
require 'test_helper'class UserTest < ActiveSupport::TestCase# test "the truth" do# assert true# endend
All kinds ofbad
No testsSlow testsLow quality tests
Tests are notsacred artifacts
Tests can betransient
zero coverage?this might not be so bad
Feature specsgo full stack or go home
Poor or slow units?wrong time, wrong place
Repeat after me:Tests are notsacred artifacts
kill them with fire
4step
Seekanddestroy
Reduce thesurfacearea
Always be merciless
Low hanging fruitTargets or goals which areeasily achievable but donot require lots of effort
ImproveIncrementally
versioning railsstay on target, stay on target
5step
Keep it full unicorn
Fail the build
Always beimproving
PerceptionMetricsTestsReduce & ImproveStay Full Unicorn
meet hot single sharks in your area
Thanks!@benlovell