ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
git_diff_function.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5
9
18class GitDiffFunction : public CommandBase<GitDiffFunction> {
19 public:
20 static constexpr CliOption options_[] = {
21 {"first_function", 0, PositionalArgument, "First function name pattern."},
22 {"second_function", 0, PositionalArgument, "Second function name pattern."},
24 };
25 COMMAND_DESCRIPTION("Show a git-style diff for two duplicate functions found by the tool.")
26
27 explicit GitDiffFunction(Similarity_Table* _similarity_table);
28
29 bool validate(const ParsedOptions& options) override;
30 bool run(const ParsedOptions& options) override;
31
32 private:
33 Similarity_Table* similarity_table;
34
35 std::vector<Path> find_matching_paths(const std::string& pattern) const;
36 const std::string format_pattern(const std::string& pattern) const;
37 Path choose_single_path(const std::vector<Path>& candidates, const std::string& pattern) const;
38 bool diff_functions(const Path& first, const Path& second) const;
39 static std::string build_text_from_lines(const std::vector<std::string>& lines);
40};
const CliOption * options() const final
Generate a git-style diff between two duplicate functions.
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
static constexpr CliOption options_[]
bool run(const ParsedOptions &options) override
Executes the main logic of the command.
Represents a logical path to a function in the codebase.
Definition: path.hpp:26
Represents a similarity graph between functions (paths).
#define COMMAND_DESCRIPTION(str)
Definition: command_base.hpp:9
#define OPTION_END
This marks the end of a long array of options.
@ PositionalArgument
Logical path abstraction for source code elements.
Similarity relationships storage and analysis.