Code Duplication Detection - Delphi

Does anyone know a good tool for finding duplicate code in a delphi program like SolidSDD?

+4
source share
5 answers

In Delphi 2010 and XE there is a built-in . There is a new tool called Auditing and Metrics.

They run several tests against your code to find various problems or unpleasant odors that can be detected by static analysis.

In XE, from the menu you can choose Project | QA Auditing for access to duplicate code verification features. You can run 3 different code checks.

QA Audits

Although it does not perform duplicate code detection, there is also a Peganza Pascal Analyzer that performs various audits using static analysis.

+5
source

We discovered DupeCheck through the Torry Delphi website. This is a standalone .exe that scans a directory listing and goes through .pas files, trying to find duplicate lines of code - ignoring comments, spaces and case sensitivity.

+4
source

Try the following:

Delphi audit

+3
source

You can try AQTime from Smartbear software, its a good profiling and analysis tool that allows you to detect duplicate code and much more like:

Codecoverage, performance issues, memory allocation, trace exceptions and functions, etc.

This tool is not free, but it is very powerful and supports Delphi applications, you can even integrate it into your development environment.

for more information with AQ-Profilers

+2
source

I used Simian. http://www.harukizaemon.com/simian/

You can easily run it to find duplicate code. For instance:

simian-2.3.33 -ignoreCharacterCase+ -ignoreCurlyBraces+ %1 

This is not special for Delphi, but it works.

Here is an example output:

 Simian is not free unless used solely for non-commercial or evaluation purposes. {failOnDuplication=true, ignoreCharacterCase=true, ignoreCurlyBraces=true, ignoreIdentifierCase=true, ignoreModifiers=true, ignoreStringCase=true, threshold=6} Found 6 duplicate lines in the following files: Between lines 6386 and 6391 in c:\develop\Schedule.pas Between lines 6370 and 6375 in c:\develop\Schedule.pas Found 6 duplicate lines in the following files: Between lines 5229 and 5235 in c:\develop\Schedule.pas Between lines 5189 and 5195 in c:\develop\Schedule.pas Found 6 duplicate lines in the following files: Between lines 6892 and 6898 in c:\develop\Schedule.pas Between lines 6418 and 6423 in c:\develop\Schedule.pas Between lines 6402 and 6407 in c:\develop\Schedule.pas Between lines 6354 and 6359 in c:\develop\Schedule.pas Between lines 6338 and 6343 in c:\develop\Schedule.pas Found 27 duplicate lines in the following files: Between lines 2995 and 3022 in c:\develop\Schedule.pas Between lines 3035 and 3062 in c:\develop\Schedule.pas 
0
source

Source: https://habr.com/ru/post/1338753/


All Articles