Training material sonar v1

1,215 views
1,048 views

Published on

Presentation on Sonar

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

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

No notes for slide
  • Blocker = number of PMD blocker issuesCritical = number of PMD critical issuesMajor = number of PMD major issuesMinor = number of PMD minor issuesInfo = number of PMD info issues
  • Blocker = number of PMD blocker issuesCritical = number of PMD critical issuesMajor = number of PMD major issuesMinor = number of PMD minor issuesInfo = number of PMD info issues
  • Blocker = number of PMD blocker issuesCritical = number of PMD critical issuesMajor = number of PMD major issuesMinor = number of PMD minor issuesInfo = number of PMD info issuesCyclomatic ComplexityThe Cyclomatic Complexity is measured by the number of (&&, ||) operators and (if, while, do, for, ?:, catch, switch, case, return, throw) statements in the body of a class plus one for each constructor, method (but not getter/setter), static initializer, or instance initializer in the class. The last return stament in method, if exists, is not taken into account.Even when the Cyclomatic Complexity of a class is very high, this complexity might be well distributed among all methods. Nevertheless, most of the time, a very complex class is a class which breaks the Single Responsibility Principle and which should be re-factored to be split in several classes.
  • Blocker = number of PMD blocker issuesCritical = number of PMD critical issuesMajor = number of PMD major issuesMinor = number of PMD minor issuesInfo = number of PMD info issues
  • Blocker = number of PMD blocker issuesCritical = number of PMD critical issuesMajor = number of PMD major issuesMinor = number of PMD minor issuesInfo = number of PMD info issues
  • Training material sonar v1

    1. 1. Training Material Sonar 11th October 2013 By Shinu Suresh
    2. 2. Agenda • Introduction • Sonar Portal • Statistics • Navigation • Violations
    3. 3. Introduction • A platform to manage code quality • Free, Open source, LGPL web based portal • Aggregates will know Code Review tools • Static Analysis – PMD, Findbugs, Checkstyle • Duplicate Code – (Squid, CPD) • Code Coverage – (Cobertura, JaCoCo) • Easy to integrate with Jenkins build
    4. 4. Sonar Portal
    5. 5. Sonar Basic Statistics
    6. 6. Quality Index • Derived based on 4 pillars Quality Index = 10 - 4.5 * Coding - 2 * Complexity - 2 * Coverage - 1.5 * Style • Coding • Checks for PMD compliance. Rule applied is Coding = (Blocker * 10 + Critical * 5 + Major * 3 + Minor + Info) / (Lines of Code - Duplicated Lines) • Complexity • Checks for method complexities. Rule applied is Complexity = (Complexity>30 * 10 + Complexity>20 * 5 + Complexity>10 * 3 + Complexity>1) / (Lines of Code - Duplicated Lines) • Coverage • Coverage of Unit Tests • Style • Check style compliance index. Rule applied is Style = (Errors * 10 + Warnings) / (Lines of Code - Duplicated Lines) * 10
    7. 7. Size Metrics • Lines of Code • Classes • Packages • Methods • Accessors
    8. 8. Complexity • Cyclomatic Complexity • Method • Class • File Complexities over 10 will be flagged
    9. 9. Rules Compliance • Issues • Rules Compliance • Issue Types
    10. 10. Duplications • Analyses duplications with in • Class File • Project • Multiple Projects
    11. 11. Navigation
    12. 12. Navigating to Issue Drill down
    13. 13. Navigating to Specific file
    14. 14. Violations
    15. 15. Violations - Examples
    16. 16. Violations – Examples Cont
    17. 17. Managing Violations • For Each violation You Can • • • • • Comment Change its severity Declare it as a false-positive Assign it to someone Assign it to an action plan
    18. 18. Unresolved issues in Project
    19. 19. What now • What to Start With • Check violations for your project • Remove duplicate code • Improve test coverage

    ×