Slide 1

Slide 1 text

Upgrading�Rails?�It�is�a� good�time�to�refactor� your�code P.S.V.R Powered�by�Rabbit�2.1.2

Slide 2

Slide 2 text

Rails�4.1�was�released� last�week! 1/39

Slide 3

Slide 3 text

Why�is�it�a�good�time�to� refactor�your�code?�(1) Trust�me:�if�you�had�time�for� upgrading,�you�would�have�time�for� refactoring 2/39

Slide 4

Slide 4 text

Why�is�it�a�good�time�to� refactor�your�code?�(2) ���������������������������������������� ������������������������������������������� �������� ������������������������������������������������������������������� some�upgraded�behaviors�require� refactoring�after�all 3/39

Slide 5

Slide 5 text

Why�is�it�a�good�time�to� refactor�your�code?�(3) ����������������������������������� ��������� ������������������ ��������������������������� �������������������������������� ���������������������������������������������������������� ����������������������������������������������������� You�wan�to�implement�old�functions�via� new�features 4/39

Slide 6

Slide 6 text

Roadmap Ⅰ.�Community�Guidelines Ⅱ.�Code�coverage Ⅲ.�Dependencies�updating Ⅳ.�Density�of�Comments Ⅴ.�Cyclomatic�complexity Ⅵ.�Static�code�analyzer Ⅶ.�Commit�messages 5/39

Slide 7

Slide 7 text

Ⅰ.�Community� Guidelines�(1) ruby-style-guide A�community-driven�Ruby�coding�style� guide https://github.com/bbatsov/ruby-style- guide 6/39

Slide 8

Slide 8 text

Ⅰ.�Community� Guidelines�(2) ex.�Comments�section 7/39

Slide 9

Slide 9 text

Ⅰ.�Community� Guidelines�(3) rails-style-guide A�community-driven�Rails�3�&�4�style� guide https://github.com/bbatsov/rails-style- guide 8/39

Slide 10

Slide 10 text

Ⅰ.�Community� Guidelines�(4) ex.�Routing�section 9/39

Slide 11

Slide 11 text

Ⅱ.�Code�coverage�(1) simplecov Code�coverage�for�Ruby�1.9+�with�a� powerful�configuration�library�and� automatic�merging�of�coverage�across� test�suites gem�install�simplecov 10/39

Slide 12

Slide 12 text

Ⅱ.�Code�coverage�(2) 11/39

Slide 13

Slide 13 text

Ⅱ.�Code�coverage�(3) coveralls.io https://coveralls.io/ gem�ʻcoverallsʼ,�require:�false 12/39

Slide 14

Slide 14 text

Ⅱ.�Code�coverage�(4) 13/39

Slide 15

Slide 15 text

Ⅲ.�Dependencies� updating�(1) gemnasium https://gemnasium.com/ 14/39

Slide 16

Slide 16 text

Ⅲ.�Dependencies� updating�(2) 15/39

Slide 17

Slide 17 text

Ⅳ.�Density�of� Comments�(1) cf.�http://staff.unak.is/andy/ StaticAnalysis0809/metrics/dc.html 16/39

Slide 18

Slide 18 text

Ⅳ.�Density�of� Comments�(2) inch Documentation�measurement�tool�for� Ruby,�based�on�YARD. gem�install�inch 17/39

Slide 19

Slide 19 text

Ⅳ.�Density�of� Comments�(3) 18/39

Slide 20

Slide 20 text

Ⅳ.�Density�of� Comments�(4) inch-pages https://github.com/rrrene/inch-pages 19/39

Slide 21

Slide 21 text

Ⅳ.�Density�of� Comments�(5) 20/39

Slide 22

Slide 22 text

Ⅴ.�Cyclomatic� complexity�(1) developed�by�Thomas�J.�McCabe,�Sr.�in� 1976 For�this�strongly�connected�control� flow�graph,�Cyclomatic�complexity�=�3� is�the�number�of�linearly�independent� cycles�that�exist�in�the�graph,�i.e.�those� cycles�that�do�not�contain�other�cycles� within�themselves. 21/39

Slide 23

Slide 23 text

Ⅴ.�Cyclomatic� complexity�(2) 22/39

Slide 24

Slide 24 text

Ⅴ.�Cyclomatic� complexity�(3) ������� ����������� ��� ex.�Cyclomatic�complexity�=�1 23/39

Slide 25

Slide 25 text

Ⅴ.�Cyclomatic� complexity�(4) ������������������ ������������������������ ��� ex.�Cyclomatic�complexity�=�2 24/39

Slide 26

Slide 26 text

Ⅴ.�Cyclomatic� complexity�(5) ������������������������������� ��������������������������������������� ��� ex.�Cyclomatic�complexity�=�3 25/39

Slide 27

Slide 27 text

Ⅴ.�Cyclomatic� complexity�(6) ������������ ���������� ������������������������������� ��������������������������������� ������������������������������������� ����������������������������������� ������������������������������� ����������������������������������� ������������������������������� ����� ��� ex.�Cyclomatic�complexity�=�8 26/39

Slide 28

Slide 28 text

Ⅴ.�Cyclomatic� complexity�(7�-�before) ������������������������ ������������� ��������������������������������������������������������� �������������������������������������� ������������������������������������ ����������������������� ���������������������������������������������� ��������������������� ����������������������������� ��������������������������������� ���������������������������������� ���������������������������������������� ��������������������������������� ���������������������������������������������������� ����������������������������������� ����������������������������������� �������������������������������������������������� ������������������������������������������������������������� ���������������������������� ����� ����� ������������� ��� 27/39

Slide 29

Slide 29 text

Ⅴ.�Cyclomatic� complexity�(8�-�after) ������������������������������������������������������ ������������������������ �������������������������������������������������������� �������������������� �������������������������������������������� ��� 28/39

Slide 30

Slide 30 text

Ⅴ.�Cyclomatic� complexity�(9�-�after) ���������������� ������������������� ��������������������������� ������������������������������������������������������������� �������������������������������� �������������������������������������� �������������������������������������������������������������������������� ��������������������������������� ������������������������������������������������������������ ��� ������ ��� 29/39

Slide 31

Slide 31 text

Ⅵ.�Static�code�analyzer� (1) rubocop gem�install�rubocop rubocop�-R�>�rubocop.txt 30/39

Slide 32

Slide 32 text

Ⅵ.�Static�code�analyzer� (2) 31/39

Slide 33

Slide 33 text

Ⅵ.�Static�code�analyzer� (3) codeclimate https://codeclimate.com/ 32/39

Slide 34

Slide 34 text

Ⅵ.�Static�code�analyzer� (4) 33/39

Slide 35

Slide 35 text

Ⅶ.�Commit�messages� (1) good�commit�message�example 34/39

Slide 36

Slide 36 text

Ⅶ.�Commit�messages� (2) bad�commit�message�examples 35/39

Slide 37

Slide 37 text

Ⅶ.�Commit�messages� (3) bad�commit�message�examples 36/39

Slide 38

Slide 38 text

Ⅶ.�Commit�messages� (4) bad�commit�message�examples 37/39

Slide 39

Slide 39 text

How�to�write�good� commit�messages? Use�English Use�the�imperative,�present�tense:� “change”,�not�“changed”�or�“changes”;� “Fix�bug#1234”�is�better�than�“Fixed� bug�#1234” Use�50-char�title�and�Use�72-character� columns�for�word-wrapping. Read�more:�https://github.com/ torvalds/linux/ pull/17#issuecomment-5654674 38/39

Slide 40

Slide 40 text

Download�the�slides https://github.com/pmq20 39/39 Powered�by�Rabbit�2.1.2