Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321471

Summary: [checker] Return statement style
Product: [Tools] CDT Reporter: Marc-André Laperle <malaperle>
Component: cdt-codanAssignee: Elena Laskavaia <elaskavaia.cdt>
Status: RESOLVED FIXED QA Contact: Elena Laskavaia <elaskavaia.cdt>
Severity: enhancement    
Priority: P3 CC: cdtdoug
Version: 8.0   
Target Milestone: 8.0   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Return style checker
none
Return style checker, no regex + tests cdtdoug: iplog-

Description Marc-André Laperle CLA 2010-08-01 22:26:51 EDT
Created attachment 175678 [details]
Return style checker

In some organizations, it is required to use parenthesis in the return statement when the return type is not void. This checker is off by default and is configurable using a regular expression.
Comment 1 Tomasz Wesolowski CLA 2010-08-02 05:06:06 EDT
Thanks!
Btw- I can understand this being a company's convention, but what could be the actual advantage of making the return statement look like a function?
Comment 2 Marc-André Laperle CLA 2010-08-02 11:07:29 EDT
(In reply to comment #1)
> Thanks!
> Btw- I can understand this being a company's convention, but what could be the
> actual advantage of making the return statement look like a function?

No idea. I guess some conventions are there just to make the code more consistent. This checker was useful to me and I want to contribute as much as I can :)
Comment 3 Elena Laskavaia CLA 2010-08-12 21:08:34 EDT
1) Please project a junit test for this - it is very easy to write
2) Why you using rawSignature instead of check for expression type?
Comment 4 Marc-André Laperle CLA 2010-09-10 12:14:18 EDT
(In reply to comment #3)
> 1) Please project a junit test for this - it is very easy to write
> 2) Why you using rawSignature instead of check for expression type?

I'm not sure what you mean by checking for expression type. The idea is to check the return statement against a configurable regex so I need the string of the statement. Is there a better way to do this? About the junit test, I will provide a test for the checker using the default regex.
Comment 5 Elena Laskavaia CLA 2010-09-10 12:45:22 EDT
What is the point of having customizable expression type? I don't even heard of any other possible styles for return statement.
Checking for expression type if kind of

expr instanceof ExpressionInBrakets 
(I made up the ast node name but just as example)
Comment 6 Marc-André Laperle CLA 2010-09-16 12:55:56 EDT
Created attachment 179052 [details]
Return style checker, no regex + tests

Here is the new patch that does not use a regex and includes tests.
Comment 7 Elena Laskavaia CLA 2010-09-19 21:18:04 EDT
fixed on head, thanks for the patch