]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/help/lint/checks/checks.factor
core: subseq-index? -> subseq-of?
[factor.git] / basis / help / lint / checks / checks.factor
index 55a607000ee648d67bd77260e466eeaa1c8bc37f..dfac066116ed37f08d15db58316d03423f9f8fb9 100644 (file)
@@ -2,11 +2,11 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays assocs classes classes.struct
 classes.tuple combinators combinators.short-circuit debugger
-definitions effects eval formatting fry grouping help
-help.markup help.topics io io.streams.string kernel macros math
-namespaces sequences sequences.deep sets splitting strings
-summary tools.destructors unicode vocabs vocabs.loader words
-words.constant words.symbol ;
+definitions effects eval formatting grouping help help.markup
+help.topics io io.streams.string kernel macros math
+math.statistics namespaces prettyprint sequences sequences.deep
+sets splitting strings summary tools.destructors unicode vocabs
+vocabs.loader words words.constant words.symbol ;
 IN: help.lint.checks
 
 ERROR: simple-lint-error message ;
@@ -21,7 +21,17 @@ SYMBOL: vocab-articles
 : no-ui-disposables ( seq -- seq' )
     [
         class-of name>> {
-            "line" "single-texture" "multi-texture"
+            "single-texture" "multi-texture" ! opengl.textures
+            "line" ! core-text
+            "layout" ! ui.text.pango
+            "script-string" ! windows.uniscribe
+            "linux-monitor" ! github issue #2014, race condition in disposing of child monitors
+            "event-stream"
+            "macosx-monitor"
+            "recursive-monitor"
+            "input-port"
+            "malloc-ptr"
+            "fd"
         } member?
     ] reject ;
 
@@ -29,15 +39,19 @@ SYMBOL: vocab-articles
     [
         '[
             _ rest [
-                but-last "\n" join
-                [ (eval>string) ] call( code -- output )
+                but-last join-lines
+                (eval-with-stack>string)
                 "\n" ?tail drop
             ] keep
             last assert=
         ] vocabs-quot get call( quot -- )
-    ] leaks members no-ui-disposables length [
-        "%d disposable(s) leaked in example" sprintf simple-lint-error
-    ] unless-zero ;
+    ] leaks members no-ui-disposables
+    dup length 0 > [
+       dup [ class-of ] histogram-by
+       [ "Leaked resources: " write ... ] with-string-writer simple-lint-error
+    ] [
+        drop
+    ] if ;
 
 : check-examples ( element -- )
     \ $example swap elements [ check-example ] each ;
@@ -84,7 +98,7 @@ SYMBOL: vocab-articles
         [ parsing-word? ]
         [ "declared-effect" word-prop not ]
         [ constant? ]
-        [ "word-help" word-prop not ]
+        [ "help" word-prop not ]
     } 1|| ;
 
 : skip-check-values? ( word element -- ? )
@@ -106,11 +120,6 @@ SYMBOL: vocab-articles
         simple-lint-error
     ] unless ;
 
-: check-nulls ( element -- )
-    \ $values swap elements
-    null swap deep-member?
-    [ "$values should not contain null" simple-lint-error ] when ;
-
 : check-see-also ( element -- )
     \ $see-also swap elements [ rest all-unique? ] all?
     [ "$see-also are not unique" simple-lint-error ] unless ;
@@ -124,6 +133,10 @@ SYMBOL: vocab-articles
         ] unless
     ] each ;
 
+: check-slots-tables ( element -- )
+    \ $slots swap elements [ rest [ length 2 = ] all?  ] all?
+    [ "$slots have too many values in at least one row" simple-lint-error ] unless ;
+
 : check-rendering ( element -- )
     [ print-content ] with-string-writer drop ;
 
@@ -134,7 +147,7 @@ SYMBOL: vocab-articles
             simple-lint-error
         ] when
     ] [
-        "  " swap subseq? [
+        "  " subseq-of? [
             "Paragraph text should not contain double spaces"
             simple-lint-error
         ] when
@@ -199,6 +212,7 @@ SYMBOL: vocab-articles
         [ check-examples ]
         [ check-modules ]
         [ check-descriptions ]
+        [ check-slots-tables ]
     } cleave ;
 
 : files>vocabs ( -- assoc )