SlideShare a Scribd company logo
Upgrading�Rails?�It�is�a�
good�time�to�refactor�
your�code
P.S.V.R
Powered�by�Rabbit�2.1.2
Rails�4.1�was�released�
last�week!
1/39
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
Why�is�it�a�good�time�to�
refactor�your�code?�(2)
����������������������������������������
�������������������������������������������
��������
�������������������������������������������������������������������
some�upgraded�behaviors�require�
refactoring�after�all
3/39
Why�is�it�a�good�time�to�
refactor�your�code?�(3)
�����������������������������������
���������
������������������
���������������������������
��������������������������������
����������������������������������������������������������
�����������������������������������������������������
You�wan�to�implement�old�functions�via�
new�features
4/39
Roadmap
Ⅰ.�Community�Guidelines
Ⅱ.�Code�coverage
Ⅲ.�Dependencies�updating
Ⅳ.�Density�of�Comments
Ⅴ.�Cyclomatic�complexity
Ⅵ.�Static�code�analyzer
Ⅶ.�Commit�messages
5/39
Ⅰ.�Community�
Guidelines�(1)
ruby-style-guide
A�community-driven�Ruby�coding�style�
guide
https://github.com/bbatsov/ruby-style-
guide
6/39
Ⅰ.�Community�
Guidelines�(2)
ex.�Comments�section
7/39
Ⅰ.�Community�
Guidelines�(3)
rails-style-guide
A�community-driven�Rails�3�&�4�style�
guide
https://github.com/bbatsov/rails-style-
guide
8/39
Ⅰ.�Community�
Guidelines�(4)
ex.�Routing�section
9/39
Ⅱ.�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
Ⅱ.�Code�coverage�(2)
11/39
Ⅱ.�Code�coverage�(3)
coveralls.io
https://coveralls.io/
gem�ʻcoverallsʼ,�require:�false
12/39
Ⅱ.�Code�coverage�(4)
13/39
Ⅲ.�Dependencies�
updating�(1)
gemnasium
https://gemnasium.com/
14/39
Ⅲ.�Dependencies�
updating�(2)
15/39
Ⅳ.�Density�of�
Comments�(1)
cf.�http://staff.unak.is/andy/
StaticAnalysis0809/metrics/dc.html
16/39
Ⅳ.�Density�of�
Comments�(2)
inch
Documentation�measurement�tool�for�
Ruby,�based�on�YARD.
gem�install�inch
17/39
Ⅳ.�Density�of�
Comments�(3)
18/39
Ⅳ.�Density�of�
Comments�(4)
inch-pages
https://github.com/rrrene/inch-pages
19/39
Ⅳ.�Density�of�
Comments�(5)
20/39
Ⅴ.�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
Ⅴ.�Cyclomatic�
complexity�(2)
22/39
Ⅴ.�Cyclomatic�
complexity�(3)
�������
�����������
���
ex.�Cyclomatic�complexity�=�1
23/39
Ⅴ.�Cyclomatic�
complexity�(4)
������������������
������������������������
���
ex.�Cyclomatic�complexity�=�2
24/39
Ⅴ.�Cyclomatic�
complexity�(5)
�������������������������������
���������������������������������������
���
ex.�Cyclomatic�complexity�=�3
25/39
Ⅴ.�Cyclomatic�
complexity�(6)
������������
����������
�������������������������������
���������������������������������
�������������������������������������
�����������������������������������
�������������������������������
�����������������������������������
�������������������������������
�����
���
ex.�Cyclomatic�complexity�=�8
26/39
Ⅴ.�Cyclomatic�
complexity�(7�-�before)
������������������������
�������������
���������������������������������������������������������
��������������������������������������
������������������������������������
�����������������������
����������������������������������������������
���������������������
�����������������������������
���������������������������������
����������������������������������
����������������������������������������
���������������������������������
����������������������������������������������������
�����������������������������������
�����������������������������������
��������������������������������������������������
�������������������������������������������������������������
����������������������������
�����
�����
�������������
���
27/39
Ⅴ.�Cyclomatic�
complexity�(8�-�after)
������������������������������������������������������
������������������������
��������������������������������������������������������
��������������������
��������������������������������������������
���
28/39
Ⅴ.�Cyclomatic�
complexity�(9�-�after)
����������������
�������������������
���������������������������
�������������������������������������������������������������
��������������������������������
��������������������������������������
��������������������������������������������������������������������������
���������������������������������
������������������������������������������������������������
���
������
���
29/39
Ⅵ.�Static�code�analyzer�
(1)
rubocop
gem�install�rubocop
rubocop�-R�>�rubocop.txt
30/39
Ⅵ.�Static�code�analyzer�
(2)
31/39
Ⅵ.�Static�code�analyzer�
(3)
codeclimate
https://codeclimate.com/
32/39
Ⅵ.�Static�code�analyzer�
(4)
33/39
Ⅶ.�Commit�messages�
(1)
good�commit�message�example
34/39
Ⅶ.�Commit�messages�
(2)
bad�commit�message�examples
35/39
Ⅶ.�Commit�messages�
(3)
bad�commit�message�examples
36/39
Ⅶ.�Commit�messages�
(4)
bad�commit�message�examples
37/39
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
Download�the�slides
https://github.com/pmq20
39/39Powered�by�Rabbit�2.1.2

More Related Content

PDF
Rails 快速上手攻略(Rails Getting Started)
PDF
lotus让我们写出更solid的ruby工程
PDF
Tracing a Memory-leak in a Long Running Eventmachine Application
KEY
A tour on ruby and friends
PDF
Embedding mruby into c and an actual example
PDF
Tracing a memory leaki in a long-running eventmachine application
PDF
C++ 11
PDF
How we scaled git lab for a 30k employee company
Rails 快速上手攻略(Rails Getting Started)
lotus让我们写出更solid的ruby工程
Tracing a Memory-leak in a Long Running Eventmachine Application
A tour on ruby and friends
Embedding mruby into c and an actual example
Tracing a memory leaki in a long-running eventmachine application
C++ 11
How we scaled git lab for a 30k employee company

Viewers also liked (17)

PDF
12 spazio associazioni_spazio_per_noi
PDF
15 spazio associazioni_nam
PDF
07 marzo 2011_sensi_feto
PDF
09 spazio associazioni_aibws
PDF
11 luglio agosto_2011_mi_è_nato_un_fratellino
PPTX
Evaluation question 1[1]
PPTX
Just For Kids Game
PPT
Www way2 wheeltheworld
PPTX
DivyANSH GOUR
PDF
06 febbraio 2011_parti_mondo
PPTX
My seven questions
PDF
13 spazio associazione_bambiniincorso
DOCX
Naturally diamond
PPTX
Open Packaging Conventions - Your Data: Accessible, Manageable, and Secure
PDF
Undead计划书
PPTX
Trip journal
PDF
01 tra il dire e il fare
12 spazio associazioni_spazio_per_noi
15 spazio associazioni_nam
07 marzo 2011_sensi_feto
09 spazio associazioni_aibws
11 luglio agosto_2011_mi_è_nato_un_fratellino
Evaluation question 1[1]
Just For Kids Game
Www way2 wheeltheworld
DivyANSH GOUR
06 febbraio 2011_parti_mondo
My seven questions
13 spazio associazione_bambiniincorso
Naturally diamond
Open Packaging Conventions - Your Data: Accessible, Manageable, and Secure
Undead计划书
Trip journal
01 tra il dire e il fare
Ad

Similar to Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it-is-a-good-time-to-refactor-your-code (20)

PPTX
Net core and linux in production
PDF
Headless Drupal на примере Drupal 8 и React
PDF
CI/CD with Fastlane and Telegram
PDF
Data Science Week 2016. Rambler & Co. "Пайплайн машинного обучения на Apache ...
PDF
Тестирование оборудования для операторов связи: методики, инструменты, анализ...
PPTX
Liferay Portal и приемы разработки
PDF
Практика разработки веб-серверов на Rust
PDF
Как начать применять R в Enterprise
PDF
презентация Адеев Николай, Artsofte для Tеlecom&Clouds 2014
PPTX
Breaking logs
PDF
Cisco DFA. Демонстрация функционирования, управления и интеграции
PDF
Deploy.rb, Ilya Zykin, Rails club2016
PDF
redux: the best for isomorphic apps
PDF
"Redux: the best for isomorphic apps", Денис Измайлов, MoscowJS 25
PDF
Linkmeup v076(2019-06).3
PDF
Сергей Яковлев "Phalcon 2 - стабилизация и производительность"
PDF
Денис Измайлов, JavaScript сегодня: React, Redux и новая реальность
PDF
JavaScript сегодня: React, Redux и новая реальность
PDF
JavaScript завтра
PDF
JavaScript завтра / Сергей Рубанов (Exante Limited)
Net core and linux in production
Headless Drupal на примере Drupal 8 и React
CI/CD with Fastlane and Telegram
Data Science Week 2016. Rambler & Co. "Пайплайн машинного обучения на Apache ...
Тестирование оборудования для операторов связи: методики, инструменты, анализ...
Liferay Portal и приемы разработки
Практика разработки веб-серверов на Rust
Как начать применять R в Enterprise
презентация Адеев Николай, Artsofte для Tеlecom&Clouds 2014
Breaking logs
Cisco DFA. Демонстрация функционирования, управления и интеграции
Deploy.rb, Ilya Zykin, Rails club2016
redux: the best for isomorphic apps
"Redux: the best for isomorphic apps", Денис Измайлов, MoscowJS 25
Linkmeup v076(2019-06).3
Сергей Яковлев "Phalcon 2 - стабилизация и производительность"
Денис Измайлов, JavaScript сегодня: React, Redux и новая реальность
JavaScript сегодня: React, Redux и новая реальность
JavaScript завтра
JavaScript завтра / Сергей Рубанов (Exante Limited)
Ad

Upgrading rails-it-is-a-good-time-to-refactor-your-code-en-upgrading-rails-it-is-a-good-time-to-refactor-your-code