Skip to content

Extensive Code Duplication #96

@GNiendorf

Description

@GNiendorf

To simplify the code, we should remove the extensive use of code duplication (copy-paste).

Here is a gist showing some of the current duplication, automatically generated with PMD. Not all of these are meaningful duplications, but it catches many obvious repeats:

https://gist.github.com/GNiendorf/fd4fe952f38149b5bfd1269a7039370e

This was generated with the following:

1. Download PMD

wget https://github.com/pmd/pmd/releases/download/pmd_releases%2F7.5.0/pmd-dist-7.5.0-bin.zip

2. Extract the PMD archive

unzip pmd-dist-7.5.0-bin.zip -d pmd-dist

3. Navigate to the PMD bin directory

cd pmd-dist/pmd-bin-7.5.0/bin

4. Create a list of .cc and .h files in specific directories

find
CMSSW_14_1_0_pre3/src/RecoTracker/LSTCore/interface/alpaka
CMSSW_14_1_0_pre3/src/RecoTracker/LSTCore/interface
CMSSW_14_1_0_pre3/src/RecoTracker/LSTCore/src/alpaka
CMSSW_14_1_0_pre3/src/RecoTracker/LSTCore/src
CMSSW_14_1_0_pre3/src/RecoTracker/LSTCore/standalone/bin
CMSSW_14_1_0_pre3/src/RecoTracker/LSTCore/standalone/code/core
CMSSW_14_1_0_pre3/src/RecoTracker/LSTCore/standalone/efficiency/src
-type f ( -name ".cc" -o -name ".h" ) > file_list.txt

5. Run CPD to generate the duplication report

./pmd cpd --minimum-tokens 100 --file-list file_list.txt --language cpp --format text > duplication_report.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions