Arkanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
duplication_finder_tool.cpp
Go to the documentation of this file.
3
4using fm = FormatterManager;
5
6DuplicationFinderTool::DuplicationFinderTool(const fs::path& base_path_, double similarity_) {
7 base_path = base_path_;
8 similarity = similarity_;
9}
10
12 fs::path output_parsed = base_path / "output_parsed.txt";
13
14 std::string command_tool = "python3 -W ignore ";
15 command_tool += Config::config().third_party_dir;
16 command_tool += "/duplicate-code-detection-tool/duplicate_code_detection.py -d ";
17 command_tool += base_path / "source";
18
19 fm::write(SAVING_MESSAGE);
20
21 FILE* pipe = popen(command_tool.c_str(), "r");
22 if (!pipe) {
23 cerr << "Error executing the tool.\n";
24 return;
25 }
26
27 Parser parser(output_parsed, similarity);
28 parser.exec_from_stream(pipe);
29
30 pclose(pipe);
31}
static Config & config()
Gets the singleton configuration instance.
Definition config.cpp:37
fs::path third_party_dir
Directory containing third-party dependencies.
Definition config.hpp:43
void execute()
Executes the full duplication analysis pipeline.
DuplicationFinderTool(const fs::path &base_path_, double similarity_)
Constructs the duplication finder tool.
static void write(const std::string &template_str, const std::vector< T > &data, enum Format effective=Format::AUTO, RowColorFn color_fn=nullptr, std::ostream &out=std::cout)
Parses and transforms duplication detection tool output.
Definition parser.hpp:70
void exec_from_stream(FILE *pipe)
Main parsing execution method using stream.
Definition parser.cpp:90
Main duplication detection tool interface.