AppraiseDev / Appraise

Appraise code used as part of WMT21 human evaluation campaign
BSD 3-Clause "New" or "Revised" License
22 stars 11 forks source link

TODO/dead code cleanup #180

Open zouharvi opened 1 month ago

zouharvi commented 1 month ago

As of today, there are >100 instanced of TODO in source code. Some of them are in parts of code that is never executed (e.g. after return statement). A good introductory issue would be to take up some of them, understand it, and resolve+remove it.

$ rg "TODO" .
./Campaign/models.py
26:MAX_FILEFILED_SIZE = 10  # TODO: this does not get enforced currently; remove?
29:# TODO: _validate_task_json(task_json)
202:        )  # TODO: add test
208:        )  # TODO: add test
215:        )  # TODO: add test
225:        )  # TODO: add test
234:        )  # TODO: add test
265:    # TODO:
341:    # TODO: make it to be the minimum of:
522:    # TODO: decide whether this needs to be optimized.

./pylint.rc
208:      TODO

./EvalView/templates/EvalView/direct-assessment-document.html
400:            // TODO: anchor to the first unannotated?

./Campaign/management/commands/ComputeAnnotatorMetrics.py
66:        # TODO: add argument to specify batch user

./Campaign/management/commands/ComputeZScores.py
145:        # TODO: add argument to specify batch user
224:        # TODO: get_system_data() returns a full dump of all annotations for

./Campaign/management/commands/validatecampaigndata.py
46:            # TODO: move validation code to CampaignData class.

./Campaign/management/commands/ProcessCampaignData.py
31:        # TODO: add argument to specify batch user
59:    # TODO: add rollback in case of errors

./EvalView/templates/EvalView/pairwise-assessment-document.html
428:            // TODO: anchor to the first unannotated?

./Appraise/urls.py
59:            template_name='Dashboard/signout.html',  # TODO: this does not exist!
77:    ),  # TODO: remove?

./Campaign/management/commands/InitCampaignWMT19DocSrcDACrowd.py
116:        requiredAnnotations=100,  # (tasks * redudancy), # TODO: fix

./Appraise/settings.py
199:# TODO: This is a temporary hack for running Appraise locally for regression

./EvalView/templates/EvalView/pairwise-assessment-document-newui.html
121:    // TODO: this may need to be changed
136:    // TODO: remove as there will be no slider here

./EvalView/views.py
707:                    # TODO: this could be a single query, would it be better or
720:                    # TODO: consider adding new score, not updating the
828:        # TODO: delete after the campaign is finished or fix all documents in DB
1488:        score1 = request.POST.get('score', None)  # TODO: score -> score1
2104:                    # TODO: this could be a single query, would it be better or
2117:                    # TODO: consider adding new score, not updating the

./Campaign/management/commands/ComputeSystemScores.py
38:        # TODO: add argument to specify batch user
111:        # TODO: this should consider the chosen campaign, otherwise

./EvalData/models/direct_assessment.py
223:        # TODO: this needs to be removed.
257:            # TODO: implement proper support for multiple json files in archive.
428:        # TODO: What is this magic number 70?
586:        # TODO: this is very intransparent... and needs to be fixed!

./Campaign/management/commands/InitCampaignWMT19SegSrcDA.py
100:        requiredAnnotations=100,  # (tasks * redudancy), # TODO: fix

./EvalData/models/direct_assessment_document.py
321:        # TODO: optimize, this possibly makes too many individual queries
398:            # TODO: implement proper support for multiple json files in archive.
783:        # TODO: this is very intransparent... and needs to be fixed!

./EvalData/models/task_agenda.py
35:# TODO: Unclear if these are needed?
123:    # TODO: decide whether this needs to be optimized.
242:    # TODO: decide whether this needs to be optimized.

./Campaign/management/commands/InitCampaignWMT19DocSrcDACrowd2.py
100:        requiredAnnotations=100,  # (tasks * redudancy), # TODO: fix

./EvalData/models/base_models.py
25:# TODO: Unclear if these are needed?
87:            # TODO: add registry of type names to models.py and ensure only
93:            # TODO: Hack
475:    # TODO: what is this used for? Candidate for deprecation/removal.
621:# TODO: chrife: source, target should be refactored into item1, item2.

./Campaign/management/commands/InitCampaignWMT19SegSrcDACrowd.py
100:        requiredAnnotations=100,  # (tasks * redudancy), # TODO: fix

./EvalData/models/pairwise_assessment_document.py
26:# TODO: Unclear if these are needed?
287:        # TODO: optimize, this possibly makes too many individual queries
295:                    createdBy=user,  # TODO: is passing user as an argument needed?
356:        # TODO: this needs to be removed.
390:            # TODO: implement proper support for multiple json files in archive.
438:                # TODO: check if 'targets' is empty or has more elements than 2
785:        # TODO: this is very intransparent... and needs to be fixed!

./Campaign/management/commands/ExportSystemScoresToCSV.py
33:        # TODO: add argument to specify batch user

./EvalData/models/direct_assessment_context.py
26:# TODO: Unclear if these are needed?
270:        # TODO: this needs to be removed.
304:            # TODO: implement proper support for multiple json files in archive.
659:        # TODO: this is very intransparent... and needs to be fixed!

./Scripts/create_iwslt22_tasks.py
571:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./EvalData/models/pairwise_assessment.py
28:# TODO: Unclear if these are needed?
235:        # TODO: this needs to be removed.
269:            # TODO: implement proper support for multiple json files in archive.
300:                # TODO: check if target1 + target2 should be used here
317:                # TODO: check if 'targets' is empty or has more elements than 2
652:        # TODO: this is very intransparent... and needs to be fixed!

./Campaign/management/commands/InitCampaignWMT19DocSrcDA.py
114:        requiredAnnotations=100,  # (tasks * redudancy), # TODO: fix

./EvalData/models/multi_modal_assessment.py
28:# TODO: Unclear if these are needed?
293:            # TODO: implement proper support for multiple json files in archive.

./Scripts/create_wmt22_tasks.py
823:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./EvalData/models/data_assessment.py
28:# TODO: Unclear if these are needed?
332:        # TODO: this needs to be removed.
366:            # TODO: implement proper support for multiple json files in archive.
728:        # TODO: this is very intransparent... and needs to be fixed!

./Scripts/create_wmt21_tasks.py
527:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./Campaign/management/commands/StartNewCampaign.py
41:        # TODO: support adding multiple batches
117:        # TODO: run only if the campaign does not exist

./Scripts/create_wmt19_tasks.py
389:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./Campaign/management/commands/ComputeWMT21Results.py
174:        # TODO: add argument to specify batch user
253:        # TODO: get_system_data() returns a full dump of all annotations for

./scripts/create_iwslt22_tasks.py
571:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./Campaign/management/commands/ComputeWMT23Results.py
179:        # TODO: add argument to specify batch user
258:        # TODO: get_system_data() returns a full dump of all annotations for

./EvalData/management/commands/CreateMultiModalAssessmentData.py
71:        # TODO: add optional parameters to set source, reference and system IDs
73:        # TODO: add exclude argument which prevents creation of redundant data?
177:        # TODO: add parameter to set encoding
178:        # TODO: need to use OrderedDict to preserve segment IDs' order!

./scripts/create_wmt22_tasks.py
823:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./EvalData/admin.py
20:# TODO:chrife: find a way to use SELECT-based filtering widgets

./scripts/create_wmt21_tasks.py
527:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./EvalData/management/commands/CreateDirectAssessmentData.py
142:        # TODO: add optional parameters to set source, reference and system IDs
342:            # TODO: decide whether to drop use of system_ids.
380:                # TODO: fix long lines.
426:                    # TODO: fix long lines.
464:                # TODO: fix long lines.
729:    # TODO: use module-level function instead, moving to different file.

./scripts/create_wmt19_tasks.py
389:            padded_tasks.append(tuple(task))  # TODO: does this ever occur?

./EvalData/management/commands/CreateDirectAssessmentDataWMT17.py
114:        # TODO: add optional parameters to set source, reference and system IDs
116:        # TODO: add exclude argument which prevents creation of redundant data?
225:        # TODO: add parameter to set encoding
226:        # TODO: need to use OrderedDict to preserve segment IDs' order!

./Campaign/utils.py
119:        requiredAnnotations=100,  # (tasks * redudancy), # TODO: fix

./Dashboard/templates/Dashboard/base.html
69:{% comment %}TODO: this needs proper cleanup{% endcomment %}

./Dashboard/views.py
32:# TODO: task names should be stored in task classes as an attribute
202:                print(format_exc())  # TODO: need logger here!
226:        'active_page': "OVERVIEW",  # TODO: check
zouharvi commented 1 month ago

Definitelly dead code can be detected with vulture (pip install vulture):

$ vulture . --min-confidence 100
Campaign/management/commands/ComputeAnnotatorMetrics.py:235: unreachable code after 'continue' (100% confidence)
Campaign/management/commands/ComputeAnnotatorMetrics.py:272: unreachable code after 'continue' (100% confidence)
Campaign/management/commands/ComputeWMT21Results.py:82: unused variable 'alpha' (100% confidence)
Campaign/management/commands/ComputeWMT23Results.py:82: unused variable 'alpha' (100% confidence)
Campaign/management/commands/ComputeZScores.py:59: unused variable 'alpha' (100% confidence)
Campaign/management/commands/ComputeZScores.py:570: unreachable code after 'continue' (100% confidence)
Campaign/management/commands/ComputeZScores.py:606: unreachable code after 'return' (100% confidence)
EvalData/management/commands/CreateDirectAssessmentDataWMT17.py:372: redundant if-condition (100% confidence)
EvalData/models/data_assessment.py:320: unreachable code after 'return' (100% confidence)
EvalData/models/direct_assessment.py:211: unreachable code after 'return' (100% confidence)
EvalData/models/direct_assessment_context.py:258: unreachable code after 'return' (100% confidence)
EvalData/models/pairwise_assessment.py:223: unreachable code after 'return' (100% confidence)
EvalData/models/pairwise_assessment_document.py:344: unreachable code after 'return' (100% confidence)