Version 1.42

About
Features
Download
Installation
Architecture
FAQ
The Importance
of Impatience
Credits

SourceForge.net Logo
The Squealer
Code Checking
 

The Squealer currently support Java code checking using The Frisker. The Frisker is designed to be a lightweight Java code checker, aiming to catch the major problems with Java source. It comes with a basic selection of about 10 key checks.

It is not expected to be either comprehensive or briming with fabulous features. Instead it aims to provide two three things we feel are currently missing from current Open Source Java code checkers:

  • User-friendly output. The Frisker's output is nice on the eye. It gives the basic data to the user and hides the irrelevances (e.g. file names, line numbers, etc.). The results, like other Squealer outputs are clickable (in Textpad).
  • Sensible output. Rules that report very small issues should be grouped. For example, a rule that reports on the use of tabs should present the user with a count of the number of tabs in the class. It is confusing to spit out one error per tab if a file contains 1000 tab characters. The Frisker is careful to present its output to give across the most meaning to the user.
  • Trivial to modify rules. Frisker checks are written in Perl fragments that are eval'ed. It therefore makes the checks arguably more accessible to modification.

Standard Checks

The Frisker works by first parsing a Java file (or collection of Java files) using simple text parsing (through file, class, field and methods). It constructs a data structure of all the data and provides access to the raw code for each. The next pass executes a rules file that contains code checks over the parsed file. The checks are written in Perl (as is The Frisker) and therefore full access to Perl is available in the checks. It comes with the following standard checks:
  • Method length. Severe error if methods are > 120 lines long.
  • Method complexity. Severe error if methods have a PhD complexity rating of > 15.
  • Method name variable. Warning if no variable for method name logging.
  • bad method name variable. Severe error if variable for method name logging is not identical to the method name.
  • No System.Out. Error if System.Out used.
  • String reference equality. Error if == used on string.
  • No Error Logging In Catch Block. Warning if no error logging statement in catch block.
  • 80 Character Limit. Group error if any lines are > 80 characters wide.
  • No tabs. Group warning if any tabs.
  • Naming standard. Subset of the Sun Naming Standards.

Example

Hit Ctrl F4 on your favourite Java file and you will get some results like the following. The first column indicates severity, the rest should be obvious, except to say that as always, the results are clickable (in Textpad).
Current project is: test

[D:/work/myproject/ejb/src/org/mycompany/myproject/wflow/WflowBean.java]

    [Statistics] 2363 Lines 271 Blank Lines

          4 Severe Errors, 4 Errors and 9 Warnings.

    [S] Method   'changeProcessAttribute()'   is too long (140 lines)
    [S] Method   'findProcessDefinitions()'   is too long (123 lines)
    [S] Method   'createProcess()'            is too long (137 lines)
    [S] Method   'changeProcessAttribute()'   *  is too complex (*PhD rating of 16)
    [E] Field    'SP_SUCCESS',                as an instance-scope variable 
                                                should be named 'SP_SUCCESS_i'.
    [E] Field    'REFERRAL_PROCESS_ID',       as an instance-scope variable 
                                                should be named 'REFERRAL_PROCESS_ID_i'.
    [E] Field    'wfHelper',                  as an instance-scope variable 
                                                should be named 'wfHelper_i'.
    [E] Class    'WflowBean'                  exceeds the 80 char limit 34 times (max: 100)

    [W] Method   'changeProcessAttribute()'   is missing a 'method' variable containing 
                                                method name
    [W] Method   'changeProcessAttribute()'   No error-level logging in catch block
    [W] Method   'changeAttribute()'          No error-level logging in catch block
    [W] Method   'changeAttribute()'          No error-level logging in catch block
    [W] Method   'findProcessInstance()'      No error-level logging in catch block
    [W] Method   'findProcessInstance()'      No error-level logging in catch block
    [W] Method   'createProcess()'            No error-level logging in catch block
    [W] Method   'createProcess()'            No error-level logging in catch block
    [W] Method   'startProcess()'             No error-level logging in catch block