https://github.com/lvntky/noditto
Noditto: AST Based Code Duplication Finder
https://github.com/lvntky/noditto
abstract-syntax-tree duplicate-detection duplicate-files parser
Last synced: 10 months ago
JSON representation
Noditto: AST Based Code Duplication Finder
- Host: GitHub
- URL: https://github.com/lvntky/noditto
- Owner: lvntky
- License: mit
- Created: 2024-07-17T10:22:24.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-07-22T09:55:51.000Z (over 1 year ago)
- Last Synced: 2025-02-09T08:19:56.060Z (11 months ago)
- Topics: abstract-syntax-tree, duplicate-detection, duplicate-files, parser
- Language: CMake
- Homepage:
- Size: 55.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Noditto



> ditto (/ˈdɪtəʊ/)
> noun - the same thing again (used in lists and accounts and often indicated by a ditto mark under the word or figure to be repeated).
Noditto is a code duplication finder program written in C++ that uses Abstract Syntax Trees (ASTs) and other algorithms to detect duplicated code blocks within a file. This tool aims to help developers identify and refactor redundant code, improving code quality and maintainability.
Features
- AST-Based Duplication Detection: Parses source code into ASTs and identifies repeated subtrees.
- Efficient Algorithms: Implements various algorithms for efficient duplication detection, including tree hashing and sliding window techniques.
- Custom Parsing: Uses a custom parser to generate ASTs, allowing for extensibility and customization.
- Detailed Reporting: Generates detailed reports on detected duplications, including line numbers and similarity percentages.
- Logging: Utilizes `spdlog` for robust logging capabilities.
## Usage
Run noditto from the command line, specifying the file to check for duplications:
```sh
./noditto /path/to/your/file.cpp
```
Command-Line Options
- -h, --help: Display help information.
- -o, --output: Specify the output file for the duplication report.
## How It Works
1. Parsing Source Code:
- Noditto parses the source code file and generates its AST.
- The AST represents the structure of the source code.
2. Extracting Subtrees:
- Noditto traverses the AST to extract all possible subtrees.
3. Hashing Subtrees:
- Each subtree is hashed to enable quick comparison.
4. Comparing Hashes:
- Noditto stores the hashes in a data structure and compares them to find duplicate subtrees.
5. Generating Reports:
- Ditto generates a detailed report of the detected duplications, including file names, line numbers, and similarity percentages.
## Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue if you find any bugs or have suggestions for improvements.
## License
MIT