Arkanjo 0.1
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
big_clone_formater.cpp
Go to the documentation of this file.
2
3string Big_Clone_Formater::format_relative_path(string relative_path){
4 for(auto &c : relative_path){
5 if(c == '/'){
6 c = ',';
7 }
8 }
9 return relative_path;
10}
11
12string Big_Clone_Formater::build_path_formated_string(Path path){
13 string relative_path = path.build_relative_path();
14 relative_path = format_relative_path(relative_path);
15
16 Function function(path);
17 auto [line_declaration,start_line,end_line] = function.get_scope_function_in_file();
18
19 string ret;
20 ret += relative_path;
21 ret += ',' + to_string(line_declaration);
22 ret += ',' + to_string(start_line);
23 ret += ',' + to_string(end_line);
24
25 return ret;
26}
27auto Big_Clone_Formater::process_similar_path_pair(Path path1, Path path2, double similarity){
28 auto string_path1 = build_path_formated_string(path1);
29 auto string_path2 = build_path_formated_string(path2);
30
31 string comparation_string = string_path1 + ',' + string_path2 + ',';
32 cout << comparation_string;
33 cout << fixed << setprecision(2) << similarity << '\n';
34}
35
37 auto similar_paths = similarity_table->get_all_path_pairs_and_similarity_sorted_by_similarity();
38 for(auto [similarity,path1,path2] : similar_paths){
39 process_similar_path_pair(path1,path2,similarity);
40 }
41}
BigCloneEval format conversion interface.
Big_Clone_Formater(Similarity_Table *similarity_table)
Constructs formatter and processes similarity table.
Represents a code function with its content and metadata.
Definition function.hpp:33
Path manipulation class for tool-specific directory structure.
Definition path.hpp:27
string build_relative_path()
Builds relative path portion.
Definition path.cpp:112
Manages and analyzes function similarity relationships.
vector< tuple< double, Path, Path > > get_all_path_pairs_and_similarity_sorted_by_similarity()
Gets all similar path pairs with scores, sorted.
return ret
Definition sum.c:3
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition json.hpp:25317