Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bad smell removal recipes from repository mining

Luis Mayorga
November 27, 2014

Bad smell removal recipes from repository mining

Luis Mayorga

November 27, 2014
Tweet

Other Decks in Research

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. 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
  3. 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
  4. 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
  5. V1 ... Vn Refactoring Finder Smell Finder Strategy Miner Refactoring

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

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

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

    Strategy S1 ... Sn R1 ... Rn Available Mature Tools Ref-Finder General Mining Approach
  9. 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
  10. 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
  11. 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! ! !
  12. 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! ! !
  13. 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! ! !
  14. 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! ! !
  15. 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
  16. Refactorings Found: Blob Operation 01. inline temp! 02. extract method!

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

    03. replace method with method object 01. inline method 01. extract method Feature Envy
  18. 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)