Scheck

pad edited this page Apr 2, 2014 · 13 revisions

Bugs finder

Introduction

The goal of scheck is to find stupid mistakes like typo in your code. For instance on this code:

function foo($avar) {
  return $avarr;
}

scheck will complain with:

demos/scheck.php:4:9: CHECK: use of undefined variable $avarr
demos/scheck.php:3:13: CHECK: unused Param variable $avar

See https://github.com/facebook/pfff/blob/master/main_scheck.ml

Motivations

Many programming language compilers offer strong type-checking as well as static detection of certain mistakes like the use of undeclared variables. This is not the case in many dynamic languages like PHP or Javascript. Fortunately one can write programming language frontend a la lint that detect those mistakes.

Synopsis

The synopsis is:

$ scheck [-strict] <files_or_dirs>

Features

Here are the checks currently done by scheck:

Use of undeclared variable

Unused variable

Use of undefined entity (class, function, constant)

Mutiple definitions of entity

Wrong number of arguments in a call

Wrong order of arguments in a call

TODO Use of undefined member

This requires a class analysis

TODO Use of undefined method

This requires a class analysis.

TODO Incompatible type

This requires a sophisticated type inference analysis.

Ugly code (use of dynamic features)

Dead statement

This uses a control flow graph analysis.

Dead entity

This uses a simple global use/def analysis. This requires to have access to the whole codebase.

Other analysis

See Features#Bug_finder

Examples

FAQ

Future work

Related work

research: - Dawson Engler work - YuanYuan Zhou work

tools: - JSLint