ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
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. More...
 
bool validate (const ParsedOptions &options) override
 Validate the arguments already analyzed. More...
 
bool run (const ParsedOptions &options) override
 Handles code exploration command. More...
 
- Public Member Functions inherited from CommandBase< SimilarityExplorer >
virtual void print_help (const std::string command_name, const OptionsCollector *collector) const
 
const CliOption * options () 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 const CliOption * options () const =0
 
virtual std::string_view description () const =0
 
virtual bool validate (const ParsedOptions &options)=0
 Validate the arguments already analyzed. More...
 
virtual bool run (const ParsedOptions &options)=0
 Executes the main logic of the command. More...
 
virtual bool do_run (const std::string command_name, const ParsedOptions &options, const OptionsCollector *collector=nullptr)=0
 

Static Public Attributes

static constexpr int UNLIMITED_RESULTS = 0
 Constant for unlimited results display. More...
 
static constexpr const char * EMPTY_PATTERN = ""
 Constant for empty search pattern. More...
 
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 34 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 219 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 188 of file similarity_explorer.cpp.

Member Data Documentation

◆ EMPTY_PATTERN

constexpr const char* SimilarityExplorer::EMPTY_PATTERN = ""
staticconstexpr

Constant for empty search pattern.

Definition at line 37 of file similarity_explorer.hpp.

◆ options_

constexpr 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."},
{"verbose", 0, NoArgument, "Enable verbose output"},
{"template", 't', RequiredArgument, "Output format template for each result entry. Run --template-help to see available variables and an example."},
{"template-help", 0, NoArgument, "Show available template variables for --template."},
}
#define OPTION_END
This marks the end of a long array of options.
@ RequiredArgument
@ NoArgument

Definition at line 39 of file similarity_explorer.hpp.

◆ UNLIMITED_RESULTS

constexpr int SimilarityExplorer::UNLIMITED_RESULTS = 0
staticconstexpr

Constant for unlimited results display.

Definition at line 36 of file similarity_explorer.hpp.


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