Package com.jalios.jcms.tools
Class JsChecker
- java.lang.Object
-
- com.jalios.jcms.tools.AbstractChecker
-
- com.jalios.jcms.tools.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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
COMMENT_REGEX
static java.lang.String
IGNORE_CHECK_ALERT
static java.lang.String
IGNORE_CHECK_CONSOLE
static java.lang.String
IGNORE_CHECK_DEBUGGER
static java.lang.String
IGNORE_CHECK_HREF
static java.lang.String
REVISION
-
Fields inherited from class com.jalios.jcms.tools.AbstractChecker
CHANNEL, PROP_SUFFIX_FILE_FILTER, UTF8Charset
-
-
Constructor Summary
Constructors Constructor Description JsChecker()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkAlert(CheckResult result, CheckedFile file, CheckerContext checkerContext)
static CheckResult
checkAll(java.io.File webappDir)
static void
checkConsole(CheckResult result, CheckedFile file, CheckerContext checkerContext)
static void
checkDebugger(CheckResult result, CheckedFile file, CheckerContext checkerContext)
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 analyezstatic void
main(java.lang.String[] args)
-
Methods inherited from class com.jalios.jcms.tools.AbstractChecker
getCheckedFile, getFileList, getFileList, loadLanguageProperties, loadProperties, loadProperties, saveError
-
-
-
-
Field Detail
-
REVISION
public static final java.lang.String REVISION
- See Also:
- Constant Field Values
-
IGNORE_CHECK_CONSOLE
public static final java.lang.String IGNORE_CHECK_CONSOLE
- See Also:
- Constant Field Values
-
IGNORE_CHECK_ALERT
public static final java.lang.String IGNORE_CHECK_ALERT
- See Also:
- Constant Field Values
-
IGNORE_CHECK_DEBUGGER
public static final java.lang.String IGNORE_CHECK_DEBUGGER
- See Also:
- Constant Field Values
-
IGNORE_CHECK_HREF
public static final java.lang.String IGNORE_CHECK_HREF
- See Also:
- Constant Field Values
-
COMMENT_REGEX
public static final java.lang.String COMMENT_REGEX
- See Also:
- Constant Field Values
-
-
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
-
checkConsole
public static void checkConsole(CheckResult result, CheckedFile file, CheckerContext checkerContext) throws java.io.IOException
- Throws:
java.io.IOException
-
checkAlert
public static void checkAlert(CheckResult result, CheckedFile file, CheckerContext checkerContext) 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 matchedresult
- the CheckResult instance filled with the analysis resultfile
- wrapper of file being tested
-
-