fix diagnostics indent
This commit is contained in:
parent
ea89ecad9f
commit
d8f0d396a9
@ -9,17 +9,17 @@ the `file.diagnostics` field, filling it with diagnostics."
|
|||||||
|
|
||||||
(λ unused-definition [self file symbol definition]
|
(λ unused-definition [self file symbol definition]
|
||||||
"local variable that is defined but not used"
|
"local variable that is defined but not used"
|
||||||
(if (and (not= "_" (: (tostring symbol) :sub 1 1))
|
(if (and (not= "_" (: (tostring symbol) :sub 1 1))
|
||||||
(not (accumulate [reference false
|
(not (accumulate [reference false
|
||||||
_ ref (ipairs definition.referenced-by)
|
_ ref (ipairs definition.referenced-by)
|
||||||
&until reference]
|
&until reference]
|
||||||
(or (= ref.ref-type :read)
|
(or (= ref.ref-type :read)
|
||||||
(= ref.ref-type :mutate)))))
|
(= ref.ref-type :mutate)))))
|
||||||
{:range (message.ast->range self file symbol)
|
{:range (message.ast->range self file symbol)
|
||||||
:message (.. "unused definition: " (tostring symbol))
|
:message (.. "unused definition: " (tostring symbol))
|
||||||
:severity message.severity.WARN
|
:severity message.severity.WARN
|
||||||
:code 301
|
:code 301
|
||||||
:codeDescription "unused-definition"}))
|
:codeDescription "unused-definition"}))
|
||||||
|
|
||||||
(λ unknown-module-field [self file]
|
(λ unknown-module-field [self file]
|
||||||
"any multisym whose definition can't be found through a (require) call"
|
"any multisym whose definition can't be found through a (require) call"
|
||||||
@ -36,51 +36,50 @@ the `file.diagnostics` field, filling it with diagnostics."
|
|||||||
|
|
||||||
(λ unnecessary-method [self file colon call]
|
(λ unnecessary-method [self file colon call]
|
||||||
"a call to the : builtin that could just be a multisym"
|
"a call to the : builtin that could just be a multisym"
|
||||||
(if (sym? colon ":")
|
(if (and (sym? colon ":")
|
||||||
(let [receiver (. call 2)
|
(sym? (. call 2))
|
||||||
method (. call 3)]
|
(. file.lexical call))
|
||||||
(if (and (sym? receiver)
|
(let [method (. call 3)]
|
||||||
(. file.lexical call)
|
(if (and (= :string (type method))
|
||||||
(= :string (type method))
|
(not (method:find "^[0-9]"))
|
||||||
(not (method:find "^[0-9]"))
|
(not (method:find "[^!$%*+-/0-9<=>?A-Z\\^_a-z|\128-\255]")))
|
||||||
(not (method:find "[^!$%*+-/0-9<=>?A-Z\\^_a-z|\128-\255]")))
|
(case (message.ast->range self file call)
|
||||||
(case (message.ast->range self file call)
|
range {: range
|
||||||
range {: range
|
:message (.. "unnecessary : call: use (" (tostring (. call 2)) ":" method ")")
|
||||||
:message (.. "unnecessary : call: use (" (tostring receiver) ":" method ")")
|
:severity message.severity.WARN
|
||||||
:severity message.severity.WARN
|
:code 303
|
||||||
:code 303
|
:codeDescription "unnecessary-method"})))))
|
||||||
:codeDescription "unnecessary-method"})))))
|
|
||||||
|
|
||||||
(local ops {"+" 1 "-" 1 "*" 1 "/" 1 "//" 1 "%" 1 ".." 1 "and" 1 "or" 1})
|
(local ops {"+" 1 "-" 1 "*" 1 "/" 1 "//" 1 "%" 1 ".." 1 "and" 1 "or" 1})
|
||||||
(λ bad-unpack [self file op call]
|
(λ bad-unpack [self file op call]
|
||||||
"an unpack call leading into an operator"
|
"an unpack call leading into an operator"
|
||||||
(if (and (sym? op)
|
(if (and (sym? op)
|
||||||
(. ops (tostring op))
|
(. ops (tostring op))
|
||||||
;; last item is an unpack call
|
;; last item is an unpack call
|
||||||
(list? (. call (length call)))
|
(list? (. call (length call)))
|
||||||
(or (sym? (. call (length call) 1) :unpack)
|
(or (sym? (. call (length call) 1) :unpack)
|
||||||
(sym? (. call (length call) 1) :_G.unpack)
|
(sym? (. call (length call) 1) :_G.unpack)
|
||||||
(sym? (. call (length call) 1) :table.unpack))
|
(sym? (. call (length call) 1) :table.unpack))
|
||||||
;; Only the unpack call needs to be present in the original file.
|
;; Only the unpack call needs to be present in the original file.
|
||||||
(. file.lexical (. call (length call))))
|
(. file.lexical (. call (length call))))
|
||||||
(case (message.ast->range self file (. call (length call)))
|
(case (message.ast->range self file (. call (length call)))
|
||||||
range {: range
|
range {: range
|
||||||
:message (.. "faulty unpack call: " (tostring op) " isn't variadic at runtime."
|
:message (.. "faulty unpack call: " (tostring op) " isn't variadic at runtime."
|
||||||
(if (sym? op "..")
|
(if (sym? op "..")
|
||||||
(let [unpackme (view (. call (length call) 2))]
|
(let [unpackme (view (. call (length call) 2))]
|
||||||
(.. " Use (table.concat " unpackme ") instead of (.. (unpack " unpackme "))"))
|
(.. " Use (table.concat " unpackme ") instead of (.. (unpack " unpackme "))"))
|
||||||
(.. " Use a loop when you have a dynamic number of arguments to (" (tostring op) ")")))
|
(.. " Use a loop when you have a dynamic number of arguments to (" (tostring op) ")")))
|
||||||
:severity message.severity.WARN
|
:severity message.severity.WARN
|
||||||
:code 304
|
:code 304
|
||||||
:codeDescription "bad-unpack"})))
|
:codeDescription "bad-unpack"})))
|
||||||
|
|
||||||
(λ var-never-set [self file symbol definition]
|
(λ var-never-set [self file symbol definition]
|
||||||
(if (and definition.var? (not definition.var-set))
|
(if (and definition.var? (not definition.var-set))
|
||||||
{:range (message.ast->range self file symbol)
|
{:range (message.ast->range self file symbol)
|
||||||
:message (.. "var is never set: " (tostring symbol) " Consider using (local) instead of (var)")
|
:message (.. "var is never set: " (tostring symbol) " Consider using (local) instead of (var)")
|
||||||
:severity message.severity.WARN
|
:severity message.severity.WARN
|
||||||
:code 305
|
:code 305
|
||||||
:codeDescription "var-never-set"}))
|
:codeDescription "var-never-set"}))
|
||||||
|
|
||||||
(λ check [self file]
|
(λ check [self file]
|
||||||
"fill up the file.diagnostics table with linting things"
|
"fill up the file.diagnostics table with linting things"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user