Check for spaces/newlines after opening a form
authorFrank Duncan <frank@kank.net>
Sun, 12 Jul 2015 15:15:55 +0000 (10:15 -0500)
committerFrank Duncan <frank@kank.net>
Sun, 12 Jul 2015 15:15:55 +0000 (10:15 -0500)
resources/good.lisp
resources/newlineafteropenparens.lisp [new file with mode: 0644]
resources/spaceafteropenparens.lisp [new file with mode: 0644]
src/main/checker.lisp

index bca3e8595a6243e004687924596eed7759abca99..adb5e3797718e50a07ec79a6c1d168429c14583f 100644 (file)
@@ -5,7 +5,10 @@
 
 (defun hello-world (a b c)
  (progn
 
 (defun hello-world (a b c)
  (progn
-  (with-open-file (str "increasinglylongfilenamesfailme.dat" :direction :input :if-does-not-exist :create)
-   (when
-    (read-line str)
-    (format t "This file had some things in int, yay!~%")))))
+  (let
+   ((x y)
+    (z 9))
+   (with-open-file (str "increasinglylongfilenamesfailme.dat" :direction :input :if-does-not-exist :create)
+    (when
+     (read-line str)
+     (format t "This file had some things in int, yay!~%")))))
diff --git a/resources/newlineafteropenparens.lisp b/resources/newlineafteropenparens.lisp
new file mode 100644 (file)
index 0000000..749ffba
--- /dev/null
@@ -0,0 +1,15 @@
+(in-package #:nothing)
+
+(defun small-guy (a b) (+ a b))
+(defun small-guy-2 (a b) (+ a b))
+
+(defun hello-world (a b c)
+ (progn
+  (let
+   ((x y)
+    (z 9))
+   (with-open-file (str "increasinglylongfilenamesfailme.dat" :direction :input :if-does-not-exist :create)
+    (
+     when
+     (read-line str)
+     (format t "This file had some things in int, yay!~%")))))
diff --git a/resources/spaceafteropenparens.lisp b/resources/spaceafteropenparens.lisp
new file mode 100644 (file)
index 0000000..4cab605
--- /dev/null
@@ -0,0 +1,14 @@
+(in-package #:nothing)
+
+(defun small-guy (a b) (+ a b))
+(defun small-guy-2 (a b) (+ a b))
+
+(defun hello-world (a b c)
+ (progn
+  (let
+   ((x y)
+    (z 9))
+   (with-open-file (str "increasinglylongfilenamesfailme.dat" :direction :input :if-does-not-exist :create)
+    ( when
+     (read-line str)
+     (format t "This file had some things in int, yay!~%")))))
index 3db05e29e1b74c823cacf381b164c8676874a02e..02a3d2da21c603c0f898eda01cd410babbeb3f2f 100644 (file)
@@ -1,7 +1,8 @@
 (in-package #:style-checker)
 
 ; Rules
 (in-package #:style-checker)
 
 ; Rules
-; - Elements in each form must be indented the same amount
+; - Elements on new line in each form must be indented the same amount
+; * No space/newline after open parens
 ; * No form longer than 50 lines
 ; * Top level multiline forms must be separated by exactly one space
 ; * No line longer than 120 characters
 ; * No form longer than 50 lines
 ; * Top level multiline forms must be separated by exactly one space
 ; * No line longer than 120 characters
@@ -40,6 +41,7 @@
     :beginning-of-line-with-separator ; empty space in there
     :beginning-of-symbols
     :beginning-of-symbols-with-separator
     :beginning-of-line-with-separator ; empty space in there
     :beginning-of-symbols
     :beginning-of-symbols-with-separator
+    :first-symbol-of-form ; After an open parens
     :all ; matches everything
    )))
 
     :all ; matches everything
    )))
 
 ; These are in reverse order
 (progn
  (setf *evaluators* nil)
 ; These are in reverse order
 (progn
  (setf *evaluators* nil)
- (defevaluator :all "\\t"
-  (constantly "Must not use tabs"))
- (defevaluator :begin "\\(in-package[^\\)]*\\)"
-  (lambda () (set-state :normal)))
- (defevaluator :beginning-of-line-with-separator :eof
-  (constantly "Must not end with empty line"))
- (defevaluator :beginning-of-line-with-separator "\\n"
-  (constantly "Must not have two empty lines in a row"))
- (defevaluator :begin ".*"
-  (constantly "Must begin with in-package form"))
- (defevaluator :normal "\\( *in-package "
-  (constantly "Only one in-package per file"))
+ (defevaluator :all "\\t" (constantly "Must not use tabs"))
+ (defevaluator :begin "\\(in-package[^\\)]*\\)" (lambda () (set-state :normal)))
+ (defevaluator :beginning-of-line-with-separator :eof (constantly "Must not end with empty line"))
+ (defevaluator :beginning-of-line-with-separator "\\n" (constantly "Must not have two empty lines in a row"))
+ (defevaluator :begin ".*" (constantly "Must begin with in-package form"))
+ (defevaluator :normal "\\( *in-package " (constantly "Only one in-package per file"))
  (defevaluator :normal "\\n"
   (lambda ()
    (set-state :beginning-of-line)
    (incf *line-no*)
    (setf *col-no* -1)
    nil))
  (defevaluator :normal "\\n"
   (lambda ()
    (set-state :beginning-of-line)
    (incf *line-no*)
    (setf *col-no* -1)
    nil))
- (defevaluator :normal " +\\n"
-  (constantly "No whitespace at end of line"))
- (defevaluator :beginning-of-line " *"
-  (lambda () (set-state :beginning-of-symbols)))
- (defevaluator :beginning-of-line-with-separator " *"
-  (lambda () (set-state :beginning-of-symbols-with-separator)))
+ (defevaluator :normal " +\\n" (constantly "No whitespace at end of line"))
+ (defevaluator :beginning-of-line " *" (lambda () (set-state :beginning-of-symbols)))
+ (defevaluator :beginning-of-line-with-separator " *" (lambda () (set-state :beginning-of-symbols-with-separator)))
  (defevaluator :beginning-of-symbols "\\n"
   (lambda ()
    (if
     (< 0 *col-no*)
     "No whitespace only lines"
     (set-state :beginning-of-line-with-separator))))
  (defevaluator :beginning-of-symbols "\\n"
   (lambda ()
    (if
     (< 0 *col-no*)
     "No whitespace only lines"
     (set-state :beginning-of-line-with-separator))))
- (defevaluator :beginning-of-symbols "\\)"
-  (constantly "No hanging close parens"))
- (defevaluator :beginning-of-symbols-with-separator "\\)"
-  (constantly "No hanging close parens"))
+ (defevaluator :beginning-of-symbols "\\)" (constantly "No hanging close parens"))
+ (defevaluator :beginning-of-symbols-with-separator "\\)" (constantly "No hanging close parens"))
  (defevaluator :beginning-of-symbols ""
   (lambda ()
    (if
  (defevaluator :beginning-of-symbols ""
   (lambda ()
    (if
    (push
     (list *line-no* *col-no*)
     *form-stack*)
    (push
     (list *line-no* *col-no*)
     *form-stack*)
-   nil))
+   (set-state :first-symbol-of-form)))
  (defevaluator :normal "\\)"
   (lambda ()
    (let
  (defevaluator :normal "\\)"
   (lambda ()
    (let
      ((not form) "Unmatched ending paren")
      ((< 50 (- *line-no* (car form))) "Forms can't be over 50 lines long")
      (t (setf *form-ended-on-same-line* (= *line-no* (car form))) nil)))))
      ((not form) "Unmatched ending paren")
      ((< 50 (- *line-no* (car form))) "Forms can't be over 50 lines long")
      (t (setf *form-ended-on-same-line* (= *line-no* (car form))) nil)))))
- (defevaluator :normal "::"
-  (constantly "No internal symbols from other packages"))
+ (defevaluator :normal "::" (constantly "No internal symbols from other packages"))
+ (defevaluator :first-symbol-of-form "\\n" (constantly "No new line after opening form"))
+ (defevaluator :first-symbol-of-form " " (constantly "No space after opening parens"))
+ (defevaluator :first-symbol-of-form "" (lambda () (set-state :normal)))
  (defevaluator :normal "." (constantly nil)))
  (defevaluator :normal "." (constantly nil)))