File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/MenuFactory.java | File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/gui/util/ReportMenuFactory.java | |||
Method name: void initializeMenus()
|
Method name: void initializeMenus()
|
|||
Number of AST nodes: 36 | Number of AST nodes: 34 | |||
1 | while (iter.hasNext()) {↵ | 1 | while (iter.hasNext()) {↵ | |
2 | String name = (String) iter.next();↵ | 2 | String name = (String) iter.next();↵ | |
3 | /*↵ | 3 | /*↵ | |
4 | * JMeterTreeNode and TestBeanGUI are special GUI classes, and↵ | 4 | * JMeterTreeNode and TestBeanGUI are special GUI classes, and↵ | |
5 | * aren't intended to be added to menus↵ | 5 | * aren't intended to be added to menus↵ | |
6 | * ↵ | 6 | * ↵ | |
7 | * TODO: find a better way of checking this↵ | 7 | * TODO: find a better way of checking this↵ | |
8 | */↵ | 8 | */↵ | |
9 | if (name.endsWith("JMeterTreeNode") // $NON-NLS-1$↵ | 9 | if (name.endsWith("JMeterTreeNode")↵ | |
10 | || name.endsWith("TestBeanGUI")) {// $NON-NLS-1$↵ | 10 | || name.endsWith("TestBeanGUI")) {↵ | |
11 | continue;// Don't try to instantiate these↵ | 11 | continue;// Don't try to instantiate these↵ | |
12 | }↵ | 12 | }↵ | |
13 | JMeterGUIComponent item;↵ | 13 | JMeterGUIComponent item;↵ | |
14 | try {↵ | 14 | try {↵ | |
15 | Class c = Class.forName(name);↵ | 15 | Class c = Class.forName(name);↵ | |
16 | if (TestBean.class.isAssignableFrom(c)) {↵ | 16 | if (TestBean.class.isAssignableFrom(c)) {↵ | |
17 | item = new TestBeanGUI(c);↵ | 17 | item = new TestBeanGUI(c);↵ | |
18 | } else {↵ | 18 | } else {↵ | |
19 | item = (JMeterGUIComponent) c.newInstance();↵ | 19 | item = (JMeterGUIComponent) c.newInstance();↵ | |
20 | }↵ | 20 | }↵ | |
21 | } catch (NoClassDefFoundError e) {↵ | 21 | } catch (NoClassDefFoundError e) {↵ | |
22 | log.warn("Missing jar? Could not create " + name + ". " + e);↵ | 22 | log.warn("Missing jar? Could not create " + name + ". " + e);↵ | |
23 | continue;↵ | 23 | continue;↵ | |
24 | } catch (Throwable e) {↵ | 24 | } catch (Throwable e) {↵ | |
25 | log.warn("Could not instantiate " + name, e);↵ | 25 | log.warn("Could not instantiate " + name, e);↵ | |
26 | continue;↵ | 26 | continue;↵ | |
27 | }↵ | 27 | }↵ | |
28 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) {↵ | 28 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) {↵ | |
29 | log.info("Skipping " + name);↵ | 29 | log.info("Skipping " + name);↵ | |
30 | continue;↵ | 30 | continue;↵ | |
31 | } else {↵ | 31 | } else {↵ | |
32 | elementsToSkip.add(name);↵ | 32 | elementsToSkip.add(name);↵ | |
33 | }↵ | 33 | }↵ | |
34 | Collection categories = item.getMenuCategories();↵ | 34 | Collection categories = item.getMenuCategories();↵ | |
35 | if (categories == null) {↵ | 35 | if (categories == null) {↵ | |
36 | log.debug(name + " participates in no menus.");↵ | 36 | log.debug(name + " participates in no menus.");↵ | |
37 | continue;↵ | 37 | continue;↵ | |
38 | } ↵ | 38 | } ↵ | |
39 | if (categories.contains(TIMERS)) {↵ | |||
40 | timers.add(new MenuInfo(item.getStaticLabel(), name));↵ | |||
41 | } ↵ | |||
42 | if (categories.contains(POST_PROCESSORS)) {↵ | 39 | if (categories.contains(POST_PROCESSORS)) {↵ | |
43 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | 40 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
44 | }↵ | 41 | }↵ | |
45 | if (categories.contains(PRE_PROCESSORS)) {↵ | 42 | if (categories.contains(PRE_PROCESSORS)) {↵ | |
46 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | 43 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
47 | }↵ | 44 | }↵ | |
48 | if (categories.contains(CONTROLLERS)) {↵ | 45 | if (categories.contains(CONTROLLERS)) {↵ | |
49 | controllers.add(new MenuInfo(item.getStaticLabel(), name));↵ | 46 | controllers.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
50 | }↵ | 47 | }↵ | |
51 | if (categories.contains(SAMPLERS)) {↵ | |||
52 | samplers.add(new MenuInfo(item.getStaticLabel(), name));↵ | |||
53 | }↵ | |||
54 | if (categories.contains(NON_TEST_ELEMENTS)) {↵ | 48 | if (categories.contains(NON_TEST_ELEMENTS)) {↵ | |
55 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | 49 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
56 | }↵ | 50 | }↵ | |
57 | if (categories.contains(LISTENERS)) {↵ | 51 | if (categories.contains(LISTENERS)) {↵ | |
58 | listeners.add(new MenuInfo(item.getStaticLabel(), name));↵ | 52 | listeners.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
59 | }↵ | 53 | }↵ | |
60 | if (categories.contains(CONFIG_ELEMENTS)) {↵ | 54 | if (categories.contains(CONFIG_ELEMENTS)) {↵ | |
61 | configElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | 55 | configElements.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
62 | }↵ | 56 | }↵ | |
57 | if (categories.contains(TABLES)) {↵ | |||
58 | tables.add(new MenuInfo(item.getStaticLabel(), name));↵ | |||
59 | }↵ | |||
63 | if (categories.contains(ASSERTIONS)) {↵ | 60 | if (categories.contains(REPORT_PAGE)) {↵ | |
64 | assertions.add(new MenuInfo(item.getStaticLabel(), name));↵ | 61 | reportPage.add(new MenuInfo(item.getStaticLabel(), name));↵ | |
65 | }↵ | 62 | }↵ | |
66 | } | 63 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 9.5 |
Clones location | Clones are in different classes |
Number of node comparisons | 286 |
Number of mapped statements | 34 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 375.5 |
Clone type | Type 3 |
ID | Statement | ID | Statement | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
23 | while (iter.hasNext()) | 21 | while (iter.hasNext()) | |||||||||||
24 | String name = (String)iter.next(); | 22 | String name = (String)iter.next(); | |||||||||||
25 | if (name.endsWith("JMeterTreeNode") || name.endsWith("TestBeanGUI")) | 23 | if (name.endsWith("JMeterTreeNode") || name.endsWith("TestBeanGUI")) | |||||||||||
26 | continue; | 24 | continue; | |||||||||||
27 | JMeterGUIComponent item; | 25 | JMeterGUIComponent item; | |||||||||||
28 | try | 26 | try | |||||||||||
29 | Class c = Class.forName(name); | 27 | Class c = Class.forName(name); | |||||||||||
30 | if (TestBean.class.isAssignableFrom(c)) | 28 | if (TestBean.class.isAssignableFrom(c)) | |||||||||||
31 | item = new TestBeanGUI(c); | 29 | item = new TestBeanGUI(c); | |||||||||||
else | else | |||||||||||||
32 | item = (JMeterGUIComponent)c.newInstance(); | 30 | item = (JMeterGUIComponent)c.newInstance(); | |||||||||||
33 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) | 31 | if (elementsToSkip.contains(name) || elementsToSkip.contains(item.getStaticLabel())) | |||||||||||
34 | log.info("Skipping " + name); | 32 | log.info("Skipping " + name); | |||||||||||
35 | continue; | 33 | continue; | |||||||||||
else | else | |||||||||||||
36 | elementsToSkip.add(name); | 34 | elementsToSkip.add(name); | |||||||||||
37 | Collection categories = item.getMenuCategories(); | 35 | Collection categories = item.getMenuCategories(); | |||||||||||
38 | if (categories == null) | 36 | if (categories == null) | |||||||||||
39 | log.debug(name + " participates in no menus."); | 37 | log.debug(name + " participates in no menus."); | |||||||||||
40 | continue; | 38 | continue; | |||||||||||
41 | if (categories.contains(TIMERS)) |
| 39 | if (categories.contains(POST_PROCESSORS)) | ||||||||||
42 | timers.add(new MenuInfo(item.getStaticLabel(), name)); |
| 40 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
43 | if (categories.contains(POST_PROCESSORS)) |
| 41 | if (categories.contains(PRE_PROCESSORS)) | ||||||||||
44 | postProcessors.add(new MenuInfo(item.getStaticLabel(), name)); |
| 42 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
45 | if (categories.contains(PRE_PROCESSORS)) |
| 43 | if (categories.contains(CONTROLLERS)) | ||||||||||
46 | preProcessors.add(new MenuInfo(item.getStaticLabel(), name)); |
| 44 | controllers.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
47 | if (categories.contains(CONTROLLERS)) |
| 45 | if (categories.contains(NON_TEST_ELEMENTS)) | ||||||||||
48 | controllers.add(new MenuInfo(item.getStaticLabel(), name)); |
| 46 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
49 | if (categories.contains(SAMPLERS)) |
| 47 | if (categories.contains(LISTENERS)) | ||||||||||
50 | samplers.add(new MenuInfo(item.getStaticLabel(), name)); |
| 48 | listeners.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
51 | if (categories.contains(NON_TEST_ELEMENTS)) |
| 49 | if (categories.contains(CONFIG_ELEMENTS)) | ||||||||||
52 | nonTestElements.add(new MenuInfo(item.getStaticLabel(), name)); |
| 50 | configElements.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
53 | if (categories.contains(LISTENERS)) |
| 51 | if (categories.contains(TABLES)) | ||||||||||
54 | listeners.add(new MenuInfo(item.getStaticLabel(), name)); |
| 52 | tables.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
55 | if (categories.contains(CONFIG_ELEMENTS)) |
| 53 | if (categories.contains(REPORT_PAGE)) | ||||||||||
56 | configElements.add(new MenuInfo(item.getStaticLabel(), name)); |
| 54 | reportPage.add(new MenuInfo(item.getStaticLabel(), name)); | ||||||||||
57 | if (categories.contains(ASSERTIONS)) |
| | |||||||||||
58 | assertions.add(new MenuInfo(item.getStaticLabel(), name)); |
| |
Row | Violation |
---|---|
1 | Unmatched statement if(categories.contains(ASSERTIONS)) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement assertions.add(new MenuInfo(item.getStaticLabel(),name)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |