3void CounterDuplicationCode::mark_path_as_processed(
Path path) {
4 processed_paths.insert(path);
7bool CounterDuplicationCode::is_path_processed_path(
Path path) {
8 return processed_paths.find(path) != processed_paths.end();
11int CounterDuplicationCode::get_number_of_lines_in_path(
const Path& path) {
14 return function.number_of_lines();
17void CounterDuplicationCode::register_code_duplication(
const Path& path1,
const Path& path2,
int number_of_lines) {
22void CounterDuplicationCode::process_path(
const Path& path) {
23 if (is_path_processed_path(path)) {
26 int number_of_lines = get_number_of_lines_in_path(path);
27 mark_path_as_processed(path);
29 for (
const auto& similar_path : similar_paths) {
30 mark_path_as_processed(similar_path);
31 register_code_duplication(path, similar_path, number_of_lines);
35void CounterDuplicationCode::process_every_path_in_similarity_table() {
37 for (
const auto& path : paths) {
42CounterDuplicationCode::CounterDuplicationCode(
Similarity_Table* _similarity_table) {
43 similarity_table = _similarity_table;
47 auto it_json =
options.args.find(
"json");
48 if (it_json !=
options.args.end()) {
49 throw CLIError(
"--json is not supported in this command.");
56 process_every_path_in_similarity_table();
Base class for CLI-related errors.
const CliOption * options() const final
void add_folder_duplication_code(const std::vector< std::string > &folder_path, int number_of_duplication_lines)
Adds duplication count for a folder path.
void print_duplication_code_trie()
Prints the trie structure with duplication counts.
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
bool run(const ParsedOptions &options) override
Handles duplication analysis command.
Represents a code function with its content and metadata.
Path manipulation class for tool-specific directory structure.
std::vector< std::string > get_common_folders(const Path &path) const
Finds common folders with another path.
Represents a similarity graph between functions (paths).
const std::vector< Path > & get_path_list() const
Gets list of all known paths.
std::vector< Path > get_similar_path_to_the_reference(const Path &reference)
Gets paths similar to reference path.
Code duplication reporting system.