SCI/modules/slint/etc/slint.xml
file. In the same file, each criterion may be enabled (default) or disabled.
|
|
Checks the name of functions:
Checks that function calls are allowed: the list of concerned functions is configurable. Default = pause, abort, quit, exit
Looks for calls to deprecated functions.
Checks the number of lines inside a function body. Too many lines can decrease the readability. Default max lines number = 200.
Checks that the number of calls to return
in a function is less than a maximum. Default = only 1.
Checks if a function's argument is useless or not. Useless arguments can decrease the readability.
Checks if output arguments are defined before returning.
Checks that there is a space after each comma in the list of function arguments at call.
Checks if a function's argument (in/out) have no duplicate.
Checks that named arguments are called at the right place.
Checks that in an implicit list a:b one or both bounds a or b is not another implicit list.
Checks that the deprecated @ (not)
operator is not used. ~
must now be used.
Checks that no double negation is used. Such expressions shall be simplified.
The 'not equal' operator can be written '~=', '@=' or '<>', so checks that only one is used.
Checks if the equality operator is used in a single instruction.
Most often, comparing a number with %nan
isn't a good idea. Using isnan
is better.
Checks if the keyword global
is present.
function y=foo(x) global z endfunction | ![]() | ![]() |
Checks if a variable redefines a Scilab's constant, built-in or macro.
Redefining a Scilab's variable could have undesirable side-effects, so it should be avoided.
function y=foo(x) y = x endfunction function y=bar(x) y = foo(x) endfunction function y=oof(x) // call oof(2) doesn't return 2 ! foo = rand(x, 1); y = bar(x) endfunction | ![]() | ![]() |
Checks if there are comments including the TODO
mnemonic. Most often, TODO points to something that still must be achieved.
Checks the line length. Scilab code style recommends a 80-char maximal length. This is the default value for slint.
Checks if there is a single instruction on each line.
Checks that lines end with a semicolon.
Checks that each binary operator (+ - * / > >= < <= = == ..
is surrounded by spaces.
Checks if in a literal decimal number the correct exponent character is "e" or "E" (instead of "d" or "D"). In addition, checking that the decimal separator is a dot (instead of a comma) is also enabled by default.
Checks that expressions are bracketed: that increases the code readability.
Computes and checks the ratio between number of lines and number of comments is greater than the minimum required. Default ratio = 30%.
Computes the simplified McCabe complexity of the code, and compares it to a reference.
Checks if there are some empty blocks.
Checks that the number of statements in the boolean condition is less than a maximum. Default = 5 max.
Checks that the nesting depth of blocks is less than a maximum (default 3).
Checks select
against various tests:
else
case is expected. Enabled by default.case
, select
shall be replaced with a simpler if
statement. Warning enabled by default.case
or else
blocks are detected. Enabled by default.Checks for unreachable code after a break
or a return
instruction. Unreachable code decreases code readability.
Check that numbers of break
or continue
in a loop are less than a maximum (default = only 1).
Checks that an implicit list a:b is specified without any a or b bound set to %nan or %inf.
In calls to printf()
, checks when it's possible whether the number of %
formating directives matches the number of provided data. The data types matching is not tested.
Checks that calls to load()
and save()
use the names of variables instead of variables handles.
Checks the struct()
definition:
Checks when it's possible if the files opened with mopen()
are closed with mclose()
. Checks as well if mclose("all")
is not used: it may have some side-effects.
Checks that the error flag returned by some functions is actually retrieved and tested. The list of such functions is configurable.
Checks if an operation without assignment is used in a single instruction.
Checks if a variable's name matches a regex pattern. [some names yield an error and stop code-checking, like "3wrongName"]
Looks for variables that are locally defined but unused. Such variables are useless and can decrease the code readability.
Looks for variables used without being locally defined. Values of such variables are silently heritated from the calling level. This may have side effects.
function y=foo(x) scilab = 123; y = bar(x); endfunction function y=bar(x) Scilab = 456; y = scilab + 1; // typo error endfunction | ![]() | ![]() |