@@ -254,7 +254,8 @@ def unseparated_keywords(self, lines: List[str]) -> TestResult:
254254 clean_line = self .remove_quoted (line )
255255 for pattern in [f"\\ b{ kw } \\ b" for kw in unseparated_keywords_list ]:
256256 if re .search (pattern , clean_line , re .IGNORECASE ):
257- self .add_extra_error (f"unseparated keyword in line: { line .strip ()} " )
257+ self .add_extra_error (f"unseparated keyword in line: "
258+ f"{ line .strip ()} " )
258259 failures += 1
259260 error_log = self .add_error_log (
260261 error_log ,
@@ -279,7 +280,8 @@ def go_to_other_than_9999(self, lines: List[str]) -> TestResult:
279280 clean_line = self .remove_quoted (line )
280281 clean_line = re .sub (r"!.*$" , "" , clean_line )
281282
282- if match := re .search (r"\bGO\s*TO\s+(\d+)" , clean_line , re .IGNORECASE ):
283+ if match := re .search (r"\bGO\s*TO\s+(\d+)" , clean_line ,
284+ re .IGNORECASE ):
283285 label = match .group (1 )
284286 if label != "9999" :
285287 self .add_extra_error (f"GO TO { label } " )
@@ -305,10 +307,12 @@ def write_using_default_format(self, lines: List[str]) -> TestResult:
305307 clean_line = self .remove_quoted (line )
306308 clean_line = re .sub (r"!.*$" , "" , clean_line )
307309
308- if re .search (r"\bWRITE\s*\(\s*\*\s*,\s*\*\s*\)" , clean_line , re .IGNORECASE ):
310+ if re .search (r"\bWRITE\s*\(\s*\*\s*,\s*\*\s*\)" , clean_line ,
311+ re .IGNORECASE ):
309312 self .add_extra_error ("WRITE(*,*) found" )
310313 failures += 1
311- error_log = self .add_error_log (error_log , "WRITE(*,*) found" , count + 1 )
314+ error_log = self .add_error_log (error_log , "WRITE(*,*) found" ,
315+ count + 1 )
312316 output = f"Checked { count + 1 } lines, found { failures } failures."
313317 return TestResult (
314318 checker_name = "WRITE using default format" ,
@@ -344,8 +348,9 @@ def lowercase_variable_names(self, lines: List[str]) -> TestResult:
344348 "" ,
345349 clean_line ,
346350 )
347- if re .search (r"[A-Z]{2,}" , clean_line ):
348- self .add_extra_error ("UPPERCASE variable name" )
351+ if match := re .search (r"([A-Z]{2,})" , clean_line ):
352+ self .add_extra_error ("UPPERCASE variable name : "
353+ f"{ match [1 ]} " )
349354 failures += 1
350355 error_log = self .add_error_log (
351356 error_log , "UPPERCASE variable name" , count + 1
@@ -418,7 +423,8 @@ def forbidden_keywords(self, lines: List[str]) -> TestResult:
418423 clean_line = self .remove_quoted (line )
419424 clean_line = re .sub (r"!.*$" , "" , clean_line )
420425
421- if re .search (r"\b(EQUIVALENCE|PAUSE)\b" , clean_line , re .IGNORECASE ):
426+ if re .search (r"\b(EQUIVALENCE|PAUSE)\b" , clean_line ,
427+ re .IGNORECASE ):
422428 self .add_extra_error ("forbidden keyword" )
423429 failures += 1
424430 error_log = self .add_error_log (
@@ -453,7 +459,8 @@ def forbidden_operators(self, lines: List[str]) -> TestResult:
453459 )
454460
455461 return TestResult (
456- checker_name = "Use of older form of relational operator " + "(.GT. etc.)" ,
462+ checker_name = "Use of older form of relational operator " +
463+ "(.GT. etc.)" ,
457464 failure_count = failures ,
458465 passed = (failures == 0 ),
459466 output = f"Checked { count + 1 } lines, found { failures } failures." ,
@@ -469,7 +476,8 @@ def line_over_80chars(self, lines: List[str]) -> TestResult:
469476 if len (line .rstrip ()) > 80 :
470477 self .add_extra_error ("line too long" )
471478 failures += 1
472- error_log = self .add_error_log (error_log , "line too long" , count + 1 )
479+ error_log = self .add_error_log (error_log , "line too long" ,
480+ count + 1 )
473481
474482 return TestResult (
475483 checker_name = "Line longer than 80 characters" ,
@@ -533,7 +541,8 @@ def printstar(self, lines: List[str]) -> TestResult:
533541 if re .search (r"\bPRINT\s*\*" , clean_line , re .IGNORECASE ):
534542 self .add_extra_error ("PRINT * used" )
535543 failures += 1
536- error_log = self .add_error_log (error_log , "PRINT * used" , count + 1 )
544+ error_log = self .add_error_log (error_log , "PRINT * used" ,
545+ count + 1 )
537546
538547 return TestResult (
539548 checker_name = "Use of PRINT rather than umMessage and umPrint" ,
@@ -555,7 +564,8 @@ def write6(self, lines: List[str]) -> TestResult:
555564 if re .search (r"\bWRITE\s*\(\s*6\s*," , clean_line , re .IGNORECASE ):
556565 self .add_extra_error ("WRITE(6) used" )
557566 failures += 1
558- error_log = self .add_error_log (error_log , "WRITE(6) used" , count + 1 )
567+ error_log = self .add_error_log (error_log , "WRITE(6) used" ,
568+ count + 1 )
559569
560570 return TestResult (
561571 checker_name = "Use of WRITE(6) rather than umMessage and umPrint" ,
@@ -611,10 +621,12 @@ def omp_missing_dollar(self, lines: List[str]) -> TestResult:
611621 error_log = {}
612622 count = - 1
613623 for count , line in enumerate (lines ):
614- if re .search (r"!\s*OMP\b" , line ) and not re .search (r"!\$OMP" , line ):
624+ if (re .search (r"!\s*OMP\b" , line ) and
625+ not re .search (r"!\$OMP" , line )):
615626 self .add_extra_error ("!OMP without $" )
616627 failures += 1
617- error_log = self .add_error_log (error_log , "!OMP without $" , count + 1 )
628+ error_log = self .add_error_log (error_log , "!OMP without $" ,
629+ count + 1 )
618630
619631 return TestResult (
620632 checker_name = "!OMP without $" ,
@@ -662,7 +674,8 @@ def cpp_comment(self, lines: List[str]) -> TestResult:
662674 self .add_extra_error ("Fortran comment in CPP directive" )
663675 failures += 1
664676 error_log = self .add_error_log (
665- error_log , "Fortran comment in CPP directive" , count + 1
677+ error_log , "Fortran comment in CPP directive" ,
678+ count + 1
666679 )
667680
668681 return TestResult (
@@ -687,7 +700,8 @@ def obsolescent_fortran_intrinsic(self, lines: List[str]) -> TestResult:
687700 self .add_extra_error (f"obsolescent intrinsic: { intrinsic } " )
688701 failures += 1
689702 error_log = self .add_error_log (
690- error_log , f"obsolescent intrinsic: { intrinsic } " , count + 1
703+ error_log , f"obsolescent intrinsic: { intrinsic } " ,
704+ count + 1
691705 )
692706
693707 return TestResult (
@@ -735,8 +749,10 @@ def intrinsic_modules(self, lines: List[str]) -> TestResult:
735749 for module in intrinsic_modules :
736750 if re .search (
737751 rf"\bUSE\s+(::)*\s*{ module } \b" , clean_line , re .IGNORECASE
738- ) and not re .search (r"\bINTRINSIC\b" , clean_line , re .IGNORECASE ):
739- self .add_extra_error (f"intrinsic module { module } without INTRINSIC" )
752+ ) and not re .search (r"\bINTRINSIC\b" , clean_line ,
753+ re .IGNORECASE ):
754+ self .add_extra_error (f"intrinsic module { module } "
755+ "without INTRINSIC" )
740756 failures += 1
741757 error_log = self .add_error_log (
742758 error_log ,
@@ -761,7 +777,8 @@ def read_unit_args(self, lines: List[str]) -> TestResult:
761777 clean_line = self .remove_quoted (line )
762778 clean_line = re .sub (r"!.*$" , "" , clean_line )
763779
764- if match := re .search (r"\bREAD\s*\(\s*([^,)]+)" , clean_line , re .IGNORECASE ):
780+ if match := re .search (r"\bREAD\s*\(\s*([^,)]+)" , clean_line ,
781+ re .IGNORECASE ):
765782 first_arg = match .group (1 ).strip ()
766783 if not first_arg .upper ().startswith ("UNIT=" ):
767784 self .add_extra_error ("READ without explicit UNIT=" )
@@ -803,7 +820,8 @@ def retire_if_def(self, lines: List[str]) -> TestResult:
803820 self .add_extra_error (f"retired if-def: { match .group (1 )} " )
804821 failures += 1
805822 error_log = self .add_error_log (
806- error_log , f"retired if-def: { match .group (1 )} " , count + 1
823+ error_log , f"retired if-def: { match .group (1 )} " ,
824+ count + 1
807825 )
808826 return TestResult (
809827 checker_name = "retired if-def" ,
@@ -845,7 +863,8 @@ def forbidden_stop(self, lines: List[str]) -> TestResult:
845863 clean_line = self .remove_quoted (line )
846864 clean_line = re .sub (r"!.*$" , "" , clean_line )
847865
848- if re .search (r"\b(STOP|CALL\s+abort)\b" , clean_line , re .IGNORECASE ):
866+ if re .search (r"\b(STOP|CALL\s+abort)\b" , clean_line ,
867+ re .IGNORECASE ):
849868 self .add_extra_error ("STOP or CALL abort used" )
850869 failures += 1
851870 error_log = self .add_error_log (
@@ -910,7 +929,8 @@ def check_crown_copyright(self, lines: List[str]) -> TestResult:
910929 found_copyright = True
911930
912931 if not found_copyright :
913- self .add_extra_error ("missing copyright or crown copyright statement" )
932+ self .add_extra_error (
933+ "missing copyright or crown copyright statement" )
914934 error_log = self .add_error_log (
915935 error_log , "missing copyright or crown copyright statement" , 0
916936 )
@@ -935,14 +955,16 @@ def check_code_owner(self, lines: List[str]) -> TestResult:
935955 file_content = "\n " .join (lines )
936956 found_code_owner = False
937957 error_log = {}
938- if "Code Owner:" in file_content or "code owner" in file_content .lower ():
958+ if ("Code Owner:" in file_content or
959+ "code owner" in file_content .lower ()):
939960 # print(f"Debug: Found {file_content.lower()}")
940961 found_code_owner = True
941962
942963 # This is often a warning rather than an error
943964 if not found_code_owner :
944965 self .add_extra_error ("missing code owner comment" )
945- error_log = self .add_error_log (error_log , "missing code owner comment" , 0 )
966+ error_log = self .add_error_log (error_log ,
967+ "missing code owner comment" , 0 )
946968 return TestResult (
947969 checker_name = "Code Owner Comment" ,
948970 failure_count = 0 if found_code_owner else 1 ,
@@ -1014,7 +1036,8 @@ def c_deprecated(self, lines: List[str]) -> int:
10141036 for line in lines :
10151037 for identifier in deprecated_c_identifiers :
10161038 if re .search (rf"\b{ identifier } \b" , line ):
1017- self .add_extra_error (f"deprecated C identifier: { identifier } " )
1039+ self .add_extra_error (
1040+ f"deprecated C identifier: { identifier } " )
10181041 failures += 1
10191042
10201043 return failures
@@ -1041,7 +1064,8 @@ def c_openmp_define_no_combine(self, lines: List[str]) -> int:
10411064 ) or re .search (
10421065 r"&&.*_OPENMP.*&&.*SHUM_USE_C_OPENMP_VIA_THREAD_UTILS" , line
10431066 ):
1044- self .add_extra_error ("OpenMP defines combined with third macro" )
1067+ self .add_extra_error (
1068+ "OpenMP defines combined with third macro" )
10451069 failures += 1
10461070
10471071 return failures
0 commit comments