Class JsChecker


  • public class JsChecker
    extends AbstractChecker
    Check JS for bad coding practices.

    Eg. console.log, alert(...), debugger, trailing comma, ...

    Since:
    jcms-7.1.3, jcms-8.0.0
    Version:
    $Revision: 134564 $
    Author:
    Sylvain Devaux
    • Constructor Detail

      • JsChecker

        public JsChecker()
    • Method Detail

      • main

        public static void main​(java.lang.String[] args)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • checkAll

        public static CheckResult checkAll​(java.io.File webappDir)
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • checkDebugger

        public static void checkDebugger​(CheckResult result,
                                         CheckedFile file,
                                         CheckerContext checkerContext)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • checkPattern

        public static void checkPattern​(java.lang.String checkName,
                                        org.apache.oro.text.regex.Pattern invalidUsePattern,
                                        java.util.regex.Pattern[] authorizedUsePatterns,
                                        CheckResult result,
                                        CheckedFile file)
        Check if the specified invalid pattern is part of any lines in the javascript File being analyez
        Parameters:
        checkName - the name of the check being formed (used in log message)
        invalidUsePattern - a perl Pattern which MUST NOT be part of any line (excepted in comment)
        authorizedUsePatterns - optional perl pattern which are authorized even though invalid pattern has matched
        result - the CheckResult instance filled with the analysis result
        file - wrapper of file being tested