Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RESCUE SQUAD: Rails Edition - Ancient City Ruby 2015

RESCUE SQUAD: Rails Edition - Ancient City Ruby 2015

146e52d49d361f85c0945487452fc6a0?s=128

Ben Lovell

March 28, 2015
Tweet

Transcript

  1. RESCUE SQUAD RAILS EDITION Ancient City Ruby 2015

  2. I ❤ 'ancient' city

  3. ben.lovell.720p.S01_E02.mkv

  4. None
  5. None
  6. None
  7. london

  8. england

  9. london

  10. not yoga, drunk

  11. None
  12. psa: don't stare into the eclipse

  13. None
  14. None
  15. None
  16. None
  17. None
  18. ben lovell ltd ™ © ® giving no fucks since

    2014
  19. rails sucks

  20. $ rails new life_is_good

  21. None
  22. None
  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. @benlovell twitter/github/irc

  30. I really suck!

  31. Here’s some commits I made just the other day

  32. None
  33. None
  34. ! "

  35. Programming is like skipping merrily between car crashes

  36. WHY!!!!? !

  37. Ephemeral Teams

  38. Make it work Make it right Make it fast

  39. Make it work Make it right Make it fast

  40. Is it done yet? Is it done yet? Is it

    done yet?
  41. !!!

  42. Rails Derailed

  43. None
  44. None
  45. None
  46. None
  47. three hard problems in computer science

  48. 1. cache invalidation

  49. 2. naming things

  50. DHH

  51. None
  52. Changing requirements

  53. sorry Your project is not a special ❄

  54. guess what? software changes

  55. Quit whining!

  56. No. 1 best job?

  57. None
  58. $ git clone ...

  59. Huge pile of shit?

  60. None
  61. None
  62. !" GTFO?

  63. 5 Steps

  64. 1 Step

  65. Perception change it!

  66. I see dead people

  67. Being a positive influence

  68. Opinions as pull requests

  69. Broken windows

  70. Always leave the camp cleaner than you found it

  71. It’s better to seek forgiveness than ask permission

  72. 2 step

  73. Metrics

  74. CI

  75. None
  76. !

  77. Effect a consistent style

  78. Make it approachable

  79. Rubocop

  80. 2nd most stylish rubyist

  81. $ gem install rubocop ~/code/frontend % rubocop Inspecting 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
  82. Auto correction?

  83. ~/code/frontend % rubocop -a Inspecting 313 files .....................................................C Offenses: app/helpers/profile_helper.rb:2:1:

    C: [Corrected] Extra empty line detected at body beginning. 313 files inspected, 1 offense detected, 1 offense corrected
  84. Sorcery!

  85. None
  86. Test Coverage

  87. $ gem install SimpleCov

  88. None
  89. You're sitting on a throne of lies

  90. Cyclomatic Complexity

  91. $ gem install metric_fu-Saikuro

  92. Coverage + Cyclomatic Complexity Inform your tests

  93. Duplication Duplication Duplication Duplication

  94. $ gem install flay ~/code/frontend % flay app/**/*.rb -f Total

    score (lower is better) = 256 1) Similar code found in :call (mass = 148) app/controllers/styleguide_controller.rb:63 app/controllers/styleguide_controller.rb:221 2) Similar code found in :defn (mass = 108) app/helpers/application_helper.rb:2 app/helpers/application_helper.rb:9 app/helpers/application_helper.rb:16 app/helpers/application_helper.rb:23 app/helpers/application_helper.rb:30 app/helpers/application_helper.rb:37
  95. Not all duplication

  96. Good DRY Bad DRY

  97. single unambiguous authoritative representation

  98. Churn

  99. $ gem install churn ~/code/blog % churn Files +----------------------------------------------------------+---------------+ |

    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 | +----------------------------------------------------------+---------------+
  100. All the metrics! $ gem install metric_fu cane, churn, flog,

    flay, reek roodi, saikuro, code statistics rails best practices
  101. code climate?

  102. Metric Overflow!

  103. Only capture that you plan to action

  104. Make it known

  105. Dashboard

  106. Gamify

  107. 3 step

  108. Tests

  109. % tree spec/models spec/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.rb 0 directories, 12 files
  110. require 'test_helper' class UserTest < ActiveSupport::TestCase # test "the truth"

    do # assert true # end end
  111. None
  112. All kinds of bad

  113. No tests Slow tests Low quality tests

  114. Tests are not sacred artifacts

  115. Tests can be transient

  116. zero coverage? this might not be so bad

  117. Feature specs go full stack or go home

  118. Poor or slow units? wrong time, wrong place

  119. Repeat after me: Tests are not sacred artifacts

  120. kill them with fire

  121. 4 step

  122. Seek and destroy

  123. Reduce the surface area

  124. Always be merciless

  125. Metrics

  126. Low hanging fruit Targets or goals which are easily achievable

    but do not require lots of effort
  127. Improve Incrementally

  128. None
  129. versioning rails stay on target, stay on target

  130. 5 step

  131. Keep it full unicorn

  132. Fail the build

  133. Always be improving

  134. Perception Metrics Tests Reduce & Improve Stay Full Unicorn

  135. None
  136. None
  137. None
  138. None
  139. meet hot single sharks in your area

  140. None
  141. None
  142. None
  143. None
  144. Thanks! @benlovell

  145. None