Package com.jalios.jcms.tools
Class JsChecker
java.lang.Object
com.jalios.jcms.tools.AbstractChecker
com.jalios.jcms.tools.JsChecker
Check JS for bad coding practices.
Eg. console.log, alert(...), debugger, trailing comma, ...
- Since:
- jcms-7.1.3, jcms-8.0.0
- Author:
- Sylvain Devaux
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class com.jalios.jcms.tools.AbstractChecker
CHANNEL, PROP_SUFFIX_FILE_FILTER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckAlert(CheckResult result, CheckedFile file, CheckerContext checkerContext) static CheckResultstatic voidcheckConsole(CheckResult result, CheckedFile file, CheckerContext checkerContext) static voidcheckDebugger(CheckResult result, CheckedFile file, CheckerContext checkerContext) static voidcheckPattern(String checkName, org.apache.oro.text.regex.Pattern invalidUsePattern, Pattern[] authorizedUsePatterns, CheckResult result, CheckedFile file) Check if the specified invalid pattern is part of any lines in the javascript File being analyezstatic voidMethods inherited from class com.jalios.jcms.tools.AbstractChecker
getCheckedFile, getFileList, getFileList, loadLanguageProperties, loadProperties, loadProperties, saveError
-
Field Details
-
IGNORE_CHECK_CONSOLE
- See Also:
-
IGNORE_CHECK_ALERT
- See Also:
-
IGNORE_CHECK_DEBUGGER
- See Also:
-
IGNORE_CHECK_HREF
- See Also:
-
COMMENT_REGEX
- See Also:
-
-
Constructor Details
-
JsChecker
public JsChecker()
-
-
Method Details
-
main
- Throws:
IOException
-
checkAll
- Throws:
IOException
-
checkConsole
public static void checkConsole(CheckResult result, CheckedFile file, CheckerContext checkerContext) throws IOException - Throws:
IOException
-
checkAlert
public static void checkAlert(CheckResult result, CheckedFile file, CheckerContext checkerContext) throws IOException - Throws:
IOException
-
checkDebugger
public static void checkDebugger(CheckResult result, CheckedFile file, CheckerContext checkerContext) throws IOException - Throws:
IOException
-
checkPattern
public static void checkPattern(String checkName, org.apache.oro.text.regex.Pattern invalidUsePattern, 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
-