Scilint Warnings Documentation
Warning Tables
Function Warnings
Local warnings are warnings that can be detected through a local analysis of one function.
Identifier | Title | Implemented |
---|---|---|
W001 | variable not initialized | 0.1 |
W002 | unused function argument | 0.1 |
W003 | duplicate function argument | 0.2 |
W004 | duplicate return variable | 0.2 |
W005 | function argument used as return variable | 0.2 |
W006 | return variable is never set | 0.2 |
W007 | return variable used as a local variable | 0.2 |
W008 | for variable modified in for loop | 0.3 |
W009 | redefinition of primitive function | 0.3 |
W010 | redefinition of local function | 0.3 |
W011 | redefinition of library function | 0.3 |
W012 | unexpected string argument | 0.3 |
W013 | primitive with too many arguments | 0.3 |
File Warnings
File warnings are warnings that can be detected through a local analysis of one file. In such an analysis, it is supposed that the identifiers of functions defined in the file can only be used to call these functions.Identifier | Title | Implemented |
---|
Global Warnings
Global warnings are warnings that can be detected through a global analysis of a whole project, i.e. knowning all the files used in the project.Identifier | Title | Implemented |
---|
Typing Warnings
Identifier | Title | Implemented |
---|
Style Warnings
Style warnings are warnings caused by not following the style conventions.
See http://wiki.scilab.org/Code%20Conventions%20for%20the%20Scilab%20Programming%20Language
Identifier | Title | Implemented |
---|
Function Warnings
Local warnings are warnings that can be detected through a local analysis of one function.
W001 --- variable not initialized
function z = f() z = cos(x) // W001: "x" not initialized endfunction
Remarks : referencing global variables should be avoided, variables should be passed as arguments. This variable can also have been introduced by a 'resume' in a function called from the current context, or an 'execstr' function
W002 --- unused function argument
function z = f(y)// W002: "y" is not used z = cos(0) endfunction
W003 --- duplicate function argument
Two arguments in a function definition have the same name.
Note: it can only be an error !
Example:
function z = f(a,b,a)// W003: argument "a" appears twice z = cos(a) + cos(b) endfunction
W004 --- duplicate return variable
Two return variables in a function definition have the same name.
Note: it can only be an error !
Example:
function [a,b,a] = f() // W004: return variable "a" appears twice a = cos(0) b = cos(pi) c = cos(pi*2) endfunction
W005 --- function argument used as return variable
A function argument appears as a return variable.
Example:
function [a] = f(a) // W005: return variable "a" is also an argument a = cos(a) endfunction
However, this is often used as an optimization to avoid a useless copy when returning a matrix.
W006 --- return variable is never set
A return variable is never set in the function, whatever the path taken.
Example:
function [a,b] = f() // W006: return variable "a" is never set if( a > 0 ) then b = 1; else b = 0; end; endfunctionNote that, on this example, warnings W001 (variable ``a'' not initialized) and W007 (return variable used as a variable) should also be displayed.
W007 --- return variable used as a local variable
A return variable is used in the function as a local variable: return variables should only be assigned values, never read.
Example:
function [a] = f() a = 0; for i = 1:100, a = a +1; // W007: return variable "a" used as a local variable end; endfunction
However, this is often used as an optimization to avoid a useless copy when returning a matrix.
W008 --- for variable modified in for loop
Modifying the variable of a 'for' loop does not change the loop behavior.
for i=1:100 i=i+2; // W: modifying variable of 'for' loop does not change loop behavior disp(i); end
W009 --- redefinition of primitive function
Redefining a primitive is usually a bad idea
function disp(x) // W009: redefinition of primitive 'disp' disp(x+1) endfunction
W010 --- redefinition of local function
The code is redefining a function that was already defined in this scope.
function f() function pr(x), disp(x),endfunction function pr(x,y) // W010: redefinition of local function 'pr' disp(x,y) endfunction endfunction
W011 --- redefinition of library function
The code is redefining a function that was already defined in the toplevel scope.
function pr(x), disp(x),endfunction function f() function pr(x,y) // W010: redefinition of library function 'pr' disp(x,y) endfunction endfunction
W012 --- unexpected string argument
Some functions expect a limited list of strings as flags. If another string is passed, it is usually an error.
function f() execstr("x=1", "x=2"); // W012: "x=2" instead of "catcherr" endfunction
W013 --- primitive with too many arguments
Some primitives expect a limited number of arguments. Providing more arguments will usually trigger an error at runtime.
function f(a,b) disp(strcat('a=',a,'b=',b); // W013: 'strcat' expects fewer arguments endfunction
File Warnings
File warnings are warnings that can be detected through a local analysis of one file. In such an analysis, it is supposed that the identifiers of functions defined in the file can only be used to call these functions.Global Warnings
Global warnings are warnings that can be detected through a global analysis of a whole project, i.e. knowning all the files used in the project.Typing Warnings
Style Warnings
Style warnings are warnings caused by not following the style conventions.
See http://wiki.scilab.org/Code%20Conventions%20for%20the%20Scilab%20Programming%20Language