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

When QualityAssistant Meets Pharo [Enforced Code Critiques Motivate More Valuable Rules] (iwst2016)

When QualityAssistant Meets Pharo [Enforced Code Critiques Motivate More Valuable Rules] (iwst2016)

Static analysis tools can aid in software quality assessment, but are rarely used by software developers. Poor usage of quality analysis tools not only means missed opportunities for the quality of software systems, but also results in little feedback, which in turn slows the improvements of the quality rules themselves.

We introduced a set of intrusive quality plugins and integrated them into the Pharo IDE. This not only triggered a feedback loop that led to improvements of the existing rules, but also encouraged removal of some rules and integration of new ones. Our analysis of changes to the rules suggests that precise rules capturing a domain-specific logic are more valuable than general ones.

Yuriy Tymchuk

August 23, 2016
Tweet

More Decks by Yuriy Tymchuk

Other Decks in Programming

Transcript

  1. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern

    View full-size slide

  2. The Concept
    Rule

    View full-size slide

  3. The Concept
    Rule

    View full-size slide

  4. The Concept
    Rule Critique
    produces

    View full-size slide

  5. The Concept
    Rule Critique
    produces

    View full-size slide

  6. The Concept
    Rule Critique
    [|]
    Code
    produces
    improves

    View full-size slide

  7. The Concept
    Rule Critique
    [|]
    Code
    produces
    improves
    (feedback)
    improves

    View full-size slide

  8. The Concept
    Rule Critique
    [|]
    Code
    produces
    improves
    (feedback)
    improves

    View full-size slide

  9. The Concept
    Rule Critique
    [|]
    Code
    produces
    improves

    View full-size slide

  10. The Concept
    Rule Critique
    [|]
    Code
    produces
    improves

    View full-size slide

  11. The Existing CriticBrowser

    View full-size slide

  12. Newly Introduced QualityAssistant

    View full-size slide

  13. SmallLint Issues per Milestone
    0
    10
    20
    30
    40
    50
    Pharo 3 Pharo 4 Pharo 5 Pharo 6*

    View full-size slide

  14. Changes in Rules

    View full-size slide

  15. Changes in Rules
    Fixed

    View full-size slide

  16. Changes in Rules
    Fixed Removed

    View full-size slide

  17. Added
    Changes in Rules
    Fixed Removed

    View full-size slide

  18. Fixed
    (Collection>>#add:) protocol #adding

    View full-size slide

  19. Fixed
    (Collection>>#add:) protocol
    (ArrayedCollection>>#add:) protocol #adding
    #adding

    View full-size slide

  20. Fixed
    (Collection>>#add:) protocol
    (ArrayedCollection>>#add:) protocol #adding
    #accessing

    View full-size slide

  21. Fixed
    (Collection>>#add:) protocol
    (ArrayedCollection>>#add:) protocol #adding
    #accessing

    View full-size slide

  22. Fixed
    (Collection>>#add:) protocol
    #'as yet unclassified'
    (ArrayedCollection>>#add:) protocol #adding

    View full-size slide

  23. Fixed
    (Collection>>#add:) protocol
    #'as yet unclassified'
    (ArrayedCollection>>#add:) protocol #adding
    Trivial Bug

    View full-size slide

  24. Fixed
    RBModi!esCollectionRule

    View full-size slide

  25. Fixed
    RBModi!esCollectionRule
    Horrible Bug

    View full-size slide

  26. Removed
    Probably missing ‘; yourself’
    Non-blocks in special messages
    References an abstract class

    View full-size slide

  27. Removed
    Probably missing ‘; yourself’
    Non-blocks in special messages
    References an abstract class
    size = 1 ifTrue: ’:’ ifFalse: ’s:’

    View full-size slide

  28. Removed
    Probably missing ‘; yourself’
    Non-blocks in special messages
    References an abstract class
    String new
    size = 1 ifTrue: ’:’ ifFalse: ’s:’

    View full-size slide

  29. Removed
    Probably missing ‘; yourself’
    Non-blocks in special messages
    References an abstract class
    String new
    size = 1 ifTrue: ’:’ ifFalse: ’s:’
    Educational

    View full-size slide

  30. Added
    assert: a = b
    ifNotNilDo: ifNotNil:
    Smalltalk at: Smalltalk globals at:
    assert: a equals: b

    View full-size slide

  31. Added
    assert: a = b
    ifNotNilDo: ifNotNil:
    Smalltalk at: Smalltalk globals at:
    assert: a equals: b
    Migration

    View full-size slide

  32. Added
    assert: a = b
    ifNotNilDo: ifNotNil:
    Smalltalk at: Smalltalk globals at:
    assert: a equals: b
    Migration
    Recipe: use rewrite rules

    View full-size slide

  33. Added
    BoxedFloat64
    reference to

    View full-size slide

  34. Added
    BoxedFloat64
    reference to
    Private Access

    View full-size slide

  35. Added
    BoxedFloat64
    reference to
    Recipe: annotate/maintain a collection
    of system classes/methods
    Private Access

    View full-size slide

  36. Added
    b := RTMondrian new.
    b edges connectFrom: #superclass.
    b nodes: RTShape withAllSubclasses.

    View full-size slide

  37. Added
    b := RTMondrian new.
    b edges connectFrom: #superclass.
    b nodes: RTShape withAllSubclasses.
    b := RTMondrian new.
    b edges connectFrom: #superclass.
    b nodes: RTShape withAllSubclasses.

    View full-size slide

  38. Added
    b := RTMondrian new.
    b edges connectFrom: #superclass.
    b nodes: RTShape withAllSubclasses.
    Invocation order
    b := RTMondrian new.
    b edges connectFrom: #superclass.
    b nodes: RTShape withAllSubclasses.

    View full-size slide

  39. Added
    b := RTMondrian new.
    b edges connectFrom: #superclass.
    b nodes: RTShape withAllSubclasses.
    Recipe:
    initialize
    super initialize.
    self add: #edges requiresPreSend: #nodes:.
    Invocation Order
    b := RTMondrian new.
    b edges connectFrom: #superclass.
    b nodes: RTShape withAllSubclasses.

    View full-size slide

  40. Added
    ReAbstractRule class
    >> #checksPackage;
    >> #checksClass;
    >> #checksMethod;
    >> #checksNode

    View full-size slide

  41. Added
    ReAbstractRule class
    >> #checksPackage;
    >> #checksClass;
    >> #checksMethod;
    >> #checksNode
    true?

    View full-size slide

  42. Added
    ReAbstractRule class
    >> #checksPackage;
    >> #checksClass;
    >> #checksMethod;
    >> #checksNode
    true?
    Class Structure

    View full-size slide

  43. Added
    ReAbstractRule class
    >> #checksPackage;
    >> #checksClass;
    >> #checksMethod;
    >> #checksNode
    true?
    Recipe:
    (aClass inheritsFrom: ReAbstractRule) and: [
    selectors anySatisfy: [ :s | aClass perform: s ] ]
    Class Structure

    View full-size slide

  44. Added
    gtInspectorMethodsIn: composite

    | methods |
    methods := (self methods collect: #asRingDefinition)
    sorted: [ :x :y | x selector < y selector ]
    composite list
    title: 'Methods';
    display: methods;
    format: #selector;
    tags: [ :each | {each methodClass name} ]

    View full-size slide

  45. Added
    gtInspectorMethodsIn: composite

    | methods |
    methods := (self methods collect: #asRingDefinition)
    sorted: [ :x :y | x selector < y selector ]
    composite list
    title: 'Methods';
    display: methods;
    format: #selector;
    tags: [ :each | {each methodClass name} ]

    View full-size slide

  46. Added
    gtInspectorMethodsIn: composite

    composite list
    title: 'Methods';
    display: ((self methods collect: #asRingDefinition)
    sorted: [ :x :y | x selector < y selector ]);
    format: #selector;
    tags: [ :each | {each methodClass name} ]

    View full-size slide

  47. Added
    gtInspectorMethodsIn: composite

    composite list
    title: 'Methods';
    display: [ (self methods collect: #asRingDefinition)
    sorted: [ :x :y | x selector < y selector ] ];
    format: #selector;
    tags: [ :each | {each methodClass name} ]

    View full-size slide

  48. Added Lazy evaluation
    gtInspectorMethodsIn: composite

    composite list
    title: 'Methods';
    display: [ (self methods collect: #asRingDefinition)
    sorted: [ :x :y | x selector < y selector ] ];
    format: #selector;
    tags: [ :each | {each methodClass name} ]

    View full-size slide

  49. gtInspectorMethodsIn: composite

    composite list
    title: 'Methods';
    display: [ (self methods collect: #asRingDefinition)
    sorted: [ :x :y | x selector < y selector ] ];
    format: #selector;
    tags: [ :each | {each methodClass name} ]
    Added Lazy evaluation
    Recipe:
    presentation: aPresentation isTheLeftmostRecepientIn: aStatement
    ^ (aStatement isMessage or:
    [ aStatement isCascade ]) and: [
    aStatement leftmostChainReceiver = aPresentation ]

    View full-size slide

  50. Feedback
    http://renraku.inf.usi.ch/rules

    View full-size slide

  51. Feedback
    http://renraku.inf.usi.ch/rules

    View full-size slide

  52. Feedback
    http://renraku.inf.usi.ch/rules

    View full-size slide

  53. Feedback
    http://renraku.inf.usi.ch/rules

    View full-size slide

  54. Feedback
    http://renraku.inf.usi.ch/rules

    View full-size slide

  55. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern

    View full-size slide

  56. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes

    View full-size slide

  57. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes
    Educational
    Rules Removed

    View full-size slide

  58. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes
    Educational
    Rules Removed
    Domain Rules
    Added

    View full-size slide

  59. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes
    Educational
    Rules Removed
    Domain Rules
    Added
    Migration

    View full-size slide

  60. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes
    Educational
    Rules Removed
    Domain Rules
    Added
    Migration
    Private access

    View full-size slide

  61. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes
    Educational
    Rules Removed
    Domain Rules
    Added
    Migration
    Private access
    Invocation order

    View full-size slide

  62. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes
    Educational
    Rules Removed
    Domain Rules
    Added
    Migration
    Private access
    Invocation order
    Class structure

    View full-size slide

  63. @yuriy_tymchuk
    When QualityAssistant Meets Pharo
    Enforced Code Critiques Motivate
    More Valuable Rules
    , Mohammad Ghafari, Oscar Nierstrasz
    Software Composition Group @ University of Bern
    Important
    Fixes
    Educational
    Rules Removed
    Domain Rules
    Added
    Migration
    Private access
    Invocation order
    Class structure
    Lazy evaluation

    View full-size slide