Your SlideShare is downloading. ×
Defect prevention software
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Defect prevention software

154
views

Published on

Defect prevention software: set of tools for static analysis of source code and determining software quality metrics for source code

Defect prevention software: set of tools for static analysis of source code and determining software quality metrics for source code

Published in: Technology

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

  • Be the first to like this

No Downloads
Views
Total Views
154
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. DEFECT PREVENTION SOFTWARE• Tools for static analysis of source code: PMD Marker,FindBugs, Metrics Marker• Tools for determining software quality metrics for sourcecode: VizzMaintenance• Tools for UML design critics: ArgoUML• Tools for generating test cases from UML model of your code:SmartestingSee static analysis report sample and software quality metricsfor sample class on following pages…
  • 2. Here is sample CommaHyphenString.java source code1 /**2 *3 * CommaHyphenString parses .properties file. It eliminates commas or low lines4 * from .properties file so items in it( such as categories) could be properly5 * showed on screen6 */7 import java.util.*;89 public class CommaHyphenString {1011 //String s;12 int lastIndex;13 CommaHyphenString(){}141516 /** Eliminates commas, returns array of strings with low line17 * @return String[]18 */19 String[] getWithLowLine(String s) {20 int lastIndex = defineLast(s);21 if(lastIndex==0){22 String[] ss = new String[1];23 ss[0] = s;24 return ss;25 } else {26 int start = -1;27 Vector v = new Vector();28 int current = s.indexOf(,);29 do {30 v.addElement(s.substring(start+1,current));31 start = current;32 current = s.indexOf(,,current+1);33 } while (start!=lastIndex);3435 String[] ss = new String[v.size()+1];36 for(int i=0; i<v.size(); i++){37 ss[i] = (String)v.elementAt(i);38 }
  • 3. 39 ss[v.size()] = s.substring(lastIndex+1,s.length());40 return ss;41 }42 }4344 /** Eliminates low line45 * @return String[]46 */47 String[] getStringsOnly(String s){48 String[] temp = this.getWithLowLine(s);49 for (int i=0; i<temp.length; i++){50 char[] tempChar = temp[i].toCharArray();51 String k = "";52 for (int j=0; j<tempChar.length; j++){53 if(tempChar[j]==_) tempChar[j]= ;54 k+=tempChar[j];55 }56 temp[i] = k;57 }58 return temp;59 }606162 /** Returns categories with low line63 * @return String[]64 */65 String[] getCategoriesHyphen(String s){66 return this.getWithLowLine(s);67 }6869 /** Returns categories70 * @return String[]71 */72 String[] getCategories(String s){73 return this.getStringsOnly(s);74 }7576 /** Defines index of last comma in string77 * @return integer78 */
  • 4. 79 public int defineLast(String s){80 int lastIndex = 0;81 char c[] = s.toCharArray();82 for (int i=0; i<c.length; i++){83 if(c[i]==,) lastIndex=i;84 }85 return lastIndex;86 }8788 }Here are static analysis violations detected in CommaHyphenString.javaDescription of static analysis violation Line ToolAll classes and interfaces must belong to a named package 9 PMD MarkerUnused field: CommaHyphenString.lastIndex 12 FindBugsUse explicit scoping instead of the default package private level 12 PMD MarkerDocument empty constructor 13 PMD MarkerLines of Code in Method is 27 16MetricsMarkerNumber of Statements is 28 16MetricsMarkerAvoid variables with short names like s 19 PMD MarkerParameter s is not assigned and could be declared final 19 PMD MarkerUse explicit scoping instead of the default package private level 19 PMD MarkerLocal variable lastIndex could be declared final 20 PMD MarkerAvoid variables with short names like ss 22 PMD MarkerA method should have only one exit point, and that should be the last statement in themethod 24 PMD MarkerAvoid variables with short names like v 27 PMD MarkerConsider replacing this Vector with the newer java.util.List 27 PMD MarkerLocal variable v could be declared final 27 PMD MarkerUse ArrayList instead of Vector 27 PMD MarkerAvoid variables with short names like ss 35 PMD MarkerLines of Code in Method is 16 44MetricsMarkerAvoid variables with short names like s 47 PMD Marker
  • 5. Parameter s is not assigned and could be declared final 47 PMD MarkerUse explicit scoping instead of the default package private level 47 PMD MarkerAvoid using if statements without curly braces 53 PMD MarkerCommaHyphenString.getStringsOnly(String) concatenates strings using + in a loop 54 FindBugsPrefer StringBuffer over += for concatenating strings 54 PMD MarkerParameter s is not assigned and could be declared final 65 PMD MarkerUse explicit scoping instead of the default package private level 65 PMD MarkerParameter s is not assigned and could be declared final 72 PMD MarkerUse explicit scoping instead of the default package private level 72 PMD MarkerParameter s is not assigned and could be declared final 79 PMD MarkerLocal variable c could be declared final 81 PMD MarkerAvoid using if statements without curly braces 83 PMD MarkerHere are VizzMaintenance software quality metrics for CommaHyphenString.java classClass Name Maintainability CBO CYC_Classes DAC DIT ILCOM LCOM LD LEN LOC LOD_Class MPC NAM NOC NOMCommaHyphenString 0,136637872 0 1 0 0 0 25 0 17 80 0,167 0 6 0 5
  • 6. Here are full names of VizzMaintenance software quality metrics (click on links for details)Complexityo Size Lines of Code (LOC)o Interface Complexity Number of Attributes and Methods (SIZE2) Number Of local Methods (NOM)o Structural Complexity McCabe Cyclomatic Complexity (CC) Weighted Method Count (WMC) Response For a Class (RFC)Architecture and Structureo Inheritance Depth of Inheritance Tree (DIT) Number Of Children (NOC)o Couplingo Afferent Coupling (Ca)
  • 7.  Coupling Between Objects (CBO) Change Dependency Between Classes (CDBC) Change Dependency Of Classes (CDOC) Efferent Coupling (Ce) Coupling Factor (CF) Data Abstraction Coupling (DAC) Instability (I) Locality of Data (LD) Message Passing Coupling (MPC) Package Data Abstraction Coupling (PDAC)o Cohesion Lack of Cohesion in Methods (LCOM) Improvement of LCOM (ILCOM) Tight Class Cohesion (TCC)Design Guidelines and Code Conventionso Documentation Lack Of Documentation (LOD)o Code Conventions
  • 8. Follow me on Facebook pagehttps://www.facebook.com/AutomatedTesting