-
Notifications
You must be signed in to change notification settings - Fork 1
DLint Developer Guide
To add a new analysis:
- Add a .js file that implements the analysis to
src/js/analyses/dlint
. At the end of the execution, each analysis passes DLintWarnings to the DLint object (see existing analyses). - Add the analysis to
src/js/analyses/dlint/analyses.txt
. - Add tests for the analysis (see below).
Note: DLint framework currently adopts analysis2 API in Jalangi (not Jalangi2). It is primarily because Jalangi2 was not released when DLint was developed. We plan to migrate to Jalangi2 later.
Each analysis should have two kinds of tests:
- Example programs that should trigger a warning. For node.js tests, add such programs to
tests/dlint
and name the file so that it starts withbuggy_TheAnalysisName
, For browser tests, add such programs totests/html/dlint
in a directory that starts withbuggy_TheAnalysisName
. - Example programs that should not trigger a warning. For node.js tests, add such programs to
tests/dlint
and name the file so that it starts withokay_TheAnalysisName
. For browser tests, add such programs totests/html/dlint
in a directory that starts withokay_TheAnalysisName
.
To run all node.js tests (verbose
and debug
are optional):
node tests/dlint/runAllTests.js [ verbose | debug ]
To run all browser tests (requires the setup described above):
node tests/dlint/runAllBrowserTests.js
To run a DLint warning and JSHint warning test:
- First make sure that a web server is started:
python -m SimpleHTTPServer
- Run the following command on another terminal:
export PATH="`pwd`/scripts/path_unix":$PATH
./scripts/dlint_lintTest.sh
It will first run Dlint on those webpages, then dump javascript files and warnings on the disk, finally, it will check if the number of those warnings and their types are correct.
The current version of DLint consists of around 30 checkers. But you can choose which
checker to use when analyzing a web page.
To add/remove a checker, add/remove the checker's file name in src/js/analyses/dlint/analyses.txt
.
Note: Do not put any analysis before DLintPre.js
or after DLintPost.js
. If analysis A depends on analysis B, A should be listed after B in the configuration file.
A configuration of src/js/analyses/dlint/analyses.txt
(including all the analyses):
DLintPre.js
utils/Utils.js
utils/document.js
utils/RuntimeDB.js
utils/levenshtein.js
CheckNaN.js
ConcatUndefinedToString.js
NonObjectPrototype.js
SetFieldOfPrimitive.js
OverFlowUnderFlow.js
StyleMisuse.js
ToStringGivesNonString.js
UndefinedOffset.js
NoEffectOperation.js
AddEnumerablePropertyToObject.js
ConstructWrappedPrimitive2.js
FunctionToString.js
ShadowProtoProperty.js
NonNumericArrayProperty.js
OverwrittenPrototype.js
DelayedCodeString.js
GlobalThis.js
CompareFunctionWithPrimitives.js
InconsistentConstructor.js
FunctionCalledWithMoreArguments.js
IllegalUseOfArgumentsVariable.js
ForInArray.js
DoubleEvaluation.js
InconsistentNewCallPrefix.js
UncountableSpaceInRegexp.js
EmptyClassInRegexp.js
UseArrObjConstrWithoutArg.js
MissRadixArgInParseNum.js
FloatNumberEqualityComparison.js
jsBuiltinFunctionChecker/DocumentFunctionsMisuse.js
jsBuiltinFunctionChecker/StringFunctionsMisuse.js
jsBuiltinFunctionChecker/RegExpFunctionsMisuse.js
jsBuiltinFunctionChecker/NumberFunctionsMisuse.js
jsBuiltinFunctionChecker/ObjectFunctionsMisuse.js
jsBuiltinFunctionChecker/GlobalFunctionsMisuse.js
jsBuiltinFunctionChecker/ArrayFunctionsMisuse.js
jsBuiltinFunctionChecker/DateFunctionsMisuse.js
ExeStat.js
Timer.js
DLintPost.js