RefactoringDoes your code smell? by Martin Tschischauskas
Author•     http://twitter.com/MartynasC•     https://www.xing.com/profile/Martin_Ts      chischauskas                    ...
Motivation                                             gems                  Tools                      ConclusionMartin T...
MotivationDoes your code smell?Martin Tschischauskas   Refactoring – Does your code smell?
MotivationSituation at workMartin Tschischauskas   Refactoring – Does your code smell?
MotivationLots of articles / booksMartin Tschischauskas   Refactoring – Does your code smell?
MotivationBut how to start?Martin Tschischauskas   Refactoring – Does your code smell?
gemsCode SadistMartin Tschischauskas   Refactoring – Does your code smell?
floggem install flogfind yourapp -name *.rb | xargs flogMartin Tschischauskas                   Refactoring – Does your co...
flog• ABC metrics• computed by counting the number of assignments, branches and conditions  for a section of code    • Ass...
flaygem install flayfind yourapp -name *.rb | xargs flayMartin Tschischauskas                   Refactoring – Does your co...
flay• DRY – Don’t Repeat yourself• Analyzes ruby code for structural similarities   • Differences in literal values,   • N...
hecklegem install heckleheckle Class method –t path_to_your_test –T timeout_in_secondsMartin Tschischauskas            Ref...
heckle• Mutation tester• Changes code and checks if tests fail• If tests still succeed     • Code is not covered     • Or ...
reekgem install reekfind yourapp -name *.rb | xargs reekMartin Tschischauskas               Refactoring – Does your code s...
reek• Detects code smell   • Long Method   • Large Class   • Feature Envy (using methods of different class excessively)  ...
brakemangem install brakemanbrakeman yourappMartin Tschischauskas   Refactoring – Does your code smell?
brakeman• Detects possible security issues• No configuration is needed• Finds possible    • XSS    • SQL Injection    • …•...
rails_best_                                                                          practisesgem install rails_best_pract...
rails_best_                                                                              practises•    Tries to check code...
Code                                                               climatehttps://codeclimate.com/github/rails/railsMartin...
???ThankYou!Martin Tschischauskas   Refactoring – Does your code smell?
Credits                   http://www.flickr.com/photos/dana_moos/5495380861/sizes/o/in/photostream/                   http...
Upcoming SlideShare
Loading in...5
×

Refactoring code smell

1,637

Published on

A small presentation on how one could start refactoring ruby code.
- check the hotspots
- check your tests
- make it nice
-don't forget security

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,637
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
25
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • "http://www.amazon.de/gp/product/0321604814/ref=as_li_ss_tl?ie=UTF8&camp=1638&creative=19454&creativeASIN=0321604814&linkCode=as2&tag=woweffekt-21"
  • "http://www.amazon.de/gp/product/0321604814/ref=as_li_ss_tl?ie=UTF8&camp=1638&creative=19454&creativeASIN=0321604814&linkCode=as2&tag=woweffekt-21"
  • Refactoring code smell

    1. 1. RefactoringDoes your code smell? by Martin Tschischauskas
    2. 2. Author• http://twitter.com/MartynasC• https://www.xing.com/profile/Martin_Ts chischauskas Martin Tschischauskas • Diplom Technische Informatik / Computer Engineering • Ruby on Rails Developer • XING AG • Jobs TeamMartin Tschischauskas Refactoring – Does your code smell?
    3. 3. Motivation gems Tools ConclusionMartin Tschischauskas Refactoring – Does your code smell?
    4. 4. MotivationDoes your code smell?Martin Tschischauskas Refactoring – Does your code smell?
    5. 5. MotivationSituation at workMartin Tschischauskas Refactoring – Does your code smell?
    6. 6. MotivationLots of articles / booksMartin Tschischauskas Refactoring – Does your code smell?
    7. 7. MotivationBut how to start?Martin Tschischauskas Refactoring – Does your code smell?
    8. 8. gemsCode SadistMartin Tschischauskas Refactoring – Does your code smell?
    9. 9. floggem install flogfind yourapp -name *.rb | xargs flogMartin Tschischauskas Refactoring – Does your code smell?
    10. 10. flog• ABC metrics• computed by counting the number of assignments, branches and conditions for a section of code • Assignment - an explicit transfer of data into a variable • Branch - an explicit forward program branch out of scope - a function call, class method call, or new operator • Condition - a logical/Boolean test• |ABC| = sqrt((A*A)+(B*B)+(C*C))• http://ruby.sadi.st/Flog.htmlMartin Tschischauskas Refactoring – Does your code smell?
    11. 11. flaygem install flayfind yourapp -name *.rb | xargs flayMartin Tschischauskas Refactoring – Does your code smell?
    12. 12. flay• DRY – Don’t Repeat yourself• Analyzes ruby code for structural similarities • Differences in literal values, • Names, • Whitespace, • Programming style • Are ignored• http://ruby.sadi.st/Flay.htmlMartin Tschischauskas Refactoring – Does your code smell?
    13. 13. hecklegem install heckleheckle Class method –t path_to_your_test –T timeout_in_secondsMartin Tschischauskas Refactoring – Does your code smell?
    14. 14. heckle• Mutation tester• Changes code and checks if tests fail• If tests still succeed • Code is not covered • Or code does nothing• http://ruby.sadi.st/Heckle.htmlMartin Tschischauskas Refactoring – Does your code smell?
    15. 15. reekgem install reekfind yourapp -name *.rb | xargs reekMartin Tschischauskas Refactoring – Does your code smell?
    16. 16. reek• Detects code smell • Long Method • Large Class • Feature Envy (using methods of different class excessively) • Uncommunicative Name • Long Parameter List • Nested Iterators • https://github.com/troessner/reek/wiki/Code-SmellsMartin Tschischauskas Refactoring – Does your code smell?
    17. 17. brakemangem install brakemanbrakeman yourappMartin Tschischauskas Refactoring – Does your code smell?
    18. 18. brakeman• Detects possible security issues• No configuration is needed• Finds possible • XSS • SQL Injection • …• http://brakemanscanner.org/Martin Tschischauskas Refactoring – Does your code smell?
    19. 19. rails_best_ practisesgem install rails_best_practisesrails_best_practices -f htmlMartin Tschischauskas Refactoring – Does your code smell?
    20. 20. rails_best_ practises• Tries to check code for rails best practises• Move code from Controller to Model• RESTful Conventions• Model• Mailer• Migration• …• http://rails-bestpractices.com/Martin Tschischauskas Refactoring – Does your code smell?
    21. 21. Code climatehttps://codeclimate.com/github/rails/railsMartin Tschischauskas Refactoring – Does your code smell
    22. 22. ???ThankYou!Martin Tschischauskas Refactoring – Does your code smell?
    23. 23. Credits http://www.flickr.com/photos/dana_moos/5495380861/sizes/o/in/photostream/ http://www.flickr.com/photos/digitalsextant/4842845805/sizes/o/in/photostream/ http://www.flickr.com/photos/seatbelt67/502255276/sizes/o/in/photostream/Martin Tschischauskas Refactoring – Does your code smell?
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×