Arkanjo 0.2
A tool for find code duplicated functions in codebases
Loading...
Searching...
No Matches
SimilarityExplorer Class Reference

Duplicate function explorer and analyzer. More...

#include <similarity_explorer.hpp>

+ Inheritance diagram for SimilarityExplorer:
+ Collaboration diagram for SimilarityExplorer:

Public Member Functions

 COMMAND_DESCRIPTION ("Explore duplicated functions detected in the project.") explicit SimilarityExplorer(Similarity_Table *_similarity_table)
 Constructs explorer with configuration.
 
bool validate (const ParsedOptions &options) override
 Validate the arguments already analyzed.
 
bool run (const ParsedOptions &options) override
 Handles code exploration command.
 
- Public Member Functions inherited from CommandBase< SimilarityExplorer >
virtual void print_help (const std::string command_name, const OptionsCollector *collector) const
 
const CliOptionoptions () const final
 
bool do_run (const std::string command_name, const ParsedOptions &options, const OptionsCollector *collector=nullptr) override
 
- Public Member Functions inherited from ICommand
virtual ~ICommand ()=default
 
virtual std::string_view description () const =0
 

Static Public Attributes

static constexpr int UNLIMITED_RESULTS = 0
 Constant for unlimited results display.
 
static constexpr const char * EMPTY_PATTERN = ""
 Constant for empty search pattern.
 
static constexpr CliOption options_ []
 

Detailed Description

Duplicate function explorer and analyzer.

Enables exploration of duplicate functions with configurable filtering and sorting capabilities to identify code duplication patterns.

Definition at line 35 of file similarity_explorer.hpp.

Member Function Documentation

◆ COMMAND_DESCRIPTION()

SimilarityExplorer::COMMAND_DESCRIPTION ( "Explore duplicated functions detected in the project." )

Constructs explorer with configuration.

Parameters
_similarity_tableSimilarity data source

◆ run()

bool SimilarityExplorer::run ( const ParsedOptions & options)
overridevirtual

Handles code exploration command.

Implements ICommand.

Definition at line 157 of file similarity_explorer.cpp.

◆ validate()

bool SimilarityExplorer::validate ( const ParsedOptions & options)
overridevirtual

Validate the arguments already analyzed.

Verify that all required options have been selected and that the values ​​provided are valid.

Parameters
optionsThe ParsedOptions structure will be populated with the arguments.
Returns
True if the arguments are valid, false otherwise.

Implements ICommand.

Definition at line 139 of file similarity_explorer.cpp.

Member Data Documentation

◆ EMPTY_PATTERN

const char* SimilarityExplorer::EMPTY_PATTERN = ""
staticconstexpr

Constant for empty search pattern.

Definition at line 38 of file similarity_explorer.hpp.

◆ options_

CliOption SimilarityExplorer::options_[]
staticconstexpr
Initial value:
= {
{"limiter", 'l', RequiredArgument, "Limits the number of results shown to the user. By default, all results are shown."},
{"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`)."},
{"both-match", 'b', NoArgument, "Enable both-pattern matching. By default, the pattern only needs to match one function."},
{"sort", 's', NoArgument, "Sort results by number of duplicated lines. By default, results are sorted by the similarity metric."},
{"cluster", 'c', NoArgument, "Print results with cluster relationships from the similarity table."},
}
#define OPTION_END
This marks the end of a long array of options.
@ RequiredArgument
@ NoArgument

Definition at line 40 of file similarity_explorer.hpp.

◆ UNLIMITED_RESULTS

int SimilarityExplorer::UNLIMITED_RESULTS = 0
staticconstexpr

Constant for unlimited results display.

Definition at line 37 of file similarity_explorer.hpp.


The documentation for this class was generated from the following files: