40ANTS-CRITIC

40ANTS-CRITIC ASDF System Details

Installation

This system can be installed from Ultralisp like this:

(ql-dist:install-dist "http://dist.ultralisp.org/"
                      :prompt nil)

If you are going to use this utility from a command line, then you might install it using Roswell:

$ ros install  40ants/40ants-critic
Installing from github 40ants/40ants-critic
To load "40ants-critic":
  Load 1 ASDF system:
    40ants-critic
; Loading "40ants-critic"

; compiling file "/Users/art/.roswell/local-projects/40ants/critic/src/critic.lisp" (written 20 FEB 2022 12:54:52 PM):

; wrote /Users/art/.cache/common-lisp/sbcl-2.1.11-macosx-x64/Users/art/.roswell/local-projects/40ants/critic/src/critic-tmp5GEXGEG5.fasl
; compilation finished in 0:00:00.026
[1/3] System '40ants-critic' found. Loading the system..
[2/3] Processing build-hook..
[3/3] Attempting to install the scripts in roswell/ subdirectory of the system...
Found 1 scripts: lisp-critic
/Users/art/.roswell/bin/lisp-critic

Also, you might use this checker in your CI pipeline on the GitHub. It might check all pull-requests to ensure the code will remain clean.

To learn more about using it as a part of the GitHub workflow, read 40ants-ci::@critic section.

Usage

This wrapper provides a simple way to analyze code of a single ASDF system. To get some advices, use critique-asdf-system function. Difference between this function and LISP-CRITIC:CRITIQUE-FILE function is that the latter outputs all forms from the file even if there is no any advices.

Also, critique-asdf-system returns a number of found problems which is useful for CI pipelines. For example, lisp-critic script uses this number to report that the unix command was failed:

lisp-critic reblocks-text-editor


#P"/Users/art/projects/lisp/zibaldone/src/utils/text.lisp"
**********************************************************************

(DEFUN REMOVE-HTML-TAGS (HTML-STRING)
  (LET* ((RESULT
          (CL-PPCRE:REGEX-REPLACE-ALL "<[^>]+>" HTML-STRING "")))
    (IF (STRING= RESULT +ZERO-WIDTH-SPACE+)
        RESULT
        (CL-PPCRE:REGEX-REPLACE-ALL +ZERO-WIDTH-SPACE+ RESULT ""))))
----------------------------------------------------------------------
[let*-single]: There's no need for LET* here. Use LET unless you can't.
----------------------------------------------------------------------

You can ignore all let*-single warnings by adding --ignore 'let*-single' command line option or put a special comment before the top-level form:

;; ignore-critiques: let*-single
(defun remove-html-tags (html-string)
   (let* ((result
     ...

Such comment can enumerate a multiple comma-separated critiques names.

API

function
name &key (out \*standard-output\*) (ignore nil)

Outputs advices on how given ASDF system can be improved. This function analyzes all lisp files of the given system and outputs advices on how code might be improved.

NAME argument should be a string or symbol designator of ASDF system.

IGNORE argument can be a list of string. Each string should be a code shown in the square brackets in the critique output.

OUT argument is optional. It should be an output stream to write advices to.

Result of the function is number of found problems.