BaseTools: drop GeneralCheckNonAscii() from ECC

The GeneralCheckNonAscii() function is a sledgehammer rejecting any file
containing any character outside of the 7-bit ASCII encoding space, as
well as the DEL character (which seems unrelated).

This conflicts with basic stuff like correctly spelling certain proper
nouns in comments (like copyright statements), or string literals (for
example in multi-language driver binding ComponentNames).

So rip it out, to be replaced by more fine-grained checks to be added as
identified and needed.

Signed-off-by: Leif Lindholm <quic_llindhol@quicinc.com>
This commit is contained in:
Leif Lindholm 2024-07-10 20:34:00 +01:00 committed by mergify[bot]
parent 8ade6d7bd1
commit 5366def8d0
4 changed files with 0 additions and 27 deletions

View File

@ -181,7 +181,6 @@ class Check(object):
# General Checking
def GeneralCheck(self):
self.GeneralCheckNonAscii()
self.UniCheck()
self.GeneralCheckNoTab()
self.GeneralCheckLineEnding()
@ -238,25 +237,6 @@ class Check(object):
OtherMsg = "File %s has trailing white spaces at line %s" % (Record[1], IndexOfLine)
EccGlobalData.gDb.TblReport.Insert(ERROR_GENERAL_CHECK_TRAILING_WHITE_SPACE_LINE, OtherMsg=OtherMsg, BelongsToTable='File', BelongsToItem=Record[0])
# Check whether file has non ASCII char
def GeneralCheckNonAscii(self):
if EccGlobalData.gConfig.GeneralCheckNonAscii == '1' or EccGlobalData.gConfig.GeneralCheckAll == '1' or EccGlobalData.gConfig.CheckAll == '1':
EdkLogger.quiet("Checking Non-ASCII char in file ...")
SqlCommand = """select ID, FullPath, ExtName from File where ExtName in ('.dec', '.inf', '.dsc', 'c', 'h')"""
RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
for Record in RecordSet:
if Record[2].upper() not in EccGlobalData.gConfig.BinaryExtList:
op = open(Record[1]).readlines()
IndexOfLine = 0
for Line in op:
IndexOfLine += 1
IndexOfChar = 0
for Char in Line:
IndexOfChar += 1
if ord(Char) > 126:
OtherMsg = "File %s has Non-ASCII char at line %s column %s" % (Record[1], IndexOfLine, IndexOfChar)
EccGlobalData.gDb.TblReport.Insert(ERROR_GENERAL_CHECK_NON_ASCII, OtherMsg=OtherMsg, BelongsToTable='File', BelongsToItem=Record[0])
# C Function Layout Checking
def FunctionLayoutCheck(self):
self.FunctionLayoutCheckReturnType()

View File

@ -59,7 +59,6 @@ _ConfigFileToInternalTranslation = {
"GeneralCheckNoProgma":"GeneralCheckNoProgma",
"GeneralCheckNoTab":"GeneralCheckNoTab",
"GeneralCheckNo_Asm":"GeneralCheckNo_Asm",
"GeneralCheckNonAscii":"GeneralCheckNonAscii",
"GeneralCheckTabWidth":"GeneralCheckTabWidth",
"GeneralCheckTrailingWhiteSpaceLine":"GeneralCheckTrailingWhiteSpaceLine",
"GeneralCheckUni":"GeneralCheckUni",
@ -179,8 +178,6 @@ class Configuration(object):
self.GeneralCheckCarriageReturn = 1
# Check whether the file exists
self.GeneralCheckFileExistence = 1
# Check whether file has non ASCII char
self.GeneralCheckNonAscii = 1
# Check whether UNI file is valid
self.GeneralCheckUni = 1
# Check Only use CRLF (Carriage Return Line Feed) line endings.

View File

@ -14,7 +14,6 @@ ERROR_GENERAL_CHECK_NO_ASM = 1004
ERROR_GENERAL_CHECK_NO_PROGMA = 1005
ERROR_GENERAL_CHECK_CARRIAGE_RETURN = 1006
ERROR_GENERAL_CHECK_FILE_EXISTENCE = 1007
ERROR_GENERAL_CHECK_NON_ASCII = 1008
ERROR_GENERAL_CHECK_UNI = 1009
ERROR_GENERAL_CHECK_UNI_HELP_INFO = 1010
ERROR_GENERAL_CHECK_INVALID_LINE_ENDING = 1011
@ -113,7 +112,6 @@ gEccErrorMessage = {
ERROR_GENERAL_CHECK_NO_PROGMA : """There should be no use of "#progma" in source file except "#pragma pack(#)\"""",
ERROR_GENERAL_CHECK_CARRIAGE_RETURN : "There should be a carriage return at the end of the file",
ERROR_GENERAL_CHECK_FILE_EXISTENCE : "File not found",
ERROR_GENERAL_CHECK_NON_ASCII : "File has invalid Non-ASCII char",
ERROR_GENERAL_CHECK_UNI : "File is not a valid UTF-16 UNI file",
ERROR_GENERAL_CHECK_UNI_HELP_INFO : "UNI file that is associated by INF or DEC file need define the prompt and help information.",
ERROR_GENERAL_CHECK_INVALID_LINE_ENDING : "Only CRLF (Carriage Return Line Feed) is allowed to line ending.",

View File

@ -62,8 +62,6 @@ GeneralCheckNoProgma = 1
GeneralCheckCarriageReturn = 1
# Check whether the file exists
GeneralCheckFileExistence = 1
# Check whether file has non ASCII char
GeneralCheckNonAscii = 1
# Check whether UNI file is valid
GeneralCheckUni = 1
# Check Only use CRLF (Carriage Return Line Feed) line endings.