|
45 | 45 | (defvar flycheck-phpstan-executable)
|
46 | 46 | (defvar flycheck-phpstan--temp-buffer-name "*Flycheck PHPStan*")
|
47 | 47 |
|
| 48 | + |
| 49 | +(defcustom flycheck-phpstan-ignore-metadata-list nil |
| 50 | + "Set of metadata items to ignore in PHPStan messages for Flycheck." |
| 51 | + :type '(set (const identifier) |
| 52 | + (const tip)) |
| 53 | + :group 'phpstan) |
| 54 | + |
| 55 | +(defcustom flycheck-phpstan-metadata-separator "\n" |
| 56 | + "Separator of PHPStan message and metadata." |
| 57 | + :type 'string |
| 58 | + :safe #'stringp |
| 59 | + :group 'phpstan) |
| 60 | + |
48 | 61 | (defun flycheck-phpstan--enabled-and-set-variable ()
|
49 | 62 | "Return path to phpstan configure file, and set buffer execute in side effect."
|
50 | 63 | (let ((enabled (phpstan-enabled)))
|
|
77 | 90 | (let ((data (phpstan--parse-json json-buffer)))
|
78 | 91 | (cl-loop for (file . entry) in (flycheck-phpstan--plist-to-alist (plist-get data :files))
|
79 | 92 | append (cl-loop for messages in (plist-get entry :messages)
|
80 |
| - for text = (let ((msg (plist-get messages :message)) |
81 |
| - (tip (plist-get messages :tip))) |
82 |
| - (if tip |
83 |
| - (concat msg "\n" phpstan-tip-message-prefix tip) |
84 |
| - msg)) |
| 93 | + for text = (let* ((msg (plist-get messages :message)) |
| 94 | + (ignorable (plist-get messages :ignorable)) |
| 95 | + (identifier (unless (memq 'identifier flycheck-phpstan-ignore-metadata-list) |
| 96 | + (plist-get messages :identifier))) |
| 97 | + (tip (unless (memq 'tip flycheck-phpstan-ignore-metadata-list) |
| 98 | + (plist-get messages :tip))) |
| 99 | + (lines (list (when (and identifier ignorable) |
| 100 | + (concat phpstan-identifier-prefix identifier)) |
| 101 | + (when tip |
| 102 | + (concat phpstan-tip-message-prefix tip)))) |
| 103 | + (lines (cl-remove-if #'null lines))) |
| 104 | + (if (null lines) |
| 105 | + msg |
| 106 | + (concat msg flycheck-phpstan-metadata-separator |
| 107 | + (mapconcat #'identity lines "\n")))) |
85 | 108 | collect (flycheck-error-new-at (plist-get messages :line)
|
86 | 109 | nil 'error text
|
87 | 110 | :filename file)))))
|
|
0 commit comments