28namespace fs = std::filesystem;
31 const std::string&,
float,
const std::vector<std::string>&
54 static constexpr const char* TEMPLATE_COUNT =
55 "The total number of functions that are "
56 "similar to the found one is {count}. "
57 "More info about them are listed below.";
59 static constexpr const char* PROJECT_PATH_MESSAGE =
"Enter your project path:";
60 static constexpr const char* MINIMUM_SIMILARITY_MESSAGE =
"Enter minimum similarity desired on using the tool:";
63 static constexpr const char* INITIAL_MESSAGE =
"Initiating Preprocessing";
64 static constexpr const char* BREAKER_MESSAGE =
"Reading codebase... (this may take a while)";
65 static constexpr const char* DUPLICATION_MESSAGE =
"Finding duplication in the codebase... (this may take a while)";
66 static constexpr const char* SAVING_MESSAGE =
"Saving results...";
67 static constexpr const char* END_MESSAGE =
"Finished preprocessing";
68 static constexpr const char* ERROR_PATH_MESSAGE =
"Provided path does not exist.";
71 static constexpr const char* MESSAGE_DUPLICATION_FINDER_TYPE =
"Enter the number of the duplication finder technique you want to use:";
72 static constexpr const char* INVALID_CODE_DUPLICATION_FINDER =
"Invalid option entered. Stopping Program...";
74 bool mode_verbose =
false;
75 int minimum_lines = 0;
77 const std::vector<MethodInfo> MethodsType = {
81 [](
const std::string& base_path,
float similarity,
82 const std::vector<std::string>&) {
83 return std::make_unique<TfidfMethod>(base_path, similarity);
85 "NLP text similarity using gensim"
90 [](
const std::string& base_path,
float similarity,
91 const std::vector<std::string>&) {
92 return std::make_unique<DiffMethod>(base_path, similarity);
94 "Count proportion of equal lines using diff command"
99 [](
const std::string& base_path,
float similarity,
100 const std::vector<std::string>&) {
101 return std::make_unique<ASTMethod>(base_path, similarity);
103 "Compare linearized structural sequences extracted from Tree-sitter ASTs"
108 [](
const std::string& base_path,
float similarity,
109 const std::vector<std::string>& pass_through_args) {
110 return std::make_unique<EmbeddingMethod>(base_path, similarity, pass_through_args);
112 "Embedding-based similarity using a code language model"
126 std::tuple<std::string, double, size_t, std::vector<std::string>,
Granularity>
137 void preprocess(
const fs::path& path,
double similarity,
size_t use_duplication_finder_index,
138 const std::vector<std::string>& pass_through_args = {},
143 {
"verbose", 0,
NoArgument,
"Enable verbose output"},
145 {
"minimum-lines", 0,
RequiredArgument,
"Minimum clone size in original lines."},
147 "Comparison granularity: 'function' (default) compares individual "
148 "functions; 'file' keeps each file whole and compares files against "
149 "each other. Applies to every duplication finder method."},
151 "Duplication finder method: 1|tfidf, 2|diff, 3|ast, 4|embedding."},
164 PreprocessorBuild(
bool force_preprocess,
const fs::path& path,
double similarity);
166 COMMAND_DESCRIPTION(
"Creates the foundation for fast query responses during the main operation phase.")
const CliOption * options() const final
Codebase preprocessing orchestrator.
static constexpr CliOption options_[]
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
PreprocessorBuild()=default
bool run(const ParsedOptions &options) override
Executes the main logic of the command.
#define COMMAND_DESCRIPTION(str)
Code duplication preprocessing system.
LLM-embedding-based code duplication detection.
Main function extraction interface.
Granularity
Comparison granularity used when breaking the codebase.
#define OPTION_END
This marks the end of a long array of options.
std::function< std::unique_ptr< IMethod >(const std::string &, float, const std::vector< std::string > &)> MethodFactory
std::string_view description
Main duplication detection tool interface.