Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

leadingUnderscoreAccess rule not working properly #1588

Closed
Nightmaster opened this issue Jul 30, 2015 · 2 comments
Closed

leadingUnderscoreAccess rule not working properly #1588

Nightmaster opened this issue Jul 30, 2015 · 2 comments
Assignees
Milestone

Comments

@Nightmaster
Copy link

We are using JSCS on our Angular application, but we got some problems with the leadingUnderscoreAccess rule. I let you see the code, JSCS rule and output to see why I say this.

JavaScript demo code:

(function()
{
    angular.module('bug-demo').controller('DemoController', DemoController);

    DemoController.$inject = ['$scope', '$log'];

    function DemoController($scope, $log)
    {
        $scope.myFunctionWorking = function myFunctionWorking()
        {
            $scope.$on('bug', _jscsFailsHereWithJsDocRule)

            /**
            * Here is the demonstration that JSCS don't find the @private annotation
            *
            * @private
            **/
            function _jscsFailsHereWithJsDocRule()
            {
                _jscsWillFailEvenWithAccessAnnotation();
            }

            /**
            * Here is the demonstration that JSCS don't find the @access annotation no more
            *
            * @access private
            **/
            function _jscsWillFailEvenWithAccessAnnotation()
            {
                $log.debug('JSCS will report innapropriate error here');
            }
        }
    }
})();

.jscrc file used:

{
    "disallowEmptyBlocks": true,
    "disallowKeywords": ["with"],
    "disallowMixedSpacesAndTabs": true,
    "disallowMultipleSpaces": true,
    "disallowPaddingNewlinesInBlocks": true,
    "disallowQuotedKeysInObjects": "allButReserved",
    "disallowSpaceAfterObjectKeys": true,
    "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
    "disallowSpaceBeforeComma": true,
    "disallowSpaceBeforeSemicolon": true,
    "disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true },
    "disallowSpacesInsideArrayBrackets": true,
    "disallowSpacesInsideParentheses": true,
    "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
    "disallowTrailingWhitespace": true,

    "jsDoc": {
        "checkAnnotations": "jsdoc3",
        "checkParamNames": true,
        "requireParamTypes": true,
        "checkRedundantParams": true,
        "checkReturnTypes": true,
        "checkRedundantReturns": true,
        "checkTypes": "capitalizedNativeCase",
        "checkRedundantAccess": true,
        "leadingUnderscoreAccess": true,
        "requireNewlineAfterDescription": true
    },

    "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
    "requireCapitalizedConstructors": true,
    "requireCommaBeforeLineBreak": true,
    "requireCurlyBraces": ["try", "catch"],
    "requireDotNotation": true,
    "requireFunctionDeclarations": true,
    "requireLineFeedAtFileEnd": true,
    "requireMultipleVarDecl": true,
    "requireOperatorBeforeLineBreak": ["?", "+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=", ","],
    "requireParenthesesAroundIIFE": true,
    "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ","],
    "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
    "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="],
    "requireSpaceBeforeObjectValues": true,
    "requireSpaceBetweenArguments": true,
    "requireSpacesInConditionalExpression": true,
    "requireSpacesInForStatement": true,
    "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true },
    "requireSpacesInsideObjectBrackets": "all",
    "requireYodaConditions": true,

    "validateLineBreaks": "LF",
    "validateQuoteMarks": "'",


    "excludeFiles": ["node_modules/**", "bower_components/**", "src/assets/**"],
    "fileExtensions": [".js"]
}

Console output – runned with JSCS --verbose:

jscs leadingunderscoreaccess rule not working demo

Running environment:

OS / Application Version
Windows 7
Node.js 0.12.6
JSCS 2.0.0
@mrjoelkemp
Copy link
Member

Thanks for reporting @Nightmaster.

cc @zxqfox

@qfox qfox self-assigned this Aug 2, 2015
@qfox
Copy link
Member

qfox commented Aug 2, 2015

I don't see the bug with correct jsdoc format:

            /**
             * Here is the demonstration that JSCS don't find the @private annotation
             *
             * @private
             */
            function _jscsFailsHereWithJsDocRule()
            {
                _jscsWillFailEvenWithAccessAnnotation();
            }

            /**
             * Here is the demonstration that JSCS don't find the @access annotation no more
             *
             * @access private
             */
            function _jscsWillFailEvenWithAccessAnnotation()
            {
                $log.debug('JSCS will report innapropriate error here');
            }

I think we should skip checking if there are no correctly formatted jsdoc comment block. Right?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants