[ checkstyle-Bugs-3365590 ] ReturnCount test false positive

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[ checkstyle-Bugs-3365590 ] ReturnCount test false positive

SourceForge.net
Bugs item #3365590, was opened at 2011-07-12 21:16
Message generated for change (Settings changed) made by starburst684
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397078&aid=3365590&group_id=29721

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Tests
Group: None
Status: Open
Resolution: None
>Priority: 7
Private: No
Submitted By: Patrick Lemmens (starburst684)
Assigned to: Oliver Burn (oburn)
Summary: ReturnCount test false positive

Initial Comment:
Checkstyle raises a false positive for the "too many returns in method" check when an anonymous class is used within a method that itself has a return value.

The example is below.  The method has a single return, but the anonymous class (TabField() {...}) has 2 returns and this seems to be used by Checkstyle in counting the number of returns in the method.


This method shows "too many returns", but there is only 1 in the main method.

Code example:

    private TabField createDefaultTabField(final String fieldName, IModel modelTmp) {
        final String tabName = fieldName.substring(TabField.TAB_PREFIX.length());
        TabField defaultTabField = new TabField() {
            /**
             * {@inheritDoc}
             */
            @Override
            public String getTabName() {
                return tabName;
            }

            /**
             * {@inheritDoc}
             */
            @Override
            public Class<? extends IModel> getModelType() {
                return IModel.class;
            }
        };
        defaultTabField.init(modelTmp, new ActionMap().init());
        return defaultTabField;
    }


----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=397078&aid=3365590&group_id=29721

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Checkstyle-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/checkstyle-devel