ArKanjo 0.5.1
A tool for find code duplicated functions in codebases
GitDiffFunction Class Reference

Generate a git-style diff between two duplicate functions. More...

#include <git_diff_function.hpp>

+ Inheritance diagram for GitDiffFunction:
+ Collaboration diagram for GitDiffFunction:

Public Member Functions

 GitDiffFunction (Similarity_Table *_similarity_table)
 
bool validate (const ParsedOptions &options) override
 Validate the arguments already analyzed. More...
 
bool run (const ParsedOptions &options) override
 Executes the main logic of the command. More...
 
- Public Member Functions inherited from CommandBase< GitDiffFunction >
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 CliOption options_ []
 

Detailed Description

Generate a git-style diff between two duplicate functions.

This command matches two function name patterns against the similarity table, validates that the functions are considered duplicates, and then uses libgit2's diff engine to render a patch between the two function bodies.

Definition at line 18 of file git_diff_function.hpp.

Constructor & Destructor Documentation

◆ GitDiffFunction()

GitDiffFunction::GitDiffFunction ( Similarity_Table *  _similarity_table)
explicit

Definition at line 12 of file git_diff_function.cpp.

Member Function Documentation

◆ run()

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

Executes the main logic of the command.

You must use the validated arguments to perform the action desired by the command.

Parameters
optionsThe ParsedOptions structure will be populated with the arguments.
Returns
True if the execution is successful, false if an error occurs.

Implements ICommand.

Definition at line 23 of file git_diff_function.cpp.

◆ validate()

bool GitDiffFunction::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 15 of file git_diff_function.cpp.

Member Data Documentation

◆ options_

constexpr CliOption GitDiffFunction::options_[]
staticconstexpr
Initial value:
= {
{"first_function", 0, PositionalArgument, "First function name pattern."},
{"second_function", 0, PositionalArgument, "Second function name pattern."},
}
#define OPTION_END
This marks the end of a long array of options.
@ PositionalArgument

Definition at line 20 of file git_diff_function.hpp.


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