| Summary: | [checker] Return statement style | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] CDT | Reporter: | Marc-André Laperle <malaperle> | ||||||
| Component: | cdt-codan | Assignee: | 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: |
|
||||||||
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? (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 :) 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? (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. 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) Created attachment 179052 [details]
Return style checker, no regex + tests
Here is the new patch that does not use a regex and includes tests.
fixed on head, thanks for the patch *** cdt cvs genie on behalf of elaskavaia *** Bug 321471 Return statement style patch from Marc-Andre Laperle [+] ReturnStyleCheckerTest.java http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/ReturnStyleCheckerTest.java?root=Tools_Project&revision=1.1&view=markup [*] AutomatedIntegrationSuite.java 1.12 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/test/AutomatedIntegrationSuite.java?root=Tools_Project&r1=1.11&r2=1.12 [*] plugin.xml 1.29 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/plugin.xml?root=Tools_Project&r1=1.28&r2=1.29 [*] bundle.properties 1.5 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/OSGI-INF/l10n/bundle.properties?root=Tools_Project&r1=1.4&r2=1.5 [+] ReturnStyleChecker.java http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/ReturnStyleChecker.java?root=Tools_Project&revision=1.1&view=markup |
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.