Bad smell removal recipes from repository mining

94f9a7a725bcf86353f6a52d9faa7760?s=47 Luis Mayorga
November 27, 2014

Bad smell removal recipes from repository mining

94f9a7a725bcf86353f6a52d9faa7760?s=128

Luis Mayorga

November 27, 2014
Tweet

Transcript

  1. Benevol 2014, Nov 11-12! CWI, Amsterdam Luis Mayorga Inferring Bad

    Smell Removal Recipes from Repository Mining: an initial exploration Universidad Politécnica de Madrid! (Erasmus student at Ansymo) Javier Pérez Ansymo, University of Antwerp, Belgium
  2. Refactoring Recipes How to automate them? Bad Smells Disharmonies to

    / away! patterns
  3. The Problem PrintServer formatSummary(): String setLastDocument(d: Document): void getLastDocument: Document

    printDocument(): void lastDocument: Document formatDocument: String formatSummary(): String content: String name: String author: String creationDate: Date Document ✤ formatSummary() of PrintServer suffers from Feature Envy ✤ Trivial strategy: apply Move Method from PrintServer to Document ✤ Refactoring precondition violation: same signature conflict ✤ Additional refactorings are needed to enable the precondition ✤ Different refactoring sequences for each particular case
  4. Can we mine! refactoring strategies? Can we automate! refactoring strategies?

  5. Can we mine! refactoring strategies? Can we automate! refactoring strategies?

  6. Refactoring Strategy • incrementally composable • semiformal • "gaps" are

    computable Recipes to Refactoring Strategies “Refactoring Planning for Design Smell Correction in Object-Oriented Software” Javier Pérez; PhD Thesis, July 2011, University of Valladolid
  7. Refactoring Planning Compute ! "Remove DataClass" Current Source Code Refactoring

    Strategy HTN automated planning ?
  8. Refactoring Planning 01. increase visibility! 02. move method! 03. increase

    visibility! 04. move method! 05. increase visibility! 06. increase visibility! 07. increase visibility! 08. move method! 09. encapsulate field! 10. remove-method! 11. remove-method! 12. remove-method Compute ! "Remove DataClass" Current Source Code Refactoring Strategy
  9. Can we mine! refactoring strategies? Can we automate! refactoring strategies?

  10. Can we mine! refactoring strategies? Can we automate! refactoring strategies?

    Yes!
  11. Can we mine! refactoring strategies? Can we automate! refactoring strategies?

    Yes!
  12. Mining Refactoring Strategies Refactoring Strategy

  13. Mining Refactoring Strategies Refactoring Strategy

  14. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

    Strategy S1 ... Sn R1 ... Rn General Mining Approach
  15. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

    Strategy S1 ... Sn R1 ... Rn Available Mature Tools General Mining Approach
  16. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

    Strategy S1 ... Sn R1 ... Rn Available Mature Tools General Mining Approach
  17. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

    Strategy S1 ... Sn R1 ... Rn Available Mature Tools Ref-Finder General Mining Approach
  18. Experiments Summary • 4 open-source projects analysed: • Hibernate, JHotdraw,

    JEdit, PMD ! ! ! • Refactorings found for 6 smells! • Data Class, Schizophrenic Class, Blob Operation, Feature Envy, Intensive Coupling • Resources available at: • https://github.com/rapsioux/nose
  19. Smell detection - sampling each 5 revisions Process Overview s

    Evolution database XML Quality reports transformation and load Bad smell disappearances repository inFusion analysis Evolu datab XML Quality reports transformation and load Analyse revisions before and after the smell Manually inspect the refactorings detected Evolution database transformation and load refFinder analysis Bad smell disappearances Ref-Finder
  20. Data overview: Hibernate 0.0 2.5 5.0 7.5 10.0 1000 1200

    1400 Revision Bad smell count 1600 1800 2000 2200 1000 1200 1400 Revision Bad smell count total smells! ! ! smells removed! ! !
  21. Data overview: JEdit 750 775 800 825 850 7400 7450

    7500 Revision Bad smell count 0.00 0.25 0.50 0.75 1.00 7400 7450 7500 Revision Bad smell count 7456 "Enhancements suggested by IntelliJIDEA" total! smells! ! ! smells! removed! ! !
  22. Data overview: JHotdraw 176! Change in package structure 0 200

    400 600 100 200 300 Revision Bad smell count 0 10 20 30 40 100 200 300 Revision Bad smell count total! smells! ! ! smells! removed! ! !
  23. Data overview: PMD 4882! Matched maven package structure 4935! Turn

    pmd-build into mvn plugin 150 160 170 180 190 200 4750 4800 4850 4900 4950 5000 Revision Bad smell count 0 10 20 30 4750 4800 4850 4900 4950 5000 Revision Bad smell count total! smells! ! ! smells! removed! ! !
  24. Refactorings Found • Smells track gets lost due to •

    renamings • package reorganisation (big changes) ! • Few refactorings found • detection launched only on a few cases • non-useful renamings detected
  25. Refactorings Found: Blob Operation 01. inline temp! 02. extract method!

    03. replace method with method object Blob Operation 01. extract method!
  26. Refactorings Found: Feature Envy 01. inline temp! 02. extract method!

    03. replace method with method object 01. inline method 01. extract method Feature Envy
  27. Can we mine! refactoring strategies? Can we automate! refactoring strategies?

    Yes!
  28. Can we mine! refactoring strategies? Can we automate! refactoring strategies?

    Yes! So far so good …
  29. Conclusions and limitations so far • It seems developers don't

    care about removing bad smells • Recipes found refine those from common catalogues (Fowler, …) • Smarter interpretation of the detections needed • understands semantics of changes • Bad Smell Detection • time consuming • 5 revisions sample frequency • Smells tracking (renamings) • Refactoring Detection • False positives & false negatives • More fine-grained revisions (Git, IDE recording)
  30. Conclusions and limitations so far