Skip to content

Commit d8305a2

Browse files
committed
Move checker-definitions inside (if (funcall *-find solidity-*-path))
This involves expanding two (if)s to wrap more code, but otherwise only whitespace changes for formatting adjustment. It improves efficiency and sets up for upcoming "feature/version"-handling commits.
1 parent 1e22271 commit d8305a2

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

solidity-flycheck.el

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,28 @@ we pass the directory to solium via the `--config' option."
8686

8787
(when solidity-flycheck-solium-checker-active
8888
;; define solium flycheck syntax checker
89-
(flycheck-define-checker solium-checker
90-
"A Solidity linter using solium"
91-
:command ("solium"
92-
(option "--config=" flycheck-solidity-solium-soliumrcfile concat)
93-
"-f"
94-
source-inplace)
95-
:error-patterns ((error line-start (zero-or-more " ") line ":" column (zero-or-more " ") "error" (message))
96-
(error line-start (zero-or-more not-newline) "[Fatal error]" (message))
97-
(warning line-start (zero-or-more " ") line ":" column (zero-or-more " ") "warning" (message)))
98-
:error-filter
99-
;; Add fake line numbers if they are missing in the lint output
100-
(lambda (errors)
101-
(dolist (err errors)
102-
(unless (flycheck-error-line err)
103-
(setf (flycheck-error-line err) 1)))
104-
errors)
105-
:modes solidity-mode
106-
:predicate (lambda () (eq major-mode 'solidity-mode)))
10789
;; first try to add solium to the checker's list since if we got solc
10890
;; it must come after it in the list due to it being chained after solc
10991
(if (funcall flycheck-executable-find solidity-solium-path)
11092
(progn
93+
(flycheck-define-checker solium-checker
94+
"A Solidity linter using solium"
95+
:command ("solium"
96+
(option "--config=" flycheck-solidity-solium-soliumrcfile concat)
97+
"-f"
98+
source-inplace)
99+
:error-patterns ((error line-start (zero-or-more " ") line ":" column (zero-or-more " ") "error" (message))
100+
(error line-start (zero-or-more not-newline) "[Fatal error]" (message))
101+
(warning line-start (zero-or-more " ") line ":" column (zero-or-more " ") "warning" (message)))
102+
:error-filter
103+
;; Add fake line numbers if they are missing in the lint output
104+
(lambda (errors)
105+
(dolist (err errors)
106+
(unless (flycheck-error-line err)
107+
(setf (flycheck-error-line err) 1)))
108+
errors)
109+
:modes solidity-mode
110+
:predicate (lambda () (eq major-mode 'solidity-mode)))
111111
(add-to-list 'flycheck-checkers 'solium-checker)
112112
(setq flycheck-solium-checker-executable solidity-solium-path))
113113
(error (format "Solidity Mode Configuration error. Requested solium flycheck integration but can't find solium at: %s" solidity-solium-path))))
@@ -118,19 +118,19 @@ we pass the directory to solium via the `--config' option."
118118
;; expanded the flycheck-define-checker macro in order to eval certain args, as per advice given in gitter
119119
;; https://gitter.im/flycheck/flycheck?at=5a43b3a8232e79134d98872b
120120
(flycheck-def-executable-var solidity-checker "solc")
121-
(flycheck-define-command-checker 'solidity-checker
122-
"A Solidity syntax checker using the solc compiler"
123-
:command '("solc" source-inplace)
124-
:error-patterns '((error line-start (file-name) ":" line ":" column ":" " Error: " (message))
125-
(error line-start "Error: " (message))
126-
(warning line-start (file-name) ":" line ":" column ":" " Warning: " (message)))
127-
:modes 'solidity-mode
128-
:predicate #'(lambda nil (eq major-mode 'solidity-mode))
129-
:next-checkers `((,solidity-flycheck-chaining-error-level . solium-checker))
130-
:standard-input 'nil
131-
:working-directory 'nil)
132121
(if (funcall flycheck-executable-find solidity-solc-path)
133122
(progn
123+
(flycheck-define-command-checker 'solidity-checker
124+
"A Solidity syntax checker using the solc compiler"
125+
:command '("solc" source-inplace)
126+
:error-patterns '((error line-start (file-name) ":" line ":" column ":" " Error: " (message))
127+
(error line-start "Error: " (message))
128+
(warning line-start (file-name) ":" line ":" column ":" " Warning: " (message)))
129+
:modes 'solidity-mode
130+
:predicate #'(lambda nil (eq major-mode 'solidity-mode))
131+
:next-checkers `((,solidity-flycheck-chaining-error-level . solium-checker))
132+
:standard-input 'nil
133+
:working-directory 'nil)
134134
(add-to-list 'flycheck-checkers 'solidity-checker)
135135
(setq flycheck-solidity-checker-executable solidity-solc-path))
136136
(error (format "Solidity Mode Configuration error. Requested solc flycheck integration but can't find solc at: %s" solidity-solc-path))))

0 commit comments

Comments
 (0)