-
Notifications
You must be signed in to change notification settings - Fork 677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix style issues and improve vera++ rules. #896
Fix style issues and improve vera++ rules. #896
Conversation
if {[regexp {\w\*\s\w+} $line]} { | ||
if {[regexp {\w\*\s\w+} $line] | ||
|| [regexp {\w\*\)} $line] | ||
|| [regexp {\w\*$} $line]} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got badly misled by the name of the rule. The first/old pattern matches something like x* abc
(or, more realistically, the tail of void* p
). The new ones match void*)
and void*
-at-end-of-line. If I'm not mistaken, none of these are pointer dereferences but pointer declarations.
As for the original pattern: why does \s
have no +
multiplier? And why does the second \w
have one? Would changing these cause too many false positives?
If we are already touching this file, it would be good to get it right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first check is for type* var_name
The second is for type casting for a pointer type (type*)
The third one is for return values of functions. They are usually in a separate line.
The plus for \w
is not necessary, we can remove if it bothers you. \s+
may be a good idea.
About the name, my opinion is that the *
symbol is the pointer dereference operator, but the expressions are really pointer declerations. I'd like to refer the *
in the name of the rule not the expressions, but we can change the name of rule if it is misleading. Please suggest a proper rule name and message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made a terrible mistake. I've taken a look at the C99 standard :). Now I know that *
is a punctuator, which is known as an operator, if (and only if) used in a context where it specifies an operation (6.4.6 p2). However, the first and the third checks are for declarators (6.7.5), while the second check is for the type-name part of a cast operator (6.5.4), which leads back again to declarations (6.7.6 p2).
Could jerry_pointer_declarator_space.tcl work as a filename, and "there should be a space between the referenced type and the pointer declarator" as a message work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@akiss77, it convenient for me. I'll update the file name and the message.
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
b66bd4f
to
a7715a5
Compare
@akiss77, I've updated the PR. |
LGTM (FWIW) |
LGTM |
JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]