Arkanjo 0.1
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
counter_duplication_code.cpp
Go to the documentation of this file.
2
3void Counter_Duplication_Code::mark_path_as_processed(Path path){
4 processed_paths.insert(path);
5}
6
7bool Counter_Duplication_Code::is_path_processed_path(Path path){
8 return processed_paths.find(path) != processed_paths.end();
9}
10
11int Counter_Duplication_Code::get_number_of_lines_in_path(Path path){
12 Function function(path);
13 return function.number_of_lines();
14}
15
16void Counter_Duplication_Code::register_code_duplication(Path path1, Path path2, int number_of_lines){
17 vector<string> common_folder_path = path1.get_common_folders(path2);
18 counter_duplication_code_trie.add_folder_duplication_code(common_folder_path, number_of_lines);
19}
20
21void Counter_Duplication_Code::process_path(Path path){
22 if(is_path_processed_path(path)){
23 return;
24 }
25 int number_of_lines = get_number_of_lines_in_path(path);
26 mark_path_as_processed(path);
27 vector<Path> similar_paths = similarity_table->get_similar_path_to_the_reference(path);
28 for(auto similar_path : similar_paths){
29 mark_path_as_processed(similar_path);
30 register_code_duplication(path, similar_path, number_of_lines);
31 }
32}
33
34void Counter_Duplication_Code::process_every_path_in_similarity_table(){
35 vector<Path> paths = similarity_table->get_path_list();
36 for(auto path : paths){
37 process_path(path);
38 }
39}
40
42 similarity_table = _similarity_table;
43 process_every_path_in_similarity_table();
44 counter_duplication_code_trie.print_duplication_code_trie();
45}
void print_duplication_code_trie()
Prints the trie structure with duplication counts.
void add_folder_duplication_code(vector< string > folder_path, int number_of_duplication_lines)
Adds duplication count for a folder path.
Counter_Duplication_Code(Similarity_Table *_similarity_table)
Constructs analyzer with similarity data.
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
vector< string > get_common_folders(Path path)
Finds common folders with another path.
Definition path.cpp:130
Manages and analyzes function similarity relationships.
vector< Path > get_path_list()
Gets list of all known paths.
vector< Path > get_similar_path_to_the_reference(Path reference)
Gets paths similar to reference path.
Code duplication reporting system.