Arkanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
random_selector.hpp
Go to the documentation of this file.
1
13#pragma once
14
15#include <arkanjo/base/path.hpp>
18#include <random>
19#include <string>
20#include <tuple>
21#include <vector>
22
25using namespace std;
26
34class RandomSelector : public CommandBase<RandomSelector> {
35 static constexpr const char* TEMPLATE_RANDOM_ENTRY =
36 "Functions: {path_a} AND {path_b}. Similarity: {similarity} ";
37
38 Similarity_Table* similarity_table;
39 double minimum_similarity;
40 double maximum_similarity;
41 double maximum_quantity;
42
43 const int seed = 123456789;
44 mt19937 rng = mt19937(seed);
45
51 bool is_valid_pair(tuple<double, Path, Path> path_pair);
52
57 vector<tuple<double, Path, Path>> get_similarity_pairs_filtered();
58
64 vector<tuple<double, Path, Path>> make_random_selection(vector<tuple<double, Path, Path>> path_pairs);
65
70 void print_path_pairs(vector<tuple<double, Path, Path>> path_pairs);
71
72 public:
73 static constexpr CliOption options_[] = {
74 {"minimum_similarity", 0, PositionalArgument, nullptr},
75 {"maximum_similarity", 0, PositionalArgument, nullptr},
76 {"maximum_quantity", 0, PositionalArgument, nullptr},
78 };
80 "Select random pairs of functions within a specified similarity range. "
81 "The provided MIN_SIMILARITY and MAX_SIMILARITY parameters define the "
82 "inclusive similarity interval, and up to MAX_QUANTITY pairs are randomly "
83 "selected and displayed.")
84
85
92 explicit RandomSelector(Similarity_Table* _similarity_table);
93
94 bool validate(const ParsedOptions& options) override;
95
99 bool run(const ParsedOptions& options) override;
100};
const CliOption * options() const final
Random pair selector for similar code segments.
bool validate(const ParsedOptions &options) override
Validate the arguments already analyzed.
bool run(const ParsedOptions &options) override
Handles random selection command.
static constexpr CliOption options_[]
COMMAND_DESCRIPTION("Select random pairs of functions within a specified similarity range. " "The provided MIN_SIMILARITY and MAX_SIMILARITY parameters define the " "inclusive similarity interval, and up to MAX_QUANTITY pairs are randomly " "selected and displayed.") explicit RandomSelector(Similarity_Table *_similarity_table)
Constructs selector with configuration.
Represents a similarity graph between functions (paths).
#define OPTION_END
This marks the end of a long array of options.
@ PositionalArgument
Path abstraction for temporary codebase.
Similarity relationships storage and analysis.
Defines utility functions used across all files.