tasks/strip_code.js
function (line, lineNum) {
            if (line.trim() === '') {
                return;
            }


            function logAnyDelimiterType(line) {
                blocks.forEach(function (blockDef, blockIdx) {
                    if (blockDef.start.test(line) === true) {
                        fileStartDelimiters.push([blockIdx, lineNum, line.trim()]);
                    }
                    if (blockDef.end.test(line) === true) {
                        fileEndDelimiters.push([blockIdx, lineNum, line.trim()]);
                    }
                });
            }

            logAnyDelimiterType(line);


            var startCount = fileStartDelimiters.length;
            var endCount = fileEndDelimiters.length;

            /**
             * Checks that amount of start/end blocks are equal.
             *
             * @param blockDef
             * @param blockIdx
             */
            var checkBlocksParity = function (blockDef, blockIdx) {
                var block = blockStats[blockIdx];

                /**
                 * 'if' for start block check
                 */
                if (blockDef.start.test(line) === true) {

                    block.lastStartLine = lineNum;

                    if (block.startCount > block.endCount) {
                        generateMessage({
                            pattern: line.trim(),
                            lineNum: block.lastStartLine,
                            caseNum: 1
                        });
                    }

                    block.startCount++;
                }


                /**
                 * 'if' for end block check
                 */
                if (blockDef.end.test(line) === true) {

                    block.lastEndLine = lineNum;

                    if (block.endCount >= block.startCount) {
                        generateMessage({
                            pattern: line.trim(),
                            lineNum: block.lastEndLine,
                            caseNum: 2
                        });
                    }

                    block.endCount++;
                }
            };


            /**
             * Checks if any two (or more) pairs of start/end
             * blocks are intersecting.
             *
             * @param blockDef
             * @param blockIdx
             */
            var checkBlocksIntersection = function (blockDef, blockIdx) {
                if (blockDef.start.test(line)) {
                    blocksStack.push([blockIdx, lineNum, line.trim()]);
                }

                if (blockDef.end.test(line) && typeof last(blocksStack) !== "undefined") {
                    if (last(blocksStack)[0] === blockIdx) {
                        blocksStack.pop();
                    } else {
                        generateMessage({
                            start: last(blocksStack)[2],
                            pattern: line.trim(),
                            lineNum: last(blocksStack)[1],
                            endLineNum: lineNum,
                            caseNum: 3
                        });
                    }
                } else if (startCount - endCount > 1) {
                    generateMessage({
                        start: last(blocksStack)[2],
                        pattern: line.trim(),
                        lineNum: last(blocksStack)[1],
                        endLineNum: lineNum,
                        caseNum: 3
                    });
                }
            };

            if (options.parityCheck === true) {
                blocks.forEach(checkBlocksParity);
            }

            if (options.intersectionCheck === true) {
                blocks.forEach(checkBlocksIntersection);
            }
        }
function (line, lineNum) {
            if (line.trim() === '') {
                return;
            }


            function logAnyDelimiterType(line) {
                blocks.forEach(function (blockDef, blockIdx) {
                    if (blockDef.start.test(line) === true) {
                        fileStartDelimiters.push([blockIdx, lineNum, line.trim()]);
                    }
                    if (blockDef.end.test(line) === true) {
                        fileEndDelimiters.push([blockIdx, lineNum, line.trim()]);
                    }
                });
            }

            logAnyDelimiterType(line);


            var startCount = fileStartDelimiters.length;
            var endCount = fileEndDelimiters.length;

            /**
             * Checks that amount of start/end blocks are equal.
             *
             * @param blockDef
             * @param blockIdx
             */
            var checkBlocksParity = function (blockDef, blockIdx) {
                var block = blockStats[blockIdx];

                /**
                 * 'if' for start block check
                 */
                if (blockDef.start.test(line) === true) {

                    block.lastStartLine = lineNum;

                    if (block.startCount > block.endCount) {
                        generateMessage({
                            pattern: line.trim(),
                            lineNum: block.lastStartLine,
                            caseNum: 1
                        });
                    }

                    block.startCount++;
                }


                /**
                 * 'if' for end block check
                 */
                if (blockDef.end.test(line) === true) {

                    block.lastEndLine = lineNum;

                    if (block.endCount >= block.startCount) {
                        generateMessage({
                            pattern: line.trim(),
                            lineNum: block.lastEndLine,
                            caseNum: 2
                        });
                    }

                    block.endCount++;
                }
            };


            /**
             * Checks if any two (or more) pairs of start/end
             * blocks are intersecting.
             *
             * @param blockDef
             * @param blockIdx
             */
            var checkBlocksIntersection = function (blockDef, blockIdx) {
                if (blockDef.start.test(line)) {
                    blocksStack.push([blockIdx, lineNum, line.trim()]);
                }

                if (blockDef.end.test(line) && typeof last(blocksStack) !== "undefined") {
                    if (last(blocksStack)[0] === blockIdx) {
                        blocksStack.pop();
                    } else {
                        generateMessage({
                            start: last(blocksStack)[2],
                            pattern: line.trim(),
                            lineNum: last(blocksStack)[1],
                            endLineNum: lineNum,
                            caseNum: 3
                        });
                    }
                } else if (startCount - endCount > 1) {
                    generateMessage({
                        start: last(blocksStack)[2],
                        pattern: line.trim(),
                        lineNum: last(blocksStack)[1],
                        endLineNum: lineNum,
                        caseNum: 3
                    });
                }
            };

            if (options.parityCheck === true) {
                blocks.forEach(checkBlocksParity);
            }

            if (options.intersectionCheck === true) {
                blocks.forEach(checkBlocksIntersection);
            }
        }
function ( line , lineNum ) { if ( line . trim ( ) === '' ) { return ; } function logAnyDelimiterType ( line ) { blocks . forEach ( function ( blockDef , blockIdx ) { if ( blockDef . start . test ( line ) === true ) { fileStartDelimiters . push ( [ blockIdx , lineNum , line . trim ( ) ] ) ; } if ( blockDef . end . test ( line ) === true ) { fileEndDelimiters . push ( [ blockIdx , lineNum , line . trim ( ) ] ) ; } } ) ; } logAnyDelimiterType ( line ) ; var startCount = fileStartDelimiters . length ; var endCount = fileEndDelimiters . length ; /**
             * Checks that amount of start/end blocks are equal.
             *
             * @param blockDef
             * @param blockIdx
             */ var checkBlocksParity = function ( blockDef , blockIdx ) { var block = blockStats [ blockIdx ] ; /**
                 * 'if' for start block check
                 */ if ( blockDef . start . test ( line ) === true ) { block . lastStartLine = lineNum ; if ( block . startCount > block . endCount ) { generateMessage ( { pattern : line . trim ( ) , lineNum : block . lastStartLine , caseNum : 1 } ) ; } block . startCount ++ ; } /**
                 * 'if' for end block check
                 */ if ( blockDef . end . test ( line ) === true ) { block . lastEndLine = lineNum ; if ( block . endCount >= block . startCount ) { generateMessage ( { pattern : line . trim ( ) , lineNum : block . lastEndLine , caseNum : 2 } ) ; } block . endCount ++ ; } } ; /**
             * Checks if any two (or more) pairs of start/end
             * blocks are intersecting.
             *
             * @param blockDef
             * @param blockIdx
             */ var checkBlocksIntersection = function ( blockDef , blockIdx ) { if ( blockDef . start . test ( line ) ) { blocksStack . push ( [ blockIdx , lineNum , line . trim ( ) ] ) ; } if ( blockDef . end . test ( line ) && typeof last ( blocksStack ) !== "undefined" ) { if ( last ( blocksStack ) [ 0 ] === blockIdx ) { blocksStack . pop ( ) ; } else { generateMessage ( { start : last ( blocksStack ) [ 2 ] , pattern : line . trim ( ) , lineNum : last ( blocksStack ) [ 1 ] , endLineNum : lineNum , caseNum : 3 } ) ; } } else if ( startCount - endCount > 1 ) { generateMessage ( { start : last ( blocksStack ) [ 2 ] , pattern : line . trim ( ) , lineNum : last ( blocksStack ) [ 1 ] , endLineNum : lineNum , caseNum : 3 } ) ; } } ; if ( options . parityCheck === true ) { blocks . forEach ( checkBlocksParity ) ; } if ( options . intersectionCheck === true ) { blocks . forEach ( checkBlocksIntersection ) ; } }
Checks each line of the file.
Sub-functions check intersection and parity.
@param line
@param lineNum
Checks each line of the file . Sub - functions check intersection and parity .