41 {
"limiter",
'l',
RequiredArgument,
"Limits the number of results shown to the user. By default, all results are shown."},
42 {
"pattern",
'p',
RequiredArgument,
"Defines a pattern that function names must match to be included in the results. A function is considered a match if the pattern is a substring of the function's concatenated file path and name (e.g., `path/to/file.c:function_name`)."},
43 {
"both-match",
'b',
NoArgument,
"Enable both-pattern matching. By default, the pattern only needs to match one function."},
44 {
"sort",
's',
NoArgument,
"Sort results by number of duplicated lines. By default, results are sorted by the similarity metric."},
45 {
"cluster",
'c',
NoArgument,
"Print results with cluster relationships from the similarity table."},
49 "Explore duplicated functions detected in the project.")
65 static constexpr const
char* TEMPLATE_PROCESSED_RESULTS =
66 "Functions find: {path_a}
"
68 ", TOTAL NUMBER LINES IN FUNCTIONS: {duplicated_lines}
";
69 static constexpr const char* TEMPLATE_PROCESSED_RESULTS_CLUSTERS =
71 ", TOTAL NUMBER LINES IN FUNCTION: {duplicated_lines}
";
72 static constexpr const char* TEMPLATE_INITIAL_TEXT =
73 "It was found a total of {found:bold}
"
74 "pair of duplicate functions in the codebase. Which the first
"
75 "{show:bold} can be found below.
";
77 int INITIAL_PROCESSED_RESULTS = 0; ///< Initial counter for processed results
79 Similarity_Table* similarity_table; ///< Source of similarity data
80 int limit_on_results; ///< Maximum number of results to show
81 std::string pattern_to_match; ///< Pattern to filter results
82 bool both_path_need_to_match_pattern; ///< Whether both paths must match pattern
83 bool sorted_by_number_of_duplicated_code; ///< Whether to sort by line count
84 bool use_clusters; ///< Whether clusters be printed
85 int processed_results = INITIAL_PROCESSED_RESULTS; ///< Counter for processed results
92 int find_number_pairs_show(int number_pair_found) const;
100 bool match_pattern(const Path& path1, const Path& path2) const;
107 static int find_number_lines(const Path& path1);
114 SimilarityExplorerEntry process_similar_path_pair(const Path& path1, const Path& path2);
121 int find_number_pair_found(const std::vector<std::pair<Path, Path>>& similar_path_pairs) const;
127 std::vector<std::pair<Path, Path>> build_similar_path_pairs();
132 void explorer_clusters();