Repository: eslint/eslint
File: lib/rules/array-callback-return.js (JavaScript)

Code before:

        let funcInfo = {
            arrayMethodName: null,
            upper: null,
            codePath: null,
            hasReturn: false,
            shouldCheck: false,
            node: null
        };

        /**
         * Checks whether or not the last code path segment is reachable.
         * Then reports this function if the segment is reachable.
         *
         * If the last code path segment is reachable, there are paths which are not
         * returned or thrown.
         * @param {ASTNode} node A node to check.
         * @returns {void}
         */
        function checkLastSegment(node) {

            if (!funcInfo.shouldCheck) {
                return;
            }

            // let messageId = null;
            const messageAndSuggestions = { messageId: "", suggest: [] };

            if (funcInfo.arrayMethodName === "forEach") {
                if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) {

                    if (options.allowVoid) {
                        if (isExpressionVoid(node.body)) {
                            return;
                        }

                        messageAndSuggestions.messageId = "expectedNoReturnValue";
                        messageAndSuggestions.suggest = [
                            {
                                messageId: "wrapBraces",
                                fix(fixer) {
                                    return curlyWrapFixer(sourceCode, node, fixer);
                                }
                            },
                            {
                                messageId: "prependVoid",
                                fix(fixer) {
                                    return voidPrependFixer(sourceCode, node.body, fixer);
                                }
                            }
                        ];

Review comment (refactor):
```suggestion
```

We can remove this if it's not needed.

Code after:

        let funcInfo = {
            arrayMethodName: null,
            upper: null,
            codePath: null,
            hasReturn: false,
            shouldCheck: false,
            node: null
        };

        /**
         * Checks whether or not the last code path segment is reachable.
         * Then reports this function if the segment is reachable.
         *
         * If the last code path segment is reachable, there are paths which are not
         * returned or thrown.
         * @param {ASTNode} node A node to check.
         * @returns {void}
         */
        function checkLastSegment(node) {

            if (!funcInfo.shouldCheck) {
                return;
            }

            const messageAndSuggestions = { messageId: "", suggest: [] };

            if (funcInfo.arrayMethodName === "forEach") {
                if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) {

                    if (options.allowVoid) {
                        if (isExpressionVoid(node.body)) {
                            return;
                        }

                        messageAndSuggestions.messageId = "expectedNoReturnValue";
                        messageAndSuggestions.suggest = [
                            {
                                messageId: "wrapBraces",
                                fix(fixer) {
                                    return curlyWrapFixer(sourceCode, node, fixer);
                                }
                            },
                            {
                                messageId: "prependVoid",
                                fix(fixer) {
                                    return voidPrependFixer(sourceCode, node.body, fixer);
                                }
                            }
                        ];
                    } else {