Refactoring code smell
Upcoming SlideShare
Loading in...5
×
 

Refactoring code smell

on

  • 1,543 views

A small presentation on how one could start refactoring ruby code.

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

Statistics

Views

Total Views
1,543
Views on SlideShare
1,541
Embed Views
2

Actions

Likes
1
Downloads
10
Comments
0

1 Embed 2

https://si0.twimg.com 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • "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 Refactoring code smell Presentation Transcript

  • RefactoringDoes your code smell? by Martin Tschischauskas
  • 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?
  • Motivation gems Tools ConclusionMartin Tschischauskas Refactoring – Does your code smell?
  • 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 code smell?
  • 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?
  • flaygem install flayfind yourapp -name *.rb | xargs flayMartin Tschischauskas Refactoring – Does your code smell?
  • 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?
  • hecklegem install heckleheckle Class method –t path_to_your_test –T timeout_in_secondsMartin Tschischauskas Refactoring – Does your code smell?
  • 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?
  • reekgem install reekfind yourapp -name *.rb | xargs reekMartin Tschischauskas Refactoring – Does your code smell?
  • 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?
  • brakemangem install brakemanbrakeman yourappMartin Tschischauskas Refactoring – Does your code smell?
  • brakeman• Detects possible security issues• No configuration is needed• Finds possible • XSS • SQL Injection • …• http://brakemanscanner.org/Martin Tschischauskas Refactoring – Does your code smell?
  • rails_best_ practisesgem install rails_best_practisesrails_best_practices -f htmlMartin Tschischauskas Refactoring – Does your code smell?
  • 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?
  • Code climatehttps://codeclimate.com/github/rails/railsMartin Tschischauskas Refactoring – Does your code smell
  • ???ThankYou!Martin Tschischauskas Refactoring – Does your code smell?
  • 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?