String base = ""; NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$ if (baseList.getLength() > 0) { base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue(); // $NON-NLS-1$ } NodeList nodeList = html.getElementsByTagName("a"); // $NON-NLS-1$ for (int i = 0; i < nodeList.getLength(); i++) { Node tempNode = nodeList.item(i); NamedNodeMap nnm = tempNode.getAttributes(); Node namedItem = nnm.getNamedItem("href"); // $NON-NLS-1$ if (namedItem == null) { continue; } String hrefStr = namedItem.getNodeValue(); if (hrefStr.startsWith("javascript:")) { // $NON-NLS-1$ continue; // No point trying these } try { HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(hrefStr, new URL(result.getURL(), base)); newUrl.setMethod(HTTPConstants.GET); if (log.isDebugEnabled()) { log.debug("Potential <a href> match: " + newUrl); } if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) { log.debug("Matched!"); potentialLinks.add(newUrl); } } catch (MalformedURLException e) { log.warn("Bad URL "+e); } }
String base = ""; NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$ if (baseList.getLength() > 0) { base = baseList.item(0).getAttributes().getNamedItem("href") // $NON-NLS-1$ .getNodeValue(); } NodeList nodeList = html.getElementsByTagName("frame"); // $NON-NLS-1$ for (int i = 0; i < nodeList.getLength(); i++) { Node tempNode = nodeList.item(i); NamedNodeMap nnm = tempNode.getAttributes(); Node namedItem = nnm.getNamedItem("src"); // $NON-NLS-1$ if (namedItem == null) { continue; } String hrefStr = namedItem.getNodeValue(); try { HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor( hrefStr, new URL(result.getURL(), base)); newUrl.setMethod(HTTPConstants.GET); if (log.isDebugEnabled()) { log.debug("Potential <frame src> match: " + newUrl); } if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) { log.debug("Matched!"); potentialLinks.add(newUrl); } } catch (MalformedURLException e) { log.warn("Bad URL "+e); } }
Clone fragments detected by clone detection tool
File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java File path: /jakarta-jmeter-2.3.2/src/org/apache/jmeter/protocol/http/modifier/AnchorModifier.java
Method name: void addAnchorUrls(Document, HTTPSampleResult, HTTPSamplerBase, List) Method name: void addFramesetUrls(Document, HTTPSampleResult, HTTPSamplerBase, List)
Number of AST nodes: 22 Number of AST nodes: 20
1
String base = "";
1
String base = "";
2
		NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$
2
       NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$
3
		if (baseList.getLength() > 0) {
3
       if (baseList.getLength() > 0) {
4
			base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue(); // $NON-NLS-1$
4
           base = baseList.item(0).getAttributes().getNamedItem("href")
5
		}
6
		
5
 // $NON-NLS-1$
6
                   .getNodeValue();
7
       }
7
NodeList nodeList = html.getElementsByTagName("a"); // $NON-NLS-1$
8
       NodeList nodeList = html.getElementsByTagName("frame"); // $NON-NLS-1$
8
		for (int i = 0; i < nodeList.getLength(); i++) {
9
       for (int i = 0; i < nodeList.getLength(); i++) {
9
			Node tempNode = nodeList.item(i);
10
           Node tempNode = nodeList.item(i);
10
			NamedNodeMap nnm = tempNode.getAttributes();
11
           NamedNodeMap nnm = tempNode.getAttributes();
11
			Node namedItem = nnm.getNamedItem("href"); // $NON-NLS-1$
12
           Node namedItem = nnm.getNamedItem("src"); // $NON-NLS-1$
12
			if (namedItem == null) {
13
           if (namedItem == null) {
13
				continue;
14
			}
15
			String hrefStr = namedItem.getNodeValue();
16
			if (hrefStr.startsWith("javascript:")) { // $NON-NLS-1$
17
				continue; // No point trying these
18
			}
19
			try {
20
				
14
               continue;
15
           }
16
           String hrefStr = namedItem.getNodeValue();
17
           try {
21
HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(
18
               HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(
22
hrefStr, new URL(result.getURL(), base));
19
                       hrefStr, new URL(result.getURL(), base));
23
				newUrl.setMethod(HTTPConstants.GET);
20
               newUrl.setMethod(HTTPConstants.GET);
24
				if (log.isDebugEnabled()) {
21
               if (log.isDebugEnabled()) {
25
				    log.debug("Potential <a href> match: " + newUrl);
22
                   log.debug("Potential <frame src> match: " + newUrl);
26
				}
27
				
23
               }
28
if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
24
               if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
29
					log.debug("Matched!");
25
                   log.debug("Matched!");
30
					potentialLinks.add(newUrl);
26
                   potentialLinks.add(newUrl);
31
				}
32
			
27
               }
33
} catch (MalformedURLException e) {
28
           } catch (MalformedURLException e) {
34
	            log.warn("Bad URL "+e);
29
               log.warn("Bad URL "+e);
35
			}
36
		
30
           }
37
}
31
       }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)1.3
Clones locationClones are declared in the same class
Number of node comparisons72
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements20
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)6.6
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    String base = "";
    1
    String base = "";
    2
    NodeList baseList = html.getElementsByTagName("base");
    2
    NodeList baseList = html.getElementsByTagName("base");
    3
    if (baseList.getLength() > 0)
    3
    if (baseList.getLength() > 0)
    4
    base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue();
    4
    base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue();
    5
    NodeList nodeList = html.getElementsByTagName("a");
    5
    NodeList nodeList = html.getElementsByTagName("a");
    5
    NodeList nodeList = html.getElementsByTagName("frame");
    Differences
    Expression1Expression2Difference
    "a""frame"LITERAL_VALUE_MISMATCH
    5
    NodeList nodeList = html.getElementsByTagName("frame");
    6
    for (int i = 0; i < nodeList.getLength(); i++)
    6
    for (int i = 0; i < nodeList.getLength(); i++)
    7
    Node tempNode = nodeList.item(i);
    7
    Node tempNode = nodeList.item(i);
    8
    NamedNodeMap nnm = tempNode.getAttributes();
    8
    NamedNodeMap nnm = tempNode.getAttributes();
    9
    Node namedItem = nnm.getNamedItem("href");
    9
    Node namedItem = nnm.getNamedItem("href");
    9
    Node namedItem = nnm.getNamedItem("src");
    Differences
    Expression1Expression2Difference
    "href""src"LITERAL_VALUE_MISMATCH
    9
    Node namedItem = nnm.getNamedItem("src");
    10
    if (namedItem == null)
    10
    if (namedItem == null)
    11
    continue;
    11
    continue;
    12
    String hrefStr = namedItem.getNodeValue();
    12
    String hrefStr = namedItem.getNodeValue();
    13
    if (hrefStr.startsWith("javascript:"))
    13
    if (hrefStr.startsWith("javascript:"))
    Preondition Violations
    Unmatched statement if(hrefStr.startsWith("javascript:")) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                      
    14
    continue;
    14
    continue;
    Preondition Violations
    Unmatched continue;
                              
    15
    try
    13
    try
    16
    HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(hrefStr, new URL(result.getURL(), base));
    14
    HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(hrefStr, new URL(result.getURL(), base));
    17
    newUrl.setMethod(HTTPConstants.GET);
    15
    newUrl.setMethod(HTTPConstants.GET);
    18
    if (log.isDebugEnabled())
    16
    if (log.isDebugEnabled())
    19
    log.debug("Potential <a href> match: " + newUrl);
    19
    log.debug("Potential <a href> match: " + newUrl);
    17
    log.debug("Potential <frame src> match: " + newUrl);
    Differences
    Expression1Expression2Difference
    "Potential match: ""Potential match: "LITERAL_VALUE_MISMATCH
    17
    log.debug("Potential <frame src> match: " + newUrl);
    20
    if (HtmlParsingUtils.isAnchorMatched(newUrl, config))
    18
    if (HtmlParsingUtils.isAnchorMatched(newUrl, config))
    21
    log.debug("Matched!");
    19
    log.debug("Matched!");
    22
    potentialLinks.add(newUrl);
    20
    potentialLinks.add(newUrl);
    Precondition Violations (3)
    Row Violation
    1Unmatched statement if(hrefStr.startsWith("javascript:")) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched continue;
    3Clone fragment #1 returns variables hrefStr , while Clone fragment #2 returns variables