\CodePro Analytix Evaluation\src\com\instantiations\example\miscellaneous\BranchingCode.java
Violations: 1 high, 36 medium, 1 low
 
Violations
Missing file comment Invalid numeric literal: 7 Constant on right side of comparison
Maximum violation count of 20 exceeded for the rule "Numeric Literals" in "/CodePro Analytix Evaluation/src/com/instantiations/example/miscellaneous/BranchingCode.java" Invalid numeric literal: 20 Invalid numeric literal: 7
Missing @version tag for type BranchingCode Invalid numeric literal: 11000 Invalid numeric literal: 20
toString() is missing Invalid numeric literal: 20 Invalid numeric literal: 11002
Missing Javadoc comment for method "primitiveBranch" Invalid numeric literal: 19 Invalid numeric literal: 20
Constant on right side of comparison Invalid numeric literal: 56000 Missing Javadoc comment for method "objectBranch"
Invalid numeric literal: 3 Invalid numeric literal: 20 Constant on right side of comparison
Constant on right side of comparison Invalid numeric literal: 11001 Constant on right side of comparison
Invalid numeric literal: 5 Invalid numeric literal: 20 Constant on right side of comparison
Invalid numeric literal: 17 Invalid numeric literal: 191 Constant on right side of comparison
Constant on right side of comparison Invalid numeric literal: 56001 Constant on right side of comparison
Invalid numeric literal: 5 Constant on right side of comparison Constant on right side of comparison
Constant on right side of comparison Invalid numeric literal: 7    
 
Source
1 package com.instantiations.example.miscellaneous;
2
3 /**
4  * The class <code>BranchingCode</code> demonstrates how the test case generator
5  * can use static analysis of branches within the code to select better values
6  * for method arguments, even when those values are nested within an object.
7  * @author Albert Adams
8  */
9 public class BranchingCode
10 {
11    public static int primitiveBranch(int x, int y, int z)
12    {
13       if (x == 3 && y == 5) {
14          return 17;
15       }
16       if (x == 5) {
17          if (y == 7) {
18             if (z > 20) {
19                return 11000;
20             } else if (z < 20) {
21                return 19;
22             } else {
23                return 56000;
24             }
25          } else {
26             if (z > 20) {
27                return 11001;
28             } else if (z < 20) {
29                return 191;
30             } else {
31                return 56001;
32             }
33          }
34       } else if (x == 7) {
35          if (y == 7) {
36             if (z > 20) {
37                return 11002;
38             } else if (z < 20) {
39                return 12;
40             } else {
41                return 56002;
42             }
43          } else {
44             if (z > 20) {
45                return 11003;
46             } else if (z < 20) {
47                return 13;
48             } else {
49                return 56003;
50             }
51          }
52       }
53       return -1;
54    }
55
56    public static int objectBranch(Point3D point)
57    {
58       if (point.x == 33 && point.y == 35) {
59          return 17;
60       }
61       if (point.x == 35) {
62          if (point.y == 37) {
63             if (point.z > 320) {
64                return 11000;
65             } else if (point.z < 320) {
66                return 19;
67             } else {
68                return 56000;
69             }
70          } else {
71             if (point.z > 320) {
72                return 11001;
73             } else if (point.z < 320) {
74                return 191;
75             } else {
76                return 56001;
77             }
78          }
79       } else if (point.x == 37) {
80          if (point.y == 37) {
81             if (point.z > 320) {
82                return 11002;
83             } else if (point.z < 320) {
84                return 12;
85             } else {
86                return 56002;
87             }
88          } else {
89             if (point.z > 320) {
90                return 11003;
91             } else if (point.z < 320) {
92                return 13;
93             } else {
94                return 56003;
95             }
96          }
97       }
98       return -1;
99    }
100 }
Powered by CodePro AnalytiX