Scilint Warnings Documentation

Warning Tables

Function Warnings

Local warnings are warnings that can be detected through a local analysis of one function.

IdentifierTitleImplemented
L001variable not initialized0.1
L002unused function argument0.1
L003duplicate function argument0.2
L004duplicate return variable 0.2
L005function argument used as return variable 0.2
L006return variable is never set0.2
L007return variable used as a local variable0.2
L008for variable modified in for loop0.3
L009redefinition of primitive function0.3
L010redefinition of local function0.3
L011redefinition of library function0.3
L012unexpected string argument0.3
L013primitive with too many arguments0.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.
IdentifierTitleImplemented

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.
IdentifierTitleImplemented

Typing Warnings

IdentifierTitleImplemented

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

IdentifierTitleImplemented
S001Function names should start with lowercase0.4
S002Function names should not contain digits0.4
S003Inconsistent string delimiters0.4
S004Inconsistent matrix delimiters0.4
S006Spaces in operator0.4
S007Spaces around dot0.4
S008Missing function parameters0.4
S009Missing catch0.4
S010Misused keyword0.4
S011Keyword as shell arg0.4
S012Deprecated0.4
S013Ambiguous dot at left of operator0.4
S014Ambiguous dot at right of operator0.4

Function Warnings

Local warnings are warnings that can be detected through a local analysis of one function.

L001 --- 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

L002 --- unused function argument

function z = f(y)// W002: "y" is not used
  z = cos(0)
endfunction

L003 --- 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

L004 --- 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

L005 --- 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.

L006 --- 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;
endfunction
Note that, on this example, warnings W001 (variable ``a'' not initialized) and W007 (return variable used as a variable) should also be displayed.

L007 --- 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.

L008 --- 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

L009 --- redefinition of primitive function

Redefining a primitive is usually a bad idea

function disp(x) // W009: redefinition of primitive 'disp'
  disp(x+1)
endfunction

L010 --- 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

L011 --- 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

L012 --- 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

L013 --- 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

S001 --- Function names should start with lowercase

S002 --- Function names should not contain digits

S003 --- Inconsistent string delimiters

A string starting with a " (resp. a ' ) should end with a " (resp. a ' ). This warning is also output when a delimiter is escaped with two different characters such as in "this is a quote: "'" which should be written "this is a quote: ''"

S004 --- Inconsistent matrix delimiters

A string starting with a [ (resp. a { ) should end with a ] (resp. a } ).

S006 --- Spaces in operator

Scilab's interpreter accepts spaces inside some operators, such as . * . which is not a good idea.

S007 --- Spaces around dot

In some cases, a space before the dot of a field access gives a different sense to the code line. For instance, v.f = 3 assigns 3 to the field f of the variable v, while v . f = 3 tests is the value of this field is 3.It is thus a good idea to avoid spaces around all dots.

S008 --- Missing function parameters

It is recommended to make explicit an empty list of arguments by writing () instead of just breaking the line after the function name.

S009 --- Missing catch

A try block without a catch statement is probably useless.

S010 --- Misused keyword

Using a language keyword as a variable, field name or anything but a keyword makes code difficult to read.

To correct this, rename the variable.

S011 --- Keyword as shell arg

Using a language keyword unquoted inside a shell call such as in disp end makes code difficult to read.

To correct this, surround the keyword with quotes, such as disp 'end'

S012 --- Deprecated

This warning is issued when a deprecated function, operator or construct is encountered.

S013 --- Ambiguous dot at left of operator

This warning is issued when a sequence similar to 3./2 is encountered, which is interpreted as 3. / 2 but could be read as 3 ./ 2

To correct it, just insert a space if you meant a dotted operator or remove the dot otherwise.

S014 --- Ambiguous dot at right of operator

This warning is issued when a sequence similar to 3/.2 is encountered, which is interpreted as 3 / .2 but could be read as 3 /. 2

To correct it, just insert a space in the right place or surround the right hand side with parentheses.