Commit 9c88ae5a authored by Christian Kamm's avatar Christian Kamm
Browse files

Doc: Add documentation stubs for all existing QmlJS checks.



Change-Id: I9f068ca358702f4033b21f64d5eee155d2580b83
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@nokia.com>
parent 852b2a94
......@@ -347,41 +347,374 @@
\endlist
\section1 Checking JavaScript Syntax
\section1 Checking JavaScript and QML Syntax
You can run static checks on JavaScript to find common problems, such as:
You can run static checks on the QML and JavaScript code in your project
to find common problems.
\list
\o Duplicate or conflicting variable, function, and formal parameter
declarations
\o Variables and functions that are used before they are declared
\o Possibly unsafe uses of the == or != operators
\o Comma expressions, except in \c for statements
\o Expression statements, except function or method calls, assignments,
or \c delete
\o Assignments within conditions (such as, \c {if (a = b)})
\o Case blocks within a switch that do not end with a return, break,
continue, or throw and that are not empty
\o Nested block statements
To run the checks, select \gui {Tools > QML/JS > Run Checks} or press
\key Ctrl+Shift+C. The results are shown in the \gui {QML Analysis}
filter of the \gui {Issues} output pane.
\o \c with statements
\o \c void expressions
\section1 List of JavaScript and QML Checks
\endlist
Many of the JavaScript checks are similar to the ones in Douglas
Crockford's JSLint tool and are explained well on
\l{http://www.jslint.com/lint.html}{the JSLint website}.
To run the checks, select \gui {Tools > QML/JS > Run Checks} or press
\key Ctrl+Shift+C. The results are shown in the \gui {QML Analysis}
filter of the \gui {Issues} output pane.
\table
\header
\o Id
\o Severity
\o Message
\o Description
\row
\o M1
\o Error
\o Invalid value for enum
\o
\row
\o M2
\o Error
\o Enum value must be a string or a number
\o
\row
\o M3
\o Error
\o Number value expected
\o
\row
\o M4
\o Error
\o Boolean value expected
\o
\row
\o M5
\o Error
\o String value expected
\o
\row
\o M6
\o Error
\o Invalid URL
\o
\row
\o M7
\o Warning
\o File or directory does not exist
\o
\row
\o M8
\o Error
\o Invalid color
\o
\row
\o M9
\o Error
\o Anchor line expected
\o
\row
\o M10
\o Error
\o Duplicate property binding
\o
\row
\o M11
\o Error
\o Id expected
\o
\row
\o M14
\o Error
\o Invalid id
\o
\row
\o M15
\o Error
\o Duplicate id
\o
\row
\o M16
\o Error
\o Invalid property name 'name'
\o
\row
\o M17
\o Error
\o 'Name' does not have members
\o
\row
\o M18
\o Error
\o 'Field' is not a member of 'object'
\o
\row
\o M19
\o Warning
\o Assignment in condition
\o
\row
\o M20
\o Warning
\o Unterminated non-empty case block
\o
\row
\o M23
\o Warning
\o Do not use 'eval'
\o
\row
\o M28
\o Warning
\o Unreachable
\o
\row
\o M29
\o Warning
\o Do not use 'with'
\o
\row
\o M30
\o Warning
\o Do not use comma expressions
\o
\row
\o M31
\o Warning
\o Unnecessary message suppression
\o
\row
\o M103
\o Warning
\o 'Name' is already a formal parameter
\o
\row
\o M104
\o Warning
\o 'Name' is already a function
\o
\row
\o M105
\o Warning
\o Var 'name' is used before its declaration
\o
\row
\o M106
\o Warning
\o 'Name' is already a var
\o
\row
\o M107
\o Warning
\o 'Name' is declared more than once
\o
\row
\o M108
\o Warning
\o Function 'name' is used before its declaration
\o
\row
\o M109
\o Warning
\o Do not use 'Boolean' as a constructor
\o
\row
\o M110
\o Warning
\o Do not use 'String' as a constructor
\o
\row
\o M111
\o Warning
\o Do not use 'Object' as a constructor
\o
\row
\o M112
\o Warning
\o Do not use 'Array' as a constructor
\o
\row
\o M113
\o Warning
\o Do not use 'Function' as a constructor
\o
\row
\o M114
\o Hint
\o The 'function' keyword and the opening parenthesis should be separated by a single space
\o
\row
\o M115
\o Warning
\o Do not use stand-alone blocks
\o
\row
\o M116
\o Warning
\o Do not use void expressions
\o
\row
\o M117
\o Warning
\o Confusing pluses
\o
\row
\o M119
\o Warning
\o Confusing minuses
\o
\row
\o M121
\o Hint
\o Declare all function vars on a single line
\o
\row
\o M123
\o Hint
\o Unnecessary parentheses
\o
\row
\o M126
\o Warning
\o == and != may perform type coercion, use === or !== to avoid
\o
\row
\o M127
\o Warning
\o Expression statements should be assignments, calls or delete expressions only
\o
\row
\o M201
\o Hint
\o Var declarations should be at the start of a function
\o
\row
\o M202
\o Hint
\o Only use one statement per line
\o
\row
\o M300
\o Error
\o Unknown component
\o
\row
\o M301
\o Error
\o Could not resolve the prototype 'name' of 'object'
\o
\row
\o M302
\o Error
\o Could not resolve the prototype 'name'
\o
\row
\o M303
\o Error
\o Prototype cycle, the last non-repeated component is 'name'
\o
\row
\o M304
\o Error
\o Invalid property type 'name'
\o
\row
\o M305
\o Warning
\o == and != perform type coercion, use === or !== to avoid
\o
\row
\o M306
\o Warning
\o Calls of functions that start with an uppercase letter should use 'new'
\o
\row
\o M307
\o Warning
\o 'new' should only be used with functions that start with an uppercase letter
\o
\row
\o M308
\o Warning
\o Do not use 'Number' as a constructor
\o
\row
\o M309
\o Hint
\o Use spaces around binary operators
\o
\row
\o M310
\o Warning
\o Unintentional empty block, use ({}) for empty object literal
\o
\row
\o M311
\o Hint
\o Use 'type' instead of 'var' or 'variant' to improve performance
\o
\endtable
*/
......
......@@ -72,6 +72,8 @@ public:
StaticAnalysisMessages::StaticAnalysisMessages()
{
// When changing a message or severity, update the documentation, currently
// in creator-editors.qdoc, accordingly.
newMsg(ErrInvalidEnumValue, Error,
tr("invalid value for enum"));
newMsg(ErrEnumValueMustBeStringOrNumber, Error,
......@@ -165,7 +167,7 @@ StaticAnalysisMessages::StaticAnalysisMessages()
newMsg(ErrUnknownComponent, Error,
tr("unknown component"));
newMsg(ErrCouldNotResolvePrototypeOf, Error,
tr("could not resolve the prototype '%1'' of '%2'"), 2);
tr("could not resolve the prototype '%1' of '%2'"), 2);
newMsg(ErrCouldNotResolvePrototype, Error,
tr("could not resolve the prototype '%1'"), 1);
newMsg(ErrPrototypeCycle, Error,
......
......@@ -54,6 +54,9 @@ enum Severity
enum Type
{
// Changing the numbers can break user code.
// When adding a new check, also add it to the documentation, currently
// in creator-editors.qdoc.
UnknownType = 0,
ErrInvalidEnumValue = 1,
ErrEnumValueMustBeStringOrNumber = 2,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment