Skip to content

Commit 674ed15

Browse files
r-sharpPierre-siddallericaneininger
authored
Tweaks to get VSCode's internal linters to quit whinging and make the… (#173)
* Tweaks to get VSCode's internal linters to quit whinging and make the ToDo plugin work nicely. * Touch O Tidying and ToDo commenting. * reviewer request to Update script_umdp3_checker/umdp3_conformance.py Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com> * Update script_umdp3_checker/umdp3_checker_rules.py Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com> * Update script_umdp3_checker/umdp3_checker_rules.py Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com> * Update script_umdp3_checker/umdp3_checker_rules.py Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com> * Update script_umdp3_checker/umdp3_checker_rules.py Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com> * Update script_umdp3_checker/umdp3_checker_rules.py Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com> * Rreviwer requested changes that I was unable to commit via GitHub's web interface --------- Co-authored-by: Pierre Siddall <43399998+Pierre-siddall@users.noreply.github.com> Co-authored-by: Erica Neininger <107684099+ericaneininger@users.noreply.github.com>
1 parent 54456f8 commit 674ed15

6 files changed

Lines changed: 326 additions & 157 deletions

File tree

__init__.py

Whitespace-only changes.

script_umdp3_checker/checker_dispatch_tables.py

Lines changed: 93 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
from umdp3_checker_rules import UMDP3Checker
1414

1515
"""
16-
ToDo : This list was checked to ensure it had something for each
16+
TODO : This list was checked to ensure it had something for each
1717
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.
1821
"""
1922

2023
# Declare version
@@ -30,72 +33,120 @@ def __init__(self):
3033
def get_diff_dispatch_table_fortran(self) -> Dict[str, Callable]:
3134
"""Get dispatch table for Fortran diff tests"""
3235
return {
33-
# 'Captain Daves doomed test of destruction': self.umdp3_checker.capitulated_keywords,
34-
"Lowercase Fortran keywords not permitted": self.umdp3_checker.capitalised_keywords,
35-
"OpenMP sentinels not in column one": self.umdp3_checker.openmp_sentinels_in_column_one,
36-
"Omitted optional space in keywords": self.umdp3_checker.unseparated_keywords,
36+
# 'Captain Daves doomed test of destruction':
37+
# self.umdp3_checker.capitulated_keywords,
38+
"Lowercase Fortran keywords not permitted":
39+
self.umdp3_checker.capitalised_keywords,
40+
"OpenMP sentinels not in column one":
41+
self.umdp3_checker.openmp_sentinels_in_column_one,
42+
"Omitted optional space in keywords":
43+
self.umdp3_checker.unseparated_keywords,
3744
"GO TO other than 9999": self.umdp3_checker.go_to_other_than_9999,
38-
"WRITE without format": self.umdp3_checker.write_using_default_format,
39-
"Lowercase or CamelCase variable names only": self.umdp3_checker.lowercase_variable_names,
40-
"Use of dimension attribute": self.umdp3_checker.dimension_forbidden,
41-
"Continuation lines shouldn't start with &": self.umdp3_checker.ampersand_continuation,
42-
"Use of EQUIVALENCE or PAUSE": self.umdp3_checker.forbidden_keywords,
43-
"Use of older form of relational operator (.GT. etc.)": self.umdp3_checker.forbidden_operators,
44-
"Line longer than 80 characters": self.umdp3_checker.line_over_80chars,
45+
"WRITE without format":
46+
self.umdp3_checker.write_using_default_format,
47+
"Lowercase or CamelCase variable names only":
48+
self.umdp3_checker.lowercase_variable_names,
49+
"Use of dimension attribute":
50+
self.umdp3_checker.dimension_forbidden,
51+
"Continuation lines shouldn't start with &":
52+
self.umdp3_checker.ampersand_continuation,
53+
"Use of EQUIVALENCE or PAUSE":
54+
self.umdp3_checker.forbidden_keywords,
55+
"Use of older form of relational operator (.GT. etc.)":
56+
self.umdp3_checker.forbidden_operators,
57+
"Line longer than 80 characters":
58+
self.umdp3_checker.line_over_80chars,
4559
"Line includes tab character": self.umdp3_checker.tab_detection,
46-
"USEd printstatus_mod instead of umPrintMgr": self.umdp3_checker.printstatus_mod,
47-
"Used PRINT rather than umMessage and umPrint": self.umdp3_checker.printstar,
48-
"Used WRITE(6) rather than umMessage and umPrint": self.umdp3_checker.write6,
49-
"Used um_fort_flush rather than umPrintFlush": self.umdp3_checker.um_fort_flush,
50-
"Used Subversion keyword substitution which is prohibited": self.umdp3_checker.svn_keyword_subst,
51-
"Used !OMP instead of !$OMP": self.umdp3_checker.omp_missing_dollar,
52-
"Used #ifdef or #ifndef rather than #if defined() or #if !defined()": self.umdp3_checker.cpp_ifdef,
53-
"Presence of fortran comment in CPP directive": self.umdp3_checker.cpp_comment,
54-
"Used an archaic fortran intrinsic function": self.umdp3_checker.obsolescent_fortran_intrinsic,
55-
"EXIT statements should be labelled": self.umdp3_checker.exit_stmt_label,
56-
"Intrinsic modules must be USEd with an INTRINSIC keyword specifier": self.umdp3_checker.intrinsic_modules,
57-
"READ statements should have an explicit UNIT= as their first argument": self.umdp3_checker.read_unit_args,
60+
"USEd printstatus_mod instead of umPrintMgr":
61+
self.umdp3_checker.printstatus_mod,
62+
"Used PRINT rather than umMessage and umPrint":
63+
self.umdp3_checker.printstar,
64+
"Used WRITE(6) rather than umMessage and umPrint":
65+
self.umdp3_checker.write6,
66+
"Used um_fort_flush rather than umPrintFlush":
67+
self.umdp3_checker.um_fort_flush,
68+
"Used Subversion keyword substitution which is prohibited":
69+
self.umdp3_checker.svn_keyword_subst,
70+
"Used !OMP instead of !$OMP":
71+
self.umdp3_checker.omp_missing_dollar,
72+
"Used #ifdef/#ifndef rather than #if defined() or #if !defined()":
73+
self.umdp3_checker.cpp_ifdef,
74+
"Presence of fortran comment in CPP directive":
75+
self.umdp3_checker.cpp_comment,
76+
"Used an archaic fortran intrinsic function":
77+
self.umdp3_checker.obsolescent_fortran_intrinsic,
78+
"EXIT statements should be labelled":
79+
self.umdp3_checker.exit_stmt_label,
80+
"Intrinsic modules must be USEd with an INTRINSIC " +
81+
"keyword specifier": self.umdp3_checker.intrinsic_modules,
82+
"READ statements should have an explicit UNIT= as " +
83+
"their first argument":
84+
self.umdp3_checker.read_unit_args,
5885
}
5986

6087
def get_file_dispatch_table_fortran(
6188
self, filename: str = ""
6289
) -> Dict[str, Callable]:
6390
"""Get dispatch table for Fortran file tests"""
6491
return {
65-
"Warning - used an if-def due for retirement": self.umdp3_checker.retire_if_def,
66-
"File is missing at least one IMPLICIT NONE": self.umdp3_checker.implicit_none,
92+
"Warning - used an if-def due for retirement":
93+
self.umdp3_checker.retire_if_def,
94+
"File is missing at least one IMPLICIT NONE":
95+
self.umdp3_checker.implicit_none,
6796
"Never use STOP or CALL abort": self.umdp3_checker.forbidden_stop,
68-
"Use of Fortran function as a variable name": self.umdp3_checker.intrinsic_as_variable,
69-
"File missing crown copyright statement or agreement reference": self.umdp3_checker.check_crown_copyright,
70-
"File missing correct code owner comment": self.umdp3_checker.check_code_owner,
71-
"Used (/ 1,2,3 /) form of array initialisation, rather than [1,2,3] form": self.umdp3_checker.array_init_form,
97+
"Use of Fortran function as a variable name":
98+
self.umdp3_checker.intrinsic_as_variable,
99+
"File missing crown copyright statement or agreement reference":
100+
self.umdp3_checker.check_crown_copyright,
101+
"File missing correct code owner comment":
102+
self.umdp3_checker.check_code_owner,
103+
"Used (/ 1,2,3 /) form of array initialisation, rather than " +
104+
"[1,2,3] form": self.umdp3_checker.array_init_form,
72105
}
73106

74107
def get_diff_dispatch_table_c(self) -> Dict[str, Callable]:
75108
"""Get dispatch table for C diff tests"""
76109
return {
77-
"Line longer than 80 characters": self.umdp3_checker.line_over_80chars,
110+
"Line longer than 80 characters":
111+
self.umdp3_checker.line_over_80chars,
78112
"Line includes tab character": self.umdp3_checker.tab_detection,
79-
'Fixed-width Integer format specifiers must have a space between themselves and the string delimiter (the " character)': self.umdp3_checker.c_integral_format_specifiers,
113+
"Fixed-width Integer format specifiers must have a space " +
114+
"between themselves and the string delimiter (the \" character)":
115+
self.umdp3_checker.c_integral_format_specifiers,
80116
}
81117

82118
def get_file_dispatch_table_c(self) -> Dict[str, Callable]:
83119
"""Get dispatch table for C file tests"""
84120
return {
85-
"Warning - used an if-def due for retirement": self.umdp3_checker.retire_if_def,
121+
"Warning - used an if-def due for retirement":
122+
self.umdp3_checker.retire_if_def,
86123
"Used a deprecated C identifier": self.umdp3_checker.c_deprecated,
87-
"File missing crown copyright statement or agreement reference": self.umdp3_checker.check_crown_copyright,
88-
"File missing correct code owner comment": self.umdp3_checker.check_code_owner,
89-
"Used an _OPENMP if-def without also testing against SHUM_USE_C_OPENMP_VIA_THREAD_UTILS. (Or _OPENMP does not come first in the test.)": self.umdp3_checker.c_openmp_define_pair_thread_utils,
90-
"Used an _OPENMP && SHUM_USE_C_OPENMP_VIA_THREAD_UTILS if-def test in a logical combination with a third macro": self.umdp3_checker.c_openmp_define_no_combine,
91-
"Used !defined(_OPENMP) rather than defined(_OPENMP) with #else branch": self.umdp3_checker.c_openmp_define_not,
92-
"Used an omp #pragma (or #include <omp.h>) without protecting it with an _OPENMP if-def": self.umdp3_checker.c_protect_omp_pragma,
93-
"Used the #ifdef style of if-def, rather than the #if defined() style": self.umdp3_checker.c_ifdef_defines,
94-
"C Unit does not end with a final newline character": self.umdp3_checker.c_final_newline,
124+
"File missing crown copyright statement or agreement reference":
125+
self.umdp3_checker.check_crown_copyright,
126+
"File missing correct code owner comment":
127+
self.umdp3_checker.check_code_owner,
128+
"Used an _OPENMP if-def without also testing against " +
129+
"SHUM_USE_C_OPENMP_VIA_THREAD_UTILS. (Or _OPENMP does " +
130+
"not come first in the test.)":
131+
self.umdp3_checker.c_openmp_define_pair_thread_utils,
132+
"Used an _OPENMP && SHUM_USE_C_OPENMP_VIA_THREAD_UTILS if-def " +
133+
"test in a logical combination with a third macro":
134+
self.umdp3_checker.c_openmp_define_no_combine,
135+
"Used !defined(_OPENMP) rather than defined(_OPENMP) " +
136+
"with #else branch": self.umdp3_checker.c_openmp_define_not,
137+
"Used an omp #pragma (or #include <omp.h>) without " +
138+
"protecting it with an _OPENMP if-def":
139+
self.umdp3_checker.c_protect_omp_pragma,
140+
"Used the #ifdef style of if-def, rather than the #if " +
141+
"defined() style":
142+
self.umdp3_checker.c_ifdef_defines,
143+
"C Unit does not end with a final newline character":
144+
self.umdp3_checker.c_final_newline,
95145
}
96146

97147
def get_file_dispatch_table_all(self) -> Dict[str, Callable]:
98148
"""Get dispatch table for universal file tests"""
99149
return {
100-
"Line includes trailing whitespace character(s)": self.umdp3_checker.line_trail_whitespace,
150+
"Line includes trailing whitespace character(s)":
151+
self.umdp3_checker.line_trail_whitespace,
101152
}

script_umdp3_checker/fortran_keywords.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77
"""
88
List of the Fortran Keywords for the UMDP3 checker to check against.
99
Hopefully complete, but may need to be updated from time to time.
10-
These have been 'ordered' in terms of frequency of occurrence within the UM codebase in order to improve efficiency.
11-
ToDo: Current order may not be perfect, and could possibly be reviewed. However, it is probably 'good enough' for now.
10+
These have been 'ordered' in terms of frequency of occurrence within
11+
the UM codebase in order to improve efficiency.
12+
"""
13+
14+
"""
15+
TODO: Current order may not be perfect, and could possibly be reviewed.
16+
However, it is probably 'good enough' for now.
1217
"""
1318

1419
fortran_keywords = (

script_umdp3_checker/search_lists.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
# -----------------------------------------------------------------------------
66

77
"""
8-
Lists of words for Fortran checks. Some to confirm they are found in the approved form, some to test for as the intention is that they should no longer appear in the code.
8+
Lists of words for Fortran checks. Some to confirm they are found in the
9+
approved form, some to test for as the intention is that they should no longer
10+
appear in the code.
911
"""
1012

1113
# Obsolescent Fortran intrinsics : These should not be used in new code and

0 commit comments

Comments
 (0)