99Python translation of the original Perl module
1010"""
1111
12- from typing import Dict , Callable
12+ from typing import Callable
1313from umdp3_checker_rules import UMDP3Checker
1414
1515"""
16- TODO : This list was checked to ensure it had something for each
17- test in the original.
18- TODO : This needs to be re-checked.
19- TODO : And the tests need to be compared to the original Perl tests
20- to ensure they are equivalent.
21- """
16+ TODO : This module has lost it's way. It uses a class to define methods which just
17+ return lists of functions. I don't think a class is required for this.
18+ As the functions themselves are shifted, renamed and hopefully improved, this
19+ class should eventually get emptied out and the file removed.
2220
23- # Declare version
24- VERSION = "13.5.0"
21+ """
2522
2623
2724class CheckerDispatchTables :
@@ -30,86 +27,66 @@ class CheckerDispatchTables:
3027 def __init__ (self ):
3128 self .umdp3_checker = UMDP3Checker ()
3229
33- def get_diff_dispatch_table_fortran (self ) -> Dict [ str , Callable ]:
30+ def get_diff_dispatch_table_fortran (self ) -> list [ Callable ]:
3431 """Get dispatch table for Fortran diff tests"""
35- return {
36- # 'Captain Daves doomed test of destruction':
37- # self.umdp3_checker.capitulated_keywords,
38- "Lowercase Fortran keywords not permitted" : self .umdp3_checker .capitalised_keywords ,
39- "OpenMP sentinels not in column one" : self .umdp3_checker .openmp_sentinels_in_column_one ,
40- "Omitted optional space in keywords" : self .umdp3_checker .unseparated_keywords ,
41- "GO TO other than 9999" : self .umdp3_checker .go_to_other_than_9999 ,
42- "WRITE without format" : self .umdp3_checker .write_using_default_format ,
43- "Lowercase or CamelCase variable names only" : self .umdp3_checker .lowercase_variable_names ,
44- "Use of dimension attribute" : self .umdp3_checker .dimension_forbidden ,
45- "Continuation lines shouldn't start with &" : self .umdp3_checker .ampersand_continuation ,
46- "Use of EQUIVALENCE or PAUSE" : self .umdp3_checker .forbidden_keywords ,
47- "Use of older form of relational operator (.GT. etc.)" : self .umdp3_checker .forbidden_operators ,
48- "Line longer than 80 characters" : self .umdp3_checker .line_over_80chars ,
49- "Line includes tab character" : self .umdp3_checker .tab_detection ,
50- "USEd printstatus_mod instead of umPrintMgr" : self .umdp3_checker .printstatus_mod ,
51- "Used PRINT rather than umMessage and umPrint" : self .umdp3_checker .printstar ,
52- "Used WRITE(6) rather than umMessage and umPrint" : self .umdp3_checker .write6 ,
53- "Used um_fort_flush rather than umPrintFlush" : self .umdp3_checker .um_fort_flush ,
54- "Used Subversion keyword substitution which is prohibited" : self .umdp3_checker .svn_keyword_subst ,
55- "Used !OMP instead of !$OMP" : self .umdp3_checker .omp_missing_dollar ,
56- "Used #ifdef/#ifndef rather than #if defined() or #if !defined()" : self .umdp3_checker .cpp_ifdef ,
57- "Presence of fortran comment in CPP directive" : self .umdp3_checker .cpp_comment ,
58- "Used an archaic fortran intrinsic function" : self .umdp3_checker .obsolescent_fortran_intrinsic ,
59- "EXIT statements should be labelled" : self .umdp3_checker .exit_stmt_label ,
60- "Intrinsic modules must be USEd with an INTRINSIC "
61- + "keyword specifier" : self .umdp3_checker .intrinsic_modules ,
62- "READ statements should have an explicit UNIT= as "
63- + "their first argument" : self .umdp3_checker .read_unit_args ,
64- }
32+ return [
33+ self .umdp3_checker .openmp_sentinels_in_column_one ,
34+ self .umdp3_checker .unseparated_keywords ,
35+ self .umdp3_checker .go_to_other_than_9999 ,
36+ self .umdp3_checker .write_using_default_format ,
37+ self .umdp3_checker .dimension_forbidden ,
38+ self .umdp3_checker .ampersand_continuation ,
39+ self .umdp3_checker .forbidden_keywords ,
40+ self .umdp3_checker .forbidden_operators ,
41+ self .umdp3_checker .tab_detection ,
42+ self .umdp3_checker .printstatus_mod ,
43+ self .umdp3_checker .printstar ,
44+ self .umdp3_checker .write6 ,
45+ self .umdp3_checker .um_fort_flush ,
46+ self .umdp3_checker .svn_keyword_subst ,
47+ self .umdp3_checker .omp_missing_dollar ,
48+ self .umdp3_checker .cpp_ifdef ,
49+ self .umdp3_checker .cpp_comment ,
50+ self .umdp3_checker .obsolescent_fortran_intrinsic ,
51+ self .umdp3_checker .exit_stmt_label ,
52+ self .umdp3_checker .intrinsic_modules ,
53+ self .umdp3_checker .read_unit_args ,
54+ ]
6555
66- def get_file_dispatch_table_fortran (
67- self , filename : str = ""
68- ) -> Dict [str , Callable ]:
56+ def get_file_dispatch_table_fortran (self , filename : str = "" ) -> list [Callable ]:
6957 """Get dispatch table for Fortran file tests"""
70- return {
71- "Warning - used an if-def due for retirement" : self .umdp3_checker .retire_if_def ,
72- "File is missing at least one IMPLICIT NONE" : self .umdp3_checker .implicit_none ,
73- "Never use STOP or CALL abort" : self .umdp3_checker .forbidden_stop ,
74- "Use of Fortran function as a variable name" : self .umdp3_checker .intrinsic_as_variable ,
75- "File missing crown copyright statement or agreement reference" : self .umdp3_checker .check_crown_copyright ,
76- "File missing correct code owner comment" : self .umdp3_checker .check_code_owner ,
77- "Used (/ 1,2,3 /) form of array initialisation, rather than "
78- + "[1,2,3] form" : self .umdp3_checker .array_init_form ,
79- }
58+ return [
59+ self .umdp3_checker .retire_if_def ,
60+ self .umdp3_checker .implicit_none ,
61+ self .umdp3_checker .forbidden_stop ,
62+ self .umdp3_checker .intrinsic_as_variable ,
63+ self .umdp3_checker .check_code_owner ,
64+ self .umdp3_checker .array_init_form ,
65+ ]
8066
81- def get_diff_dispatch_table_c (self ) -> Dict [ str , Callable ]:
67+ def get_diff_dispatch_table_c (self ) -> list [ Callable ]:
8268 """Get dispatch table for C diff tests"""
83- return {
84- "Line longer than 80 characters" : self .umdp3_checker .line_over_80chars ,
85- "Line includes tab character" : self .umdp3_checker .tab_detection ,
86- "Fixed-width Integer format specifiers must have a space "
87- + 'between themselves and the string delimiter (the " character)' : self .umdp3_checker .c_integral_format_specifiers ,
88- }
69+ return [
70+ self .umdp3_checker .tab_detection ,
71+ self .umdp3_checker .c_integral_format_specifiers ,
72+ ]
8973
90- def get_file_dispatch_table_c (self ) -> Dict [ str , Callable ]:
74+ def get_file_dispatch_table_c (self ) -> list [ Callable ]:
9175 """Get dispatch table for C file tests"""
92- return {
93- "Warning - used an if-def due for retirement" : self .umdp3_checker .retire_if_def ,
94- "Used a deprecated C identifier" : self .umdp3_checker .c_deprecated ,
95- "File missing crown copyright statement or agreement reference" : self .umdp3_checker .check_crown_copyright ,
96- "File missing correct code owner comment" : self .umdp3_checker .check_code_owner ,
97- "Used an _OPENMP if-def without also testing against "
98- + "SHUM_USE_C_OPENMP_VIA_THREAD_UTILS. (Or _OPENMP does "
99- + "not come first in the test.)" : self .umdp3_checker .c_openmp_define_pair_thread_utils ,
100- "Used an _OPENMP && SHUM_USE_C_OPENMP_VIA_THREAD_UTILS if-def "
101- + "test in a logical combination with a third macro" : self .umdp3_checker .c_openmp_define_no_combine ,
102- "Used !defined(_OPENMP) rather than defined(_OPENMP) "
103- + "with #else branch" : self .umdp3_checker .c_openmp_define_not ,
104- "Used an omp #pragma (or #include <omp.h>) without "
105- + "protecting it with an _OPENMP if-def" : self .umdp3_checker .c_protect_omp_pragma ,
106- "Used the #ifdef style of if-def, rather than the #if "
107- + "defined() style" : self .umdp3_checker .c_ifdef_defines ,
108- "C Unit does not end with a final newline character" : self .umdp3_checker .c_final_newline ,
109- }
76+ return [
77+ self .umdp3_checker .retire_if_def ,
78+ self .umdp3_checker .c_deprecated ,
79+ self .umdp3_checker .check_code_owner ,
80+ self .umdp3_checker .c_openmp_define_pair_thread_utils ,
81+ self .umdp3_checker .c_openmp_define_no_combine ,
82+ self .umdp3_checker .c_openmp_define_not ,
83+ self .umdp3_checker .c_protect_omp_pragma ,
84+ self .umdp3_checker .c_ifdef_defines ,
85+ self .umdp3_checker .c_final_newline ,
86+ ]
11087
111- def get_file_dispatch_table_all (self ) -> Dict [ str , Callable ]:
88+ def get_file_dispatch_table_all (self ) -> list [ Callable ]:
11289 """Get dispatch table for universal file tests"""
113- return {
114- "Line includes trailing whitespace character(s)" : self .umdp3_checker .line_trail_whitespace ,
115- }
90+ return [
91+ self .umdp3_checker .line_trail_whitespace ,
92+ ]
0 commit comments