public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Bob Feng" <bob.c.feng@intel.com>
To: "Fan, ZhijuX" <zhijux.fan@intel.com>,
	"devel@edk2.groups.io" <devel@edk2.groups.io>
Cc: "Gao, Liming" <liming.gao@intel.com>
Subject: Re: [PATCH] BaseTools:ECC fails to detect function header comments issue
Date: Tue, 21 Jan 2020 01:35:53 +0000	[thread overview]
Message-ID: <6585dd1ef8a24adfa3ab5d097bd0c0ef@intel.com> (raw)
In-Reply-To: <f2b155bdb7de40cd9711956b63517702@intel.com>

I have 2 comments.
1. CheckParamName may return None. But according to other part of this function, it should return True or False.
2. The meaning of ParamList.pop(0) is not much clear. 

Thanks,
Bob

-----Original Message-----
From: Fan, ZhijuX 
Sent: Monday, January 20, 2020 4:40 PM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>
Subject: [PATCH] BaseTools:ECC fails to detect function header comments issue

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1523

When the keyword after @param doesn't match the actual function parameter name, ECC doesn't detect such issue

The patch is going to fix this issue

Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
---
 BaseTools/Source/Python/Ecc/c.py | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py
index a30122a45f..e42463952d 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -2554,6 +2554,20 @@ def CheckGeneralDoxygenCommentLayout(Str, StartLine, ErrorMsgList, CommentId= -1
         ErrorMsgList.append('Line %d : @retval appear before @param ' % StartLine)
         PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Comment, @retval appear before @param  ', TableName, CommentId)
 
+def CheckParamName(ParamName, Tag):
+    ParamList = Tag.split()
+    if len(ParamList) > 1:
+        ParamList.pop(0)
+        for Item in ParamList:
+            if Item.find('[') > 0 and Item.find(']') > 0:
+                continue
+            if ParamName != Item.strip():
+                return True
+            else:
+                return False
+    else:
+        return True
+
 def CheckFunctionHeaderConsistentWithDoxygenComment(FuncModifier, FuncHeader, FuncStartLine, CommentStr, CommentStartLine, ErrorMsgList, CommentId= -1, TableName=''):
 
     ParamList = GetParamList(FuncHeader) @@ -2608,7 +2622,7 @@ def CheckFunctionHeaderConsistentWithDoxygenComment(FuncModifier, FuncHeader, Fu
                                 PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Comment, <%s> does NOT have %s ' % ((TagPartList[0] + ' ' + TagPartList[1]).replace('\n', '').replace('\r', ''), '[' + InOutStr + ']'), TableName, CommentId)
 
 
-            if Tag.find(ParamName) == -1 and ParamName != 'VOID' and ParamName != 'void':
+            if (Tag.find(ParamName) == -1 or CheckParamName(ParamName, Tag)) and ParamName != 'VOID' and ParamName != 'void':
                 ErrorMsgList.append('Line %d : in Comment, <%s> does NOT consistent with parameter name %s ' % (CommentStartLine, (TagPartList[0] + ' ' + TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName))
                 PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in Comment, <%s> does NOT consistent with parameter name %s ' % ((TagPartList[0] + ' ' + TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName), TableName, CommentId)
             Index += 1
--
2.14.1.windows.1


      reply	other threads:[~2020-01-21  1:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20  8:40 [PATCH] BaseTools:ECC fails to detect function header comments issue Fan, ZhijuX
2020-01-21  1:35 ` Bob Feng [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6585dd1ef8a24adfa3ab5d097bd0c0ef@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox