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); }
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: 16 Number of AST nodes: 15
1
for (int i = 0; i < nodeList.getLength(); i++) {
1
Node tempNode = nodeList.item(i);
2
           Node tempNode = nodeList.item(i);
2
			NamedNodeMap nnm = tempNode.getAttributes();
3
           NamedNodeMap nnm = tempNode.getAttributes();
3
			Node namedItem = nnm.getNamedItem("href"); // $NON-NLS-1$
4
           Node namedItem = nnm.getNamedItem("src"); // $NON-NLS-1$
4
			if (namedItem == null) {
5
           if (namedItem == null) {
5
				continue;
6
			}
7
			String hrefStr = namedItem.getNodeValue();
8
			if (hrefStr.startsWith("javascript:")) { // $NON-NLS-1$
9
				continue; // No point trying these
10
			}
11
			try {
12
				
6
               continue;
7
           }
8
           String hrefStr = namedItem.getNodeValue();
9
           try {
13
HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(
10
               HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(
14
hrefStr, new URL(result.getURL(), base));
11
                       hrefStr, new URL(result.getURL(), base));
15
				newUrl.setMethod(HTTPConstants.GET);
12
               newUrl.setMethod(HTTPConstants.GET);
16
				if (log.isDebugEnabled()) {
13
               if (log.isDebugEnabled()) {
17
				    log.debug("Potential <a href> match: " + newUrl);
14
                   log.debug("Potential <frame src> match: " + newUrl);
18
				}
19
				
15
               }
20
if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
16
               if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
21
					log.debug("Matched!");
17
                   log.debug("Matched!");
22
					potentialLinks.add(newUrl);
18
                   potentialLinks.add(newUrl);
23
				}
24
			
19
               }
25
} catch (MalformedURLException e) {
20
           } catch (MalformedURLException e) {
26
	            log.warn("Bad URL "+e);
21
               log.warn("Bad URL "+e);
27
			
22
           }
28
}
23
       }
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.1
Clones locationClones are declared in the same class
Number of node comparisons51
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements14
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)5.1
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    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;
    11
    continue;
    Preondition Violations
    Statement continue; without innermost loop
    Statement continue; without innermost loop
    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 (5)
    Row Violation
    1Statement continue; without innermost loop
    2Statement continue; without innermost loop
    3Unmatched 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
    4Unmatched continue;
    5Clone fragment #1 returns variables hrefStr , while Clone fragment #2 returns variables