Fighting Code Smell   with RubyMine    Dennis Ushakov     Oleg Shpynov      www.jetbrains.com
Goals of this workshop• Show available code quality tools• How do they work• Show what RubyMine can offer                 ...
Working with code                                  20%                                  Write new code                    ...
Code quality tools                 Reek              Flay Flog          Roodi Dust Heckle              Metrics_fu       RS...
Code quality tools• Static• Runtime               www.jetbrains.com   5
Static tools• Inspect your code without launching it•100% side effects free•Easy to use•Challenging to implement•Rails DSL...
Runtime tools• Inspect your code by launching it•100% follow the way Ruby works•Cope well with Rails DSL•MAY have side eff...
Code that smells• Runtime errors• Runtime warnings (like parens in calls etc.)• Dead code• Copy/paste• Complex method bodi...
Metrics• Reek   – Uncommunicative name   – One char name   – Name ends with number   – Camelcase variable   – instance_of?...
Metrics• Flog   – Assignment Branch Call metrics• Saikuro   – Cyclomatic complexity• Roodi   – Assignment in condition   –...
Testing and Coverage tools•   RSpec•   Cucumber•   Autotest•   RCov, SimpleCov•   Continuous integration•   Heckle     – C...
Practicewww.jetbrains.com   12
What else can be done?All these tools use Abstract Syntax Tree, but this is not   all the information that can be extracte...
RubyMine•   On the fly code inspections•   Code duplicates•   Test tools integration with graphical UI•   Coverage tool in...
GO AND TRY!jetbrains.com/ruby     www.jetbrains.com   15
Thank you!•   Visit us               http://www.jetbrains.com/ruby•   Read about           http://blogs.jetbrains.com/ruby...
Develop with pleasure!Dennis.Ushakov@jetbrains.com              @en_dalOleg.Shpynov@jetbrains.com                @oleg_s  ...
Upcoming SlideShare
Loading in …5
×

Fighting Ruby code smell

5,134 views
4,897 views

Published on

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

No Downloads
Views
Total views
5,134
On SlideShare
0
From Embeds
0
Number of Embeds
2,702
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Fighting Ruby code smell

  1. 1. Fighting Code Smell with RubyMine Dennis Ushakov Oleg Shpynov www.jetbrains.com
  2. 2. Goals of this workshop• Show available code quality tools• How do they work• Show what RubyMine can offer www.jetbrains.com 2
  3. 3. Working with code 20% Write new code 80% Modify existing code: bugfixes, optimizations, etc. www.jetbrains.com 3
  4. 4. Code quality tools Reek Flay Flog Roodi Dust Heckle Metrics_fu RSpec Cucumber Autotest RCov SimpleCov www.jetbrains.com 4
  5. 5. Code quality tools• Static• Runtime www.jetbrains.com 5
  6. 6. Static tools• Inspect your code without launching it•100% side effects free•Easy to use•Challenging to implement•Rails DSL magic kills ‘em•Ruby has no formal specification www.jetbrains.com 6
  7. 7. Runtime tools• Inspect your code by launching it•100% follow the way Ruby works•Cope well with Rails DSL•MAY have side effects•Works until the very first failure www.jetbrains.com 7
  8. 8. Code that smells• Runtime errors• Runtime warnings (like parens in calls etc.)• Dead code• Copy/paste• Complex method bodies• Code style violations (i.e. naming conventions, etc)• Framework pattern violations (MVC pattern violations) www.jetbrains.com 8
  9. 9. Metrics• Reek – Uncommunicative name – One char name – Name ends with number – Camelcase variable – instance_of?, kind_of?, is_a? instead of polymorphism – Duplication – Long class, method, parameter list – Nested iterators www.jetbrains.com 9
  10. 10. Metrics• Flog – Assignment Branch Call metrics• Saikuro – Cyclomatic complexity• Roodi – Assignment in condition – Missing else in case – Long class/module/method – Class/module/method name check – Cyclomatic complexity• Flay – Duplicates www.jetbrains.com 10
  11. 11. Testing and Coverage tools• RSpec• Cucumber• Autotest• RCov, SimpleCov• Continuous integration• Heckle – Change code (if <-> unless, calls, numbers, assignments, etc.) to see if test fail www.jetbrains.com 11
  12. 12. Practicewww.jetbrains.com 12
  13. 13. What else can be done?All these tools use Abstract Syntax Tree, but this is not all the information that can be extracted!The main problem is Ruby object model complexityLEXICAL analysis• Lexer -> Parser -> Abstract Syntax Tree -> Control Flow Graph -> Data Flow Analysis www.jetbrains.com 13
  14. 14. RubyMine• On the fly code inspections• Code duplicates• Test tools integration with graphical UI• Coverage tool integration• Everything is tightly integrated in IDE www.jetbrains.com 14
  15. 15. GO AND TRY!jetbrains.com/ruby www.jetbrains.com 15
  16. 16. Thank you!• Visit us http://www.jetbrains.com/ruby• Read about http://blogs.jetbrains.com/ruby/• Post bugs http://youtrack.jetbrains.net/issues/RUBY• Follow us on twitter @rubymine www.jetbrains.com 16
  17. 17. Develop with pleasure!Dennis.Ushakov@jetbrains.com @en_dalOleg.Shpynov@jetbrains.com @oleg_s www.jetbrains.com Copyrights are retained by their respective owners

×