31 | | We currently have two interface functions in the ri module: search_duplicates/0 |
32 | | and search_duplicates/1. The first uses the default values of the parameters. |
33 | | The second takes a proplist as parameter described above. Both interface |
34 | | function provide information about the progress of the process. The result is |
35 | | the list of clone groups. Every clones are defined by the path of the file and |
36 | | information about the start and end positions (line and column number). |
37 | | An example can be found at the bottom of the page. |
| 31 | ==== Analyser functions ==== |
| 32 | |
| 33 | * search_duplicates/0: uses the default values of the properties. |
| 34 | * search_duplicates/1: takes a proplist as parameter described above. |
| 35 | |
| 36 | Both interface function provide information about the progress of the process. |
| 37 | The result is the list of clone groups. Every clones are defined by the path of |
| 38 | the file and information about the start and end positions (line and column number). |
| 39 | Results are saved. An example can be found at the bottom of the page. |
| 40 | |
| 41 | ==== Result query functions ==== |
| 42 | |
| 43 | ||Function||Parameters||Description||Example|| |
| 44 | ||stored_dupcode_results/0||-||queries all saved results (name and information about the parameters of the analysis)||{{{ri:stored_dupcode_results()}}}|| |
| 45 | ||save_dupcode_result/2||Name::atom() - name associated with the result,[[BR]]Filename::string() - name of the file||saves the given result in the file||{{{ri:save_dupcode_result(temp20120527205412,"result.txt")}}}|| |
| 46 | ||show_dupcode/1||Name::atom() - name associated with the result||lists the result's all clone groupes||{{{ri:show_dupcode(temp20120527205412)}}}|| |
| 47 | ||show_dupcode_group/2||Name::atom() - name associated with the result,[[BR]]GroupNumber::integer() - the required clone group's number||lists the given clone group of the result||{{{ri:show_dupcode_group(temp20120527205412, 2)}}}|| |
68 | | [[[{filepath,"/home/user/dups/dup1.erl"}, |
69 | | {startpos,{15,1}}, |
70 | | {endpos,{17,24}}], |
71 | | [{filepath,"/home/user/dups/dup2.erl"}, |
72 | | {startpos,{5,1}}, |
73 | | {endpos,{7,24}}]], |
74 | | [[{filepath,"/home/user/dups/dup1.erl"}, |
75 | | {startpos,{8,1}}, |
76 | | {endpos,{14,11}}], |
77 | | [{filepath,"/home/user/dups/dup2.erl"}, |
78 | | {startpos,{12,1}}, |
79 | | {endpos,{18,11}}]]] |
| 83 | 2 clone groups found. |
| 84 | Result saved to temp20120527234307... |
| 85 | run ri:show_dupcode(temp20120527234307) to see the result. |
| 86 | ok |
| 87 | |
| 88 | (refactorerl@localhost)4> ri:search_duplicates([{files,[dup1,dup2]}]). |
| 89 | 2 clone groups found. |
| 90 | Result saved to temp20120527234307... |
| 91 | run ri:show_dupcode(temp20120527234307) to see the result. |
| 92 | ok |
| 94 | |
| 95 | === Result query functions === |
| 96 | |
| 97 | {{{#!erlang |
| 98 | (refactorerl@localhost)5> ri:stored_dupcode_results(). |
| 99 | [[temp20120527234307, |
| 100 | [{files,[{"/home/user/dups/dup1.erl", |
| 101 | 112018930}, |
| 102 | {"/home/user/dups/dup2.erl", |
| 103 | 96559118}]}, |
| 104 | {minlen,10}, |
| 105 | {minnum,2}, |
| 106 | {overlap,0}]], |
| 107 | [temp20120527235556, |
| 108 | [{files,[{"/usr/local/lib/erlang/lib/mnesia-4.5/src/mnesia_schema.erl", |
| 109 | 101394176}]}, |
| 110 | {minlen,20}, |
| 111 | {minnum,3}, |
| 112 | {overlap,0}]]] |
| 113 | }}} |
| 114 | |
| 115 | {{{#!erlang |
| 116 | (refactorerl@localhost)17> ri:show_dupcode(temp20120527234307). |
| 117 | [{1, |
| 118 | [[{filepath,"/home/user/dups/dup1.erl"}, |
| 119 | {startpos,{8,1}}, |
| 120 | {endpos,{18,11}}], |
| 121 | [{filepath,"/home/user/dups/dup2.erl"}, |
| 122 | {startpos,{5,1}}, |
| 123 | {endpos,{15,11}}]]}, |
| 124 | {2, |
| 125 | [[{filepath,"/home/user/dups/dup1.erl"}, |
| 126 | {startpos,{6,5}}, |
| 127 | {endpos,{6,62}}], |
| 128 | [{filepath,"/home/user/dups/dup2.erl"}, |
| 129 | {startpos,{18,5}}, |
| 130 | {endpos,{18,58}}]]}] |
| 131 | Contains 2 clone groups... |
| 132 | run ri:show_dupcode_group(temp20120527234307, GroupNumber::integer()) to see one of the clone groups. |
| 133 | ok |
| 134 | }}} |
| 135 | |
| 136 | {{{#!erlang |
| 137 | (refactorerl@localhost)16> ri:show_dupcode_group(temp20120527234307,2). |
| 138 | [[{filepath,"/home/user/dups/dup1.erl"}, |
| 139 | {startpos,{6,5}}, |
| 140 | {endpos,{6,62}}], |
| 141 | [{filepath,"/home/user/dups/dup2.erl"}, |
| 142 | {startpos,{18,5}}, |
| 143 | {endpos,{18,58}}]] |
| 144 | Contains 2 members. |
| 145 | ok |
| 146 | }}} |