Arkanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
similar_function_finder.hpp
Go to the documentation of this file.
1
12#pragma once
13
14#include <string>
15#include <vector>
16
18#include <arkanjo/base/path.hpp>
21
24
31class SimilarFunctionFinder : public CommandBase<SimilarFunctionFinder> {
32 static constexpr const char* TEMPLATE_EMPTY_FUNCTION =
33 "There is no functions that resembles the "
34 "name: {pattern:function}\n"
35 "Value incorrected passed or there is no "
36 "duplication code with this function";
37 static constexpr const char* TEMPLATE_COUNT =
38 "The total number of functions that are "
39 "similar to the found one is {count}. "
40 "More info about them are listed below.";
41 static constexpr const char* REFERENCE_PATH_MESSAGE = "The following function was found:";
42
43 Similarity_Table* similarity_table;
44 std::string function_pattern;
45 bool open_folder;
46 bool show_mode;
47 bool no_numbers;
48 Path path;
49
53 void find_path_that_meets_pattern();
54
58 void print_empty_path_message() const;
59
64 Function get_reference_function(const Path& path) const;
65
69 void print_reference_path();
70
75 void print_similar_functions(const std::vector<Path>& similar_paths);
76
80 void print_similar_functions();
81
82 void handle_show_mode();
83
84 public:
85 static constexpr CliOption options_[] = {
86 {"function_name", 0, PositionalArgument, "The tool will match the parameter with any function that has the `FUNCTION_NAME` as a substring."},
87 {"open", 'o', NoArgument, "Open the folder where the function is located."},
88 {"show", 's', NoArgument, "Show detailed information and the full source code of the function."},
89 {"no-numbers", 0, NoArgument, "Hide line numbers in the displayed source code."},
91 };
92 COMMAND_DESCRIPTION("Search for functions using a substring match.")
93
94
99 explicit SimilarFunctionFinder(Similarity_Table* _similarity_table);
100
101 bool validate(const ParsedOptions& options) override;
102
106 bool run(const ParsedOptions& options) override;
107};
const CliOption * options() const final
Represents a code function with its content and metadata.
Definition function.hpp:30
Path manipulation class for tool-specific directory structure.
Definition path.hpp:27
Similar function locator and reporter.
static constexpr CliOption options_[]
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
bool run(const ParsedOptions &options) override
Handles similar function finding command.
Represents a similarity graph between functions (paths).
#define COMMAND_DESCRIPTION(str)
Function abstraction for temporary codebase.
#define OPTION_END
This marks the end of a long array of options.
@ NoArgument
@ PositionalArgument
Path abstraction for temporary codebase.
Similarity relationships storage and analysis.
Defines utility functions used across all files.