changed 4 years ago
Linked with GitHub

Reduce Code Clones from FT code

Proposal Overview

In general, by copying and pasting, code clones makes development more efficient. However, it also makes maintenance more complicated and difficult.

a tool called jscpd is used to find out the code clone rate, and according to the following results, it is clear that there are many code clones in Tacker's FT code.
[jscpd] https://www.npmjs.com/package/jscpd

Job name Files Lines Clones Duplicated Lines
legacy 17 2236 16 301 (13.46%)
sol 7 5840 75 1705 (29.2 %)
sol_kubernetes 4 2476 56 1061 (42.85%)
sol_separated_nfvo 3 1050 7 154 (14.67)

In particular, since sol_kubernetes's code clone rate is up to 40% , we think it will be better to refactor to make future maintenance easier.

To improve this situation, a base file needs to be created and LCM operations as well as common test functions code should move into it .

Also, code clone rate of sol is about 30%, although the rate is not as high as that of sol-Kubernetes, we would like to deal with it if we can afford it.

Datail Datas

For each job's code, the duplicate lines data for each file is as follows:

  • legacy

    File Path Lines Duplicated Lines
    tacker/tests/functional/legacy/vnfm/test_vnfm_param.py 205 10
    tacker/tests/functional/legacy/vnfm/test_vnf_placement_policy.py 134 0
    tacker/tests/functional/legacy/vnfm/test_vnf_monitoring.py 88 0
    tacker/tests/functional/legacy/vnfm/test_vnf.py 106 30
    tacker/tests/functional/legacy/vnfm/test_tosca_vnfd.py 64 6
    tacker/tests/functional/legacy/vnfm/test_tosca_vnfc.py 113 38
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_scale.py 89 20
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_reservation.py 234 46
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_multiple_vdu.py 74 27
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_maintenance.py 195 12
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_floatingip.py 92 0
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_existing_block_storage.py 117 92
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_block_storage.py 109 160
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf_alarm.py 121 25
    tacker/tests/functional/legacy/vnfm/test_tosca_vnf.py 226 130
    tacker/tests/functional/legacy/nfvo/test_vim.py 183 0
    tacker/tests/functional/legacy/nfvo/test_nfvo.py 86 6
  • sol

    File Path Lines Duplicated Lines
    tacker/tests/functional/sol/vnfpkgm/test_vnf_package.py 527 76
    tacker/tests/functional/sol/vnflcm/test_vnflcm_noop.py 307 183
    tacker/tests/functional/sol/vnflcm/test_vnf_instance_with_user_data.py 2056 2075
    tacker/tests/functional/sol/vnflcm/test_vnf_instance.py 1139 660
    tacker/tests/functional/sol/vnflcm/fake_vnfpkgm.py 104 0
    tacker/tests/functional/sol/vnflcm/fake_vnflcm.py 449 86
    tacker/tests/functional/sol/vnflcm/base.py 1258 330
  • sol_kubernetes

    File Path Lines Duplicated Lines
    tacker/tests/functional/sol_kubernetes/vnflcm/test_kubernetes_scale.py 483 565
    tacker/tests/functional/sol_kubernetes/vnflcm/test_kubernetes_helm.py 446 384
    tacker/tests/functional/sol_kubernetes/vnflcm/test_kubernetes_heal.py 402 295
    tacker/tests/functional/sol_kubernetes/vnflcm/test_kubernetes.py 1145 878
  • sol_separated_nfvo

    File Path Lines Duplicated Lines
    tacker/tests/functional/sol_separated_nfvo/vnflcm/
    test_vnf_instance_with_user_data_nfvo_separate.py
    710 270
    tacker/tests/functional/sol_separated_nfvo/vnflcm/fake_vnfpkgm.py 104 0
    tacker/tests/functional/sol_separated_nfvo/vnflcm/fake_grant.py 236 38
Select a repo