From b28e965ceb90140d9c1cde75b171c4be02e02740 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 26 Apr 2026 19:49:58 +0200 Subject: [PATCH] update flycheck --- .../flycheck-buttercup.el | 157 -- elpa/flycheck-20251128.1706/flycheck-ert.el | 451 ----- elpa/flycheck-20260320.1715/README-elpa | 30 + .../flycheck-autoloads.el | 50 +- .../flycheck-buttercup.el | 586 ++++++ .../flycheck-pkg.el | 8 +- .../flycheck.el | 1735 +++++++---------- 7 files changed, 1305 insertions(+), 1712 deletions(-) delete mode 100644 elpa/flycheck-20251128.1706/flycheck-buttercup.el delete mode 100644 elpa/flycheck-20251128.1706/flycheck-ert.el create mode 100644 elpa/flycheck-20260320.1715/README-elpa rename elpa/{flycheck-20251128.1706 => flycheck-20260320.1715}/flycheck-autoloads.el (89%) create mode 100644 elpa/flycheck-20260320.1715/flycheck-buttercup.el rename elpa/{flycheck-20251128.1706 => flycheck-20260320.1715}/flycheck-pkg.el (71%) rename elpa/{flycheck-20251128.1706 => flycheck-20260320.1715}/flycheck.el (91%) diff --git a/elpa/flycheck-20251128.1706/flycheck-buttercup.el b/elpa/flycheck-20251128.1706/flycheck-buttercup.el deleted file mode 100644 index 5782980a..00000000 --- a/elpa/flycheck-20251128.1706/flycheck-buttercup.el +++ /dev/null @@ -1,157 +0,0 @@ -;;; flycheck-buttercup.el --- Flycheck: Extensions to Buttercup -*- lexical-binding: t; -*- - -;; Copyright (C) 2017-2025 Flycheck contributors -;; Copyright (C) 2016 Sebastian Wiesner and Flycheck contributors - -;; Author: Sebastian Wiesner -;; Maintainer: Clément Pit-Claudel -;; fmdkdd -;; Keywords: lisp, tools - -;; This file is not part of GNU Emacs. - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; Extensions to Buttercup to write BDD tests for Flycheck. -;; -;; Buttercup is a BDD testing framework for Emacs, see URL -;; `https://github.com/jorgenschaefer/emacs-buttercup/'. Flycheck uses -;; Buttercup extensively for new tests. -;; -;; This library provides extensions to Buttercup to write Specs for Flycheck. -;; -;; * Custom matchers -;; -;; (expect 'foo :to-be-local) - Is `foo' a local variable in the current buffer? - -;;; Code: - -(require 'buttercup) -(require 'flycheck) -(require 'seq) - - -;;; Buttercup helpers - -(defun flycheck-buttercup-format-error-list (errors) - "Format ERRORS into a human-readable string." - (mapconcat (lambda (e) (flycheck-error-format e 'with-file-name)) - errors "\n")) - - -;;; Data matchers - -(buttercup-define-matcher :to-be-empty-string (s) - (let ((s (funcall s))) - (if (equal s "") - (cons t (format "Expected %S not be an empty string" s)) - (cons nil (format "Expected %S to be an empty string" s))))) - -(buttercup-define-matcher :to-match-with-group (re s index match) - (let* ((re (funcall re)) - (s (funcall s)) - (index (funcall index)) - (match (funcall match)) - (matches? (string-match re s)) - (result (and matches? (match-string index s)))) - (if (and matches? (equal result match)) - (cons t (format "Expected %S not to match %S with %S in group %s" - re s match index)) - - (cons nil (format "Expected %S to match %S with %S in group %s, %s" - re s match index - (if matches? - (format "but got %S" result) - "but did not match")))))) - - -;;; Emacs feature matchers - -(buttercup-define-matcher :to-be-live (buffer) - (let ((buffer (get-buffer (funcall buffer)))) - (if (buffer-live-p buffer) - (cons t (format "Expected %S not to be a live buffer, but it is" - buffer)) - (cons nil (format "Expected %S to be a live buffer, but it is not" - buffer))))) - -(buttercup-define-matcher :to-be-visible (buffer) - (let ((buffer (get-buffer (funcall buffer)))) - (cond - ((and buffer (get-buffer-window buffer)) - (cons t (format "Expected %S not to be a visible buffer, but it is" - buffer))) - ((not (bufferp buffer)) - (cons nil - (format "Expected %S to be a visible buffer, but it is not a buffer" - buffer))) - (t (cons - nil - (format "Expected %S to be a visible buffer, but it is not visible" - buffer)))))) - -(buttercup-define-matcher :to-be-local (symbol) - (let ((symbol (funcall symbol))) - (if (local-variable-p symbol) - (cons t (format "Expected %S not to be a local variable, but it is" - symbol)) - (cons nil (format "Expected %S to be a local variable, but it is not" - symbol))))) - -(buttercup-define-matcher :to-contain-match (buffer re) - (let ((buffer (funcall buffer)) - (re (funcall re))) - (if (not (get-buffer buffer)) - (cons nil (format "Expected %S to contain a match of %s, \ -but is not a buffer" buffer re)) - (with-current-buffer buffer - (save-excursion - (goto-char (point-min)) - (if (re-search-forward re nil 'noerror) - (cons t (format "Expected %S to contain a match \ -for %s, but it did not" buffer re)) - (cons nil (format "Expected %S not to contain a match for \ -%s but it did not." buffer re)))))))) - - -;;; Flycheck matchers - -(buttercup-define-matcher :to-be-equal-flycheck-errors (a b) - (let* ((a (funcall a)) - (b (funcall b)) - (a-formatted (flycheck-buttercup-format-error-list a)) - (b-formatted (flycheck-buttercup-format-error-list b))) - (if (equal a b) - (cons t (format "Expected -%s -not to be equal to -%s" a-formatted b-formatted)) - (cons nil (format "Expected -%s -to be equal to -%s" a-formatted b-formatted))))) - -(provide 'flycheck-buttercup) - -;; Disable byte compilation for this library, to prevent package.el choking on a -;; missing `buttercup' library. See -;; https://github.com/flycheck/flycheck/issues/860 - -;; Local Variables: -;; no-byte-compile: t -;; End: - -;;; flycheck-buttercup.el ends here diff --git a/elpa/flycheck-20251128.1706/flycheck-ert.el b/elpa/flycheck-20251128.1706/flycheck-ert.el deleted file mode 100644 index f8219e91..00000000 --- a/elpa/flycheck-20251128.1706/flycheck-ert.el +++ /dev/null @@ -1,451 +0,0 @@ -;;; flycheck-ert.el --- Flycheck: ERT extensions -*- lexical-binding: t; -*- - -;; Copyright (C) 2017-2018 Flycheck contributors -;; Copyright (C) 2013-2016 Sebastian Wiesner and Flycheck contributors - -;; Author: Sebastian Wiesner -;; Maintainer: Clément Pit-Claudel -;; fmdkdd -;; URL: https://github.com/flycheck/flycheck - -;; This file is not part of GNU Emacs. - -;; This program is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - -;;; Commentary: - -;; Unit testing library for Flycheck, the modern on-the-fly syntax checking -;; extension for GNU Emacs. - -;; Provide various utility functions and unit test helpers to test Flycheck and -;; Flycheck extensions. - -;;; Code: - -(require 'flycheck) -(require 'ert) -(require 'macroexp) ; For macro utilities - - -;;; Internal variables - -(defvar flycheck-ert--resource-directory nil - "The directory to get resources from in this test suite.") - - -;;; Resource management macros - -(defmacro flycheck-ert-with-temp-buffer (&rest body) - "Eval BODY within a temporary buffer. - -Like `with-temp-buffer', but resets the modification state of the -temporary buffer to make sure that it is properly killed even if -it has a backing file and is modified." - (declare (indent 0) (debug t)) - `(with-temp-buffer - (unwind-protect - ,(macroexp-progn body) - ;; Reset modification state of the buffer, and unlink it from its backing - ;; file, if any, because Emacs refuses to kill modified buffers with - ;; backing files, even if they are temporary. - (set-buffer-modified-p nil) - (set-visited-file-name nil 'no-query)))) - -(defmacro flycheck-ert-with-file-buffer (file-name &rest body) - "Create a buffer from FILE-NAME and eval BODY. - -BODY is evaluated with `current-buffer' being a buffer with the -contents FILE-NAME." - (declare (indent 1) (debug t)) - `(let ((file-name ,file-name)) - (unless (file-exists-p file-name) - (error "%s does not exist" file-name)) - (flycheck-ert-with-temp-buffer - (insert-file-contents file-name 'visit) - (set-visited-file-name file-name 'no-query) - (cd (file-name-directory file-name)) - ;; Mark the buffer as not modified, because we just loaded the file up to - ;; now. - (set-buffer-modified-p nil) - ,@body))) - -(defmacro flycheck-ert-with-help-buffer (&rest body) - "Execute BODY and kill the help buffer afterwards. - -Use this macro to test functions that create a Help buffer." - (declare (indent 0)) - `(unwind-protect - ,(macroexp-progn body) - (when (buffer-live-p (get-buffer (help-buffer))) - (kill-buffer (help-buffer))))) - -(defmacro flycheck-ert-with-global-mode (&rest body) - "Execute BODY with Global Flycheck Mode enabled. - -After BODY, restore the old state of Global Flycheck Mode." - (declare (indent 0)) - `(let ((old-state global-flycheck-mode)) - (unwind-protect - (progn - (global-flycheck-mode 1) - ,@body) - (global-flycheck-mode (if old-state 1 -1))))) - -(defmacro flycheck-ert-with-env (env &rest body) - "Add ENV to `process-environment' in BODY. - -Execute BODY with a `process-environment' which contains all -variables from ENV added. - -ENV is an alist, where each cons cell `(VAR . VALUE)' is a -environment variable VAR to be added to `process-environment' -with VALUE." - (declare (indent 1)) - `(let ((process-environment (copy-sequence process-environment))) - (pcase-dolist (`(,var . ,value) ,env) - (setenv var value)) - ,@body)) - - -;;; Test resources -(defun flycheck-ert-resource-filename (resource-file) - "Determine the absolute file name of a RESOURCE-FILE. - -Relative file names are expanded against -`flycheck-ert--resource-directory'." - (expand-file-name resource-file flycheck-ert--resource-directory)) - -(defmacro flycheck-ert-with-resource-buffer (resource-file &rest body) - "Create a temp buffer from a RESOURCE-FILE and execute BODY. - -The absolute file name of RESOURCE-FILE is determined with -`flycheck-ert-resource-filename'." - (declare (indent 1)) - `(flycheck-ert-with-file-buffer - (flycheck-ert-resource-filename ,resource-file) - ,@body)) - - -;;; Test suite initialization - -(defun flycheck-ert-initialize (resource-dir) - "Initialize a test suite with RESOURCE-DIR. - -RESOURCE-DIR is the directory, `flycheck-ert-resource-filename' -should use to lookup resource files." - (when flycheck-ert--resource-directory - (error "Test suite already initialized")) - (let ((tests (ert-select-tests t t))) - ;; Select all tests - (unless tests - (error "No tests defined. \ -Call `flycheck-ert-initialize' after defining all tests!")) - - (setq flycheck-ert--resource-directory resource-dir))) - - -;;; Test case definitions -(defmacro flycheck-ert-def-checker-test (checker language name - &rest keys-and-body) - "Define a test case for a syntax CHECKER for LANGUAGE. - -CHECKER is a symbol or a list of symbols denoting syntax checkers -being tested by the test. The test case is skipped, if any of -these checkers cannot be used. LANGUAGE is a symbol or a list of -symbols denoting the programming languages supported by the -syntax checkers. This is currently only used for tagging the -test appropriately. - -NAME is a symbol denoting the local name of the test. The test -itself is ultimately named -`flycheck-define-checker/CHECKER/NAME'. If CHECKER is a list, -the first checker in the list is used for naming the test. - -Optionally, the keyword arguments `:tags' and `:expected-result' -may be given. They have the same meaning as in `ert-deftest.', -and are added to the tags and result expectations set up by this -macro. - -The remaining forms KEYS-AND-BODY denote the body of the test -case, including assertions and setup code." - (declare (indent 3)) - (unless checker - (error "No syntax checkers specified")) - (unless language - (error "No languages specified")) - (let* ((checkers (if (symbolp checker) (list checker) checker)) - (checker (car checkers)) - (languages (if (symbolp language) (list language) language)) - (language-tags (mapcar (lambda (l) (intern (format "language-%s" l))) - languages)) - (checker-tags (mapcar (lambda (c) (intern (format "checker-%s" c))) - checkers)) - (local-name (or name 'default)) - (full-name (intern (format "flycheck-define-checker/%s/%s" - checker local-name))) - (keys-and-body (ert--parse-keys-and-body keys-and-body)) - (body (cadr keys-and-body)) - (keys (car keys-and-body)) - (default-tags '(syntax-checker external-tool))) - `(ert-deftest ,full-name () - :expected-result ,(or (plist-get keys :expected-result) :passed) - :tags (append ',(append default-tags language-tags checker-tags) - ,(plist-get keys :tags)) - ,@(mapcar (lambda (c) - `(skip-unless - ;; Ignore non-command checkers - (or (not (flycheck-checker-get ',c 'command)) - (executable-find (flycheck-checker-executable ',c))))) - checkers) - ,@body))) - - -;;; Test case results - -(defun flycheck-ert-syntax-check-timed-out-p (result) - "Whether RESULT denotes a timed-out test. - -RESULT is an ERT test result object." - (and (ert-test-failed-p result) - (eq (car (ert-test-failed-condition result)) - 'flycheck-ert-syntax-check-timed-out))) - - -;;; Syntax checking in tests - -(defvar-local flycheck-ert-syntax-checker-finished nil - "Non-nil if the current checker has finished.") - -(add-hook 'flycheck-after-syntax-check-hook - (lambda () (setq flycheck-ert-syntax-checker-finished t))) - -(defconst flycheck-ert-checker-wait-time 10 - "Time to wait until a checker is finished in seconds. - -After this time has elapsed, the checker is considered to have -failed, and the test aborted with failure.") - -(define-error 'flycheck-ert-syntax-check-timed-out "Syntax check timed out.") - -(defun flycheck-ert-wait-for-syntax-checker () - "Wait until the syntax check in the current buffer is finished." - (let ((starttime (float-time))) - (while (and (not flycheck-ert-syntax-checker-finished) - (< (- (float-time) starttime) flycheck-ert-checker-wait-time)) - (accept-process-output nil 0.02)) - (unless (< (- (float-time) starttime) flycheck-ert-checker-wait-time) - (flycheck-stop) - (signal 'flycheck-ert-syntax-check-timed-out nil))) - (setq flycheck-ert-syntax-checker-finished nil)) - -(defun flycheck-ert-buffer-sync () - "Like `flycheck-buffer', but synchronously." - (setq flycheck-ert-syntax-checker-finished nil) - (should (not (flycheck-running-p))) - (flycheck-mode) ;; This will only start a deferred check, - (should (flycheck-get-checker-for-buffer)) - (flycheck-buffer) ;; …so we need an explicit manual check - ;; After starting the check, the checker should either be running now, or - ;; already be finished (if it was fast). - (should (or flycheck-current-syntax-check - flycheck-ert-syntax-checker-finished)) - ;; Also there should be no deferred check pending anymore - (should-not (flycheck-deferred-check-p)) - (flycheck-ert-wait-for-syntax-checker)) - -(defun flycheck-ert-ensure-clear () - "Clear the current buffer. - -Raise an assertion error if the buffer is not clear afterwards." - (flycheck-clear) - (should (not flycheck-current-errors)) - (should (not (seq-find (lambda (ov) (overlay-get ov 'flycheck-overlay)) - (overlays-in (point-min) (point-max)))))) - - -;;; Test assertions - -(defun flycheck-error-without-group (err) - "Return a copy ERR with the `group' property set to nil." - (let ((copy (copy-flycheck-error err))) - (setf (flycheck-error-group copy) nil) - copy)) - -(defun flycheck-ert-should-overlay (error) - "Test that ERROR has a proper overlay in the current buffer. - -ERROR is a Flycheck error object." - (let* ((overlay (seq-find (lambda (ov) - (equal (flycheck-error-without-group - (overlay-get ov 'flycheck-error)) - (flycheck-error-without-group error))) - (flycheck-overlays-in 0 (+ 1 (buffer-size))))) - (region - ;; Overlays of errors from other files are on the first line - (if (flycheck-relevant-error-other-file-p error) - (cons (point-min) - (save-excursion (goto-char (point-min)) - (line-end-position))) - (flycheck-error-region-for-mode error 'symbols))) - (level (flycheck-error-level error)) - (category (flycheck-error-level-overlay-category level)) - (face (get category 'face)) - (fringe-bitmap (flycheck-error-level-fringe-bitmap level)) - (fringe-face (flycheck-error-level-fringe-face level)) - (fringe-icon (list 'left-fringe fringe-bitmap fringe-face))) - (should overlay) - (should (overlay-get overlay 'flycheck-overlay)) - (should (= (overlay-start overlay) (car region))) - (should (= (overlay-end overlay) (cdr region))) - (should (eq (overlay-get overlay 'face) face)) - (should (equal (get-char-property 0 'display - (overlay-get overlay 'before-string)) - fringe-icon)) - (should (eq (overlay-get overlay 'category) category)) - (should (equal (flycheck-error-without-group (overlay-get overlay - 'flycheck-error)) - (flycheck-error-without-group error))))) - -(defun flycheck-ert-sort-errors (errors) - "Sort ERRORS by `flycheck-error-<'." - (seq-sort #'flycheck-error-< errors)) - -(defun flycheck-ert-should-errors (&rest errors) - "Test that the current buffers has ERRORS. - -ERRORS is a list of errors expected to be present in the current -buffer. Each error is given as a list of arguments to -`flycheck-error-new-at'. - -If ERRORS are omitted, test that there are no errors at all in -the current buffer. - -With ERRORS, test that each error in ERRORS is present in the -current buffer, and that the number of errors in the current -buffer is equal to the number of given ERRORS. In other words, -check that the buffer has all ERRORS, and no other errors." - (let ((expected (flycheck-ert-sort-errors - (mapcar (apply-partially #'apply #'flycheck-error-new-at) - errors))) - (current (flycheck-ert-sort-errors flycheck-current-errors))) - (should (equal (mapcar #'flycheck-error-without-group expected) - (mapcar #'flycheck-error-without-group current))) - ;; Check that related errors are the same - (cl-mapcar - (lambda (err1 err2) - (should (equal (flycheck-ert-sort-errors - (mapcar #'flycheck-error-without-group - (flycheck-related-errors err1 expected))) - (flycheck-ert-sort-errors - (mapcar #'flycheck-error-without-group - (flycheck-related-errors err2)))))) - expected current) - (mapc #'flycheck-ert-should-overlay expected)) - (should (= (length errors) - (length (flycheck-overlays-in (point-min) (point-max)))))) - -(define-error 'flycheck-ert-suspicious-checker "Suspicious state from checker") - -(defun flycheck-ert-should-syntax-check-in-buffer (&rest errors) - "Test a syntax check in BUFFER, expecting ERRORS. - -This is like `flycheck-ert-should-syntax-check', but with a -buffer in the right mode instead of a file." - ;; Load safe file-local variables because some tests depend on them - (let ((enable-local-variables :safe) - ;; Disable all hooks at this place, to prevent 3rd party packages - ;; from interfering - (hack-local-variables-hook)) - (hack-local-variables)) - ;; Configure config file locating for unit tests - (let ((process-hook-called 0) - (suspicious nil)) - (add-hook 'flycheck-process-error-functions - (lambda (_err) - (setq process-hook-called (1+ process-hook-called)) - nil) - nil :local) - (add-hook 'flycheck-status-changed-functions - (lambda (status) - (when (eq status 'suspicious) - (setq suspicious t))) - nil :local) - (flycheck-ert-buffer-sync) - (when suspicious - (signal 'flycheck-ert-suspicious-checker nil)) - (apply #'flycheck-ert-should-errors errors) - (should (= process-hook-called (length errors)))) - (flycheck-ert-ensure-clear)) - -(defun flycheck-ert-should-syntax-check (resource-file modes &rest errors) - "Test a syntax check in RESOURCE-FILE with MODES. - -RESOURCE-FILE is the file to check. MODES is a single major mode -symbol or a list thereof, specifying the major modes to syntax -check with. If more than one major mode is specified, the test -is run for each mode separately, so if you give three major -modes, the entire test will run three times. ERRORS is the list -of expected errors, as in `flycheck-ert-should-errors'. If -omitted, the syntax check must not emit any errors. The errors -are cleared after each test. - -The syntax checker is selected via standard syntax checker -selection. To test a specific checker, you need to set -`flycheck-checker' or `flycheck-disabled-checkers' accordingly -before using this predicate, depending on whether you want to use -manual or automatic checker selection. - -During the syntax check, configuration files of syntax checkers -are also searched in the `config-files' sub-directory of the -resource directory." - (when (symbolp modes) - (setq modes (list modes))) - (dolist (mode modes) - (unless (fboundp mode) - (ert-skip (format "%S missing" mode))) - (flycheck-ert-with-resource-buffer resource-file - (funcall mode) - (apply #'flycheck-ert-should-syntax-check-in-buffer errors)))) - -(defun flycheck-ert-at-nth-error (n) - "Determine whether point is at the N'th Flycheck error. - -Return non-nil if the point is at the N'th Flycheck error in the -current buffer. Otherwise return nil." - (let* ((error (nth (1- n) flycheck-current-errors)) - (mode flycheck-highlighting-mode) - (region (flycheck-error-region-for-mode error mode))) - (and (member error (flycheck-overlay-errors-at (point))) - (= (point) (car region))))) - -(defun flycheck-ert-explain--at-nth-error (n) - "Explain a failed at-nth-error predicate at N." - (let ((errors (flycheck-overlay-errors-at (point)))) - (if (null errors) - (format "Expected to be at error %s, but no error at point %s" - n (point)) - (let ((pos (cl-position (car errors) flycheck-current-errors))) - (format "Expected to be at point %s and error %s, \ -but point %s is at error %s" - (car (flycheck-error-region-for-mode - (nth (1- n) flycheck-current-errors) - flycheck-highlighting-mode)) - n (point) (1+ pos)))))) - -(put 'flycheck-ert-at-nth-error 'ert-explainer - 'flycheck-ert-explain--at-nth-error) - -(provide 'flycheck-ert) - -;;; flycheck-ert.el ends here diff --git a/elpa/flycheck-20260320.1715/README-elpa b/elpa/flycheck-20260320.1715/README-elpa new file mode 100644 index 00000000..b9525cd0 --- /dev/null +++ b/elpa/flycheck-20260320.1715/README-elpa @@ -0,0 +1,30 @@ +On-the-fly syntax checking for GNU Emacs. + +Flycheck is a modern on-the-fly syntax checking extension for GNU Emacs, +intended as replacement for the older Flymake extension which is part of GNU +Emacs. + +Flycheck automatically checks buffers for errors while you type, and reports +warnings and errors directly in the buffer and in an optional IDE-like error +list. + +It comes with a rich interface for custom syntax checkers and other +extensions, and has already many 3rd party extensions adding new features. + +Please read the online manual at https://www.flycheck.org for more +information. You can open the manual directly from Emacs with `M-x +flycheck-manual'. + +# Setup + +Flycheck works best on Unix systems. It does not officially support Windows, +but tries to maintain Windows compatibility and should generally work fine on +Windows, too. + +To enable Flycheck add the following to your init file: + + (add-hook 'after-init-hook #'global-flycheck-mode) + +Flycheck will then automatically check buffers in supported languages, as +long as all necessary tools are present. Use `flycheck-verify-setup' to +troubleshoot your Flycheck setup. diff --git a/elpa/flycheck-20251128.1706/flycheck-autoloads.el b/elpa/flycheck-20260320.1715/flycheck-autoloads.el similarity index 89% rename from elpa/flycheck-20251128.1706/flycheck-autoloads.el rename to elpa/flycheck-20260320.1715/flycheck-autoloads.el index 475d40f7..c08e85bf 100644 --- a/elpa/flycheck-20251128.1706/flycheck-autoloads.el +++ b/elpa/flycheck-20260320.1715/flycheck-autoloads.el @@ -11,12 +11,12 @@ ;;; Generated autoloads from flycheck.el -(autoload 'flycheck-manual "flycheck" "\ -Open the Flycheck manual." t) -(autoload 'flycheck-quick-help "flycheck" "\ -Display brief Flycheck help." t) -(autoload 'flycheck-mode "flycheck" "\ -Flycheck is a minor mode for on-the-fly syntax checking. +(autoload 'flycheck-manual "flycheck" +"Open the Flycheck manual." t) +(autoload 'flycheck-quick-help "flycheck" +"Display brief Flycheck help." t) +(autoload 'flycheck-mode "flycheck" +"Flycheck is a minor mode for on-the-fly syntax checking. In `flycheck-mode' the buffer is automatically syntax-checked using the first suitable syntax checker from `flycheck-checkers'. @@ -60,16 +60,16 @@ ARG is ‘toggle’; disable the mode otherwise. (fn &optional ARG)" t) (put 'global-flycheck-mode 'globalized-minor-mode t) -(defvar global-flycheck-mode nil "\ -Non-nil if Global Flycheck mode is enabled. +(defvar global-flycheck-mode nil +"Non-nil if Global Flycheck mode is enabled. See the `global-flycheck-mode' command for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `global-flycheck-mode'.") (custom-autoload 'global-flycheck-mode "flycheck" nil) -(autoload 'global-flycheck-mode "flycheck" "\ -Toggle Flycheck mode in many buffers. +(autoload 'global-flycheck-mode "flycheck" +"Toggle Flycheck mode in many buffers. Specifically, Flycheck mode is enabled in all buffers where `flycheck-mode-on-safe' would do it. @@ -83,8 +83,8 @@ Disable the mode if ARG is a negative number. See `flycheck-mode' for more information on Flycheck mode. (fn &optional ARG)" t) -(autoload 'flycheck-define-error-level "flycheck" "\ -Define a new error LEVEL with PROPERTIES. +(autoload 'flycheck-define-error-level "flycheck" +"Define a new error LEVEL with PROPERTIES. The following PROPERTIES constitute an error level: @@ -142,8 +142,8 @@ The following PROPERTIES constitute an error level: (fn LEVEL &rest PROPERTIES)") (function-put 'flycheck-define-error-level 'lisp-indent-function 1) -(autoload 'flycheck-define-command-checker "flycheck" "\ -Define SYMBOL as syntax checker to run a command. +(autoload 'flycheck-define-command-checker "flycheck" +"Define SYMBOL as syntax checker to run a command. Define SYMBOL as generic syntax checker via `flycheck-define-generic-checker', which uses an external command @@ -237,8 +237,8 @@ default `:verify' function of command checkers. (fn SYMBOL DOCSTRING &rest PROPERTIES)") (function-put 'flycheck-define-command-checker 'lisp-indent-function 1) (function-put 'flycheck-define-command-checker 'doc-string-elt 2) -(autoload 'flycheck-def-config-file-var "flycheck" "\ -Define SYMBOL as config file variable for CHECKER, with default FILE-NAME. +(autoload 'flycheck-def-config-file-var "flycheck" +"Define SYMBOL as config file variable for CHECKER, with default FILE-NAME. SYMBOL is declared as customizable variable using `defcustom', to provide configuration files for the given syntax CHECKER. @@ -252,9 +252,8 @@ Use this together with the `config-file' form in the `:command' argument to `flycheck-define-checker'. (fn SYMBOL CHECKER &optional FILE-NAME &rest CUSTOM-ARGS)" nil t) -(function-put 'flycheck-def-config-file-var 'lisp-indent-function 3) -(autoload 'flycheck-def-option-var "flycheck" "\ -Define SYMBOL as option variable with INIT-VALUE for CHECKER. +(autoload 'flycheck-def-option-var "flycheck" +"Define SYMBOL as option variable with INIT-VALUE for CHECKERS. SYMBOL is declared as customizable variable using `defcustom', to provide an option for the given syntax CHECKERS (a checker or a @@ -267,29 +266,22 @@ Use this together with the `option', `option-list' and `flycheck-define-checker'. (fn SYMBOL INIT-VALUE CHECKERS DOCSTRING &rest CUSTOM-ARGS)" nil t) -(function-put 'flycheck-def-option-var 'lisp-indent-function 3) (function-put 'flycheck-def-option-var 'doc-string-elt 4) -(autoload 'flycheck-define-checker "flycheck" "\ -Define SYMBOL as command syntax checker with DOCSTRING and PROPERTIES. +(autoload 'flycheck-define-checker "flycheck" +"Define SYMBOL as command syntax checker with DOCSTRING and PROPERTIES. Like `flycheck-define-command-checker', but PROPERTIES must not be quoted. Also, implicitly define the executable variable for SYMBOL with `flycheck-def-executable-var'. (fn SYMBOL DOCSTRING &rest PROPERTIES)" nil t) -(function-put 'flycheck-define-checker 'lisp-indent-function 1) (function-put 'flycheck-define-checker 'doc-string-elt 2) (register-definition-prefixes "flycheck" '("flycheck-" "help-flycheck-checker-d" "list-flycheck-errors")) ;;; Generated autoloads from flycheck-buttercup.el -(register-definition-prefixes "flycheck-buttercup" '("flycheck-buttercup-format-error-list")) - - -;;; Generated autoloads from flycheck-ert.el - -(register-definition-prefixes "flycheck-ert" '("flycheck-er")) +(register-definition-prefixes "flycheck-buttercup" '("flycheck-buttercup-")) ;;; End of scraped data diff --git a/elpa/flycheck-20260320.1715/flycheck-buttercup.el b/elpa/flycheck-20260320.1715/flycheck-buttercup.el new file mode 100644 index 00000000..48ced63b --- /dev/null +++ b/elpa/flycheck-20260320.1715/flycheck-buttercup.el @@ -0,0 +1,586 @@ +;;; flycheck-buttercup.el --- Flycheck: Extensions to Buttercup -*- lexical-binding: t; -*- + +;; Copyright (C) 2017-2025 Flycheck contributors +;; Copyright (C) 2016 Sebastian Wiesner and Flycheck contributors + +;; Author: Sebastian Wiesner +;; Maintainer: Clément Pit-Claudel +;; fmdkdd +;; Keywords: lisp, tools + +;; This file is not part of GNU Emacs. + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: + +;; Extensions to Buttercup to write BDD tests for Flycheck. +;; +;; Buttercup is a BDD testing framework for Emacs, see URL +;; `https://github.com/jorgenschaefer/emacs-buttercup/'. Flycheck uses +;; Buttercup extensively for new tests. +;; +;; This library provides extensions to Buttercup to write Specs for Flycheck. +;; +;; * Custom matchers +;; +;; (expect 'foo :to-be-local) - Is `foo' a local variable in the current buffer? + +;;; Code: + +(require 'buttercup) +(require 'flycheck) +(require 'seq) +(require 'cl-lib) +(require 'macroexp) + + +;;; Buttercup helpers + +(defun flycheck-buttercup-format-error-list (errors) + "Format ERRORS into a human-readable string." + (mapconcat (lambda (e) (flycheck-error-format e 'with-file-name)) + errors "\n")) + + +;;; Data matchers + +(buttercup-define-matcher :to-be-empty-string (s) + "Match that S is an empty string." + (let ((s (funcall s))) + (if (equal s "") + (cons t (format "Expected %S not to be an empty string" s)) + (cons nil (format "Expected %S to be an empty string" s))))) + +(buttercup-define-matcher :to-match-with-group (re s index match) + "Match that regexp RE matches string S with MATCH in group INDEX." + (let* ((re (funcall re)) + (s (funcall s)) + (index (funcall index)) + (match (funcall match)) + (matches? (string-match re s)) + (result (and matches? (match-string index s)))) + (if (and matches? (equal result match)) + (cons t (format "Expected %S not to match %S with %S in group %s" + re s match index)) + + (cons nil (format "Expected %S to match %S with %S in group %s, %s" + re s match index + (if matches? + (format "but got %S" result) + "but did not match")))))) + + +;;; Emacs feature matchers + +(buttercup-define-matcher :to-be-live (buffer) + "Match that BUFFER is a live buffer." + (let ((buffer (get-buffer (funcall buffer)))) + (if (buffer-live-p buffer) + (cons t (format "Expected %S not to be a live buffer, but it is" + buffer)) + (cons nil (format "Expected %S to be a live buffer, but it is not" + buffer))))) + +(buttercup-define-matcher :to-be-visible (buffer) + "Match that BUFFER is displayed in a window." + (let ((buffer (get-buffer (funcall buffer)))) + (cond + ((and buffer (get-buffer-window buffer)) + (cons t (format "Expected %S not to be a visible buffer, but it is" + buffer))) + ((not (bufferp buffer)) + (cons nil + (format "Expected %S to be a visible buffer, but it is not a buffer" + buffer))) + (t (cons + nil + (format "Expected %S to be a visible buffer, but it is not visible" + buffer)))))) + +(buttercup-define-matcher :to-be-local (symbol) + "Match that SYMBOL is a buffer-local variable in the current buffer." + (let ((symbol (funcall symbol))) + (if (local-variable-p symbol) + (cons t (format "Expected %S not to be a local variable, but it is" + symbol)) + (cons nil (format "Expected %S to be a local variable, but it is not" + symbol))))) + +(buttercup-define-matcher :to-contain-match (buffer re) + "Match that BUFFER contains text matching regexp RE." + (let ((buffer (funcall buffer)) + (re (funcall re))) + (if (not (get-buffer buffer)) + (cons nil (format "Expected %S to contain a match of %s, \ +but is not a buffer" buffer re)) + (with-current-buffer buffer + (save-excursion + (goto-char (point-min)) + (if (re-search-forward re nil 'noerror) + (cons t (format "Expected %S not to contain a match \ +for %s, but it did" buffer re)) + (cons nil (format "Expected %S to contain a match for \ +%s, but it did not." buffer re)))))))) + + +;;; Flycheck matchers + +(buttercup-define-matcher :to-be-equal-flycheck-errors (a b) + "Match that flycheck error lists A and B are equal." + (let* ((a (funcall a)) + (b (funcall b)) + (a-formatted (flycheck-buttercup-format-error-list a)) + (b-formatted (flycheck-buttercup-format-error-list b))) + (if (equal a b) + (cons t (format "Expected +%s +not to be equal to +%s" a-formatted b-formatted)) + (cons nil (format "Expected +%s +to be equal to +%s" a-formatted b-formatted))))) + + +;;; Internal variables + +(defvar flycheck-buttercup--resource-directory nil + "The directory to get resources from in this test suite.") + + +;;; Resource management + +(defun flycheck-buttercup-resource-filename (resource-file) + "Determine the absolute file name of a RESOURCE-FILE. + +Relative file names are expanded against +`flycheck-buttercup--resource-directory'." + (expand-file-name resource-file flycheck-buttercup--resource-directory)) + +(defun flycheck-buttercup-initialize (resource-dir) + "Initialize a test suite with RESOURCE-DIR. + +RESOURCE-DIR is the directory, `flycheck-buttercup-resource-filename' +should use to lookup resource files." + (when flycheck-buttercup--resource-directory + (error "Test suite already initialized")) + (setq flycheck-buttercup--resource-directory resource-dir)) + + +;;; Buffer utility macros + +(defmacro flycheck-buttercup-with-temp-buffer (&rest body) + "Eval BODY within a temporary buffer. + +Like `with-temp-buffer', but resets the modification state of the +temporary buffer to make sure that it is properly killed even if +it has a backing file and is modified." + (declare (indent 0) (debug t)) + `(with-temp-buffer + (unwind-protect + ,(macroexp-progn body) + ;; Reset modification state of the buffer, and unlink it from its + ;; backing file, if any, because Emacs refuses to kill modified + ;; buffers with backing files, even if they are temporary. + (set-buffer-modified-p nil) + (set-visited-file-name nil 'no-query)))) + +(defmacro flycheck-buttercup-with-file-buffer (file-name &rest body) + "Create a buffer from FILE-NAME and eval BODY. + +BODY is evaluated with `current-buffer' being a buffer with the +contents of FILE-NAME, its `visited-file-name' set to FILE-NAME, +and `default-directory' set to the file's directory." + (declare (indent 1) (debug t)) + `(let ((file-name ,file-name)) + (unless (file-exists-p file-name) + (error "%s does not exist" file-name)) + (flycheck-buttercup-with-temp-buffer + (insert-file-contents file-name 'visit) + (set-visited-file-name file-name 'no-query) + (cd (file-name-directory file-name)) + ;; Mark the buffer as not modified, because we just loaded the + ;; file up to now. + (set-buffer-modified-p nil) + ,@body))) + +(defmacro flycheck-buttercup-with-help-buffer (&rest body) + "Execute BODY and kill the help buffer afterwards. + +Use this macro to test functions that create a Help buffer." + (declare (indent 0)) + `(unwind-protect + ,(macroexp-progn body) + (when (buffer-live-p (get-buffer (help-buffer))) + (kill-buffer (help-buffer))))) + +(defmacro flycheck-buttercup-with-global-mode (&rest body) + "Execute BODY with Global Flycheck Mode enabled. + +After BODY, restore the old state of Global Flycheck Mode." + (declare (indent 0)) + `(let ((old-state global-flycheck-mode)) + (unwind-protect + (progn + (global-flycheck-mode 1) + ,@body) + (global-flycheck-mode (if old-state 1 -1))))) + +(defmacro flycheck-buttercup-with-env (env &rest body) + "Add ENV to `process-environment' in BODY. + +Execute BODY with a `process-environment' which contains all +variables from ENV added. + +ENV is an alist, where each cons cell `(VAR . VALUE)' is a +environment variable VAR to be added to `process-environment' +with VALUE." + (declare (indent 1)) + `(let ((process-environment (copy-sequence process-environment))) + (pcase-dolist (`(,var . ,value) ,env) + (setenv var value)) + ,@body)) + +(defmacro flycheck-buttercup-with-resource-buffer (resource-file &rest body) + "Create a temp buffer from a RESOURCE-FILE and execute BODY. + +The absolute file name of RESOURCE-FILE is determined with +`flycheck-buttercup-resource-filename'." + (declare (indent 1)) + `(flycheck-buttercup-with-file-buffer + (flycheck-buttercup-resource-filename ,resource-file) + ,@body)) + + +;;; Syntax checking in tests + +(defvar-local flycheck-buttercup-syntax-checker-finished nil + "Non-nil if the current checker has finished.") + +(add-hook 'flycheck-after-syntax-check-hook + (lambda () + (setq flycheck-buttercup-syntax-checker-finished t))) + +(defconst flycheck-buttercup-checker-wait-time 10 + "Time to wait until a checker is finished in seconds. + +After this time has elapsed, the checker is considered to have +failed, and the test aborted with failure.") + +(define-error 'flycheck-buttercup-syntax-check-timed-out + "Syntax check timed out.") + +(define-error 'flycheck-buttercup-suspicious-checker + "Suspicious state from checker") + +(defun flycheck-buttercup-wait-for-syntax-checker () + "Wait until the syntax check in the current buffer is finished. + +Signal `flycheck-buttercup-syntax-check-timed-out' if the check +does not complete within `flycheck-buttercup-checker-wait-time' +seconds." + (let ((starttime (float-time))) + (while (and (not flycheck-buttercup-syntax-checker-finished) + (< (- (float-time) starttime) + flycheck-buttercup-checker-wait-time)) + (accept-process-output nil 0.02)) + (unless (< (- (float-time) starttime) + flycheck-buttercup-checker-wait-time) + (flycheck-stop) + (signal 'flycheck-buttercup-syntax-check-timed-out nil))) + (setq flycheck-buttercup-syntax-checker-finished nil)) + +(defun flycheck-buttercup-buffer-sync () + "Like `flycheck-buffer', but synchronously." + (setq flycheck-buttercup-syntax-checker-finished nil) + (expect (flycheck-running-p) :not :to-be-truthy) + (flycheck-mode) ;; This will only start a deferred check, + (expect (flycheck-get-checker-for-buffer) :to-be-truthy) + (flycheck-buffer) ;; …so we need an explicit manual check + ;; After starting the check, the checker should either be running now, or + ;; already be finished (if it was fast). + (expect (or flycheck-current-syntax-check + flycheck-buttercup-syntax-checker-finished) + :to-be-truthy) + ;; Also there should be no deferred check pending anymore + (expect (flycheck-deferred-check-p) :not :to-be-truthy) + (flycheck-buttercup-wait-for-syntax-checker)) + +(defun flycheck-buttercup-ensure-clear () + "Clear Flycheck errors and overlays from the current buffer. + +Raise an assertion error if errors or overlays remain afterwards." + (flycheck-clear) + (expect flycheck-current-errors :not :to-be-truthy) + (expect (seq-find (lambda (ov) (overlay-get ov 'flycheck-overlay)) + (overlays-in (point-min) (point-max))) + :not :to-be-truthy)) + + +;;; Error utilities + +(defun flycheck-buttercup-error-without-group (err) + "Return a copy of ERR with the `group' property set to nil." + (let ((copy (copy-flycheck-error err))) + (setf (flycheck-error-group copy) nil) + copy)) + +(defun flycheck-buttercup-sort-errors (errors) + "Sort ERRORS by `flycheck-error-<'." + (seq-sort #'flycheck-error-< errors)) + + +;;; Test assertions + +(defun flycheck-buttercup-should-overlay (error) + "Test that ERROR has a proper overlay in the current buffer. + +ERROR is a Flycheck error object." + (let* ((overlay (seq-find + (lambda (ov) + (equal (flycheck-buttercup-error-without-group + (overlay-get ov 'flycheck-error)) + (flycheck-buttercup-error-without-group error))) + (flycheck-overlays-in 0 (+ 1 (buffer-size))))) + (region + ;; Overlays of errors from other files are on the first line + (if (flycheck-relevant-error-other-file-p error) + (cons (point-min) + (save-excursion (goto-char (point-min)) + (line-end-position))) + (flycheck-error-region-for-mode error 'symbols))) + (level (flycheck-error-level error)) + (category (flycheck-error-level-overlay-category level)) + (face (get category 'face)) + (fringe-bitmap (flycheck-error-level-fringe-bitmap level)) + (fringe-face (flycheck-error-level-fringe-face level)) + (fringe-icon (list 'left-fringe fringe-bitmap fringe-face))) + (expect overlay :to-be-truthy) + (expect (overlay-get overlay 'flycheck-overlay) :to-be-truthy) + (expect (overlay-start overlay) :to-equal (car region)) + (expect (overlay-end overlay) :to-equal (cdr region)) + (expect (overlay-get overlay 'face) :to-equal face) + (expect (get-char-property 0 'display + (overlay-get overlay 'before-string)) + :to-equal fringe-icon) + (expect (overlay-get overlay 'category) :to-equal category) + (expect (flycheck-buttercup-error-without-group + (overlay-get overlay 'flycheck-error)) + :to-equal + (flycheck-buttercup-error-without-group error)))) + +(defun flycheck-buttercup-should-errors (&rest errors) + "Test that the current buffer has ERRORS. + +ERRORS is a list of errors expected to be present in the current +buffer. Each error is given as a list of arguments to +`flycheck-error-new-at'. + +If ERRORS are omitted, test that there are no errors at all in +the current buffer. + +With ERRORS, test that each error in ERRORS is present in the +current buffer, and that the number of errors in the current +buffer is equal to the number of given ERRORS. In other words, +check that the buffer has all ERRORS, and no other errors." + (let ((expected (flycheck-buttercup-sort-errors + (mapcar (apply-partially #'apply #'flycheck-error-new-at) + errors))) + (current (flycheck-buttercup-sort-errors flycheck-current-errors))) + (expect (mapcar #'flycheck-buttercup-error-without-group expected) + :to-equal + (mapcar #'flycheck-buttercup-error-without-group current)) + ;; Check that related errors are the same + (cl-mapcar + (lambda (err1 err2) + (expect (flycheck-buttercup-sort-errors + (mapcar #'flycheck-buttercup-error-without-group + (flycheck-related-errors err1 expected))) + :to-equal + (flycheck-buttercup-sort-errors + (mapcar #'flycheck-buttercup-error-without-group + (flycheck-related-errors err2))))) + expected current) + (mapc #'flycheck-buttercup-should-overlay expected)) + (expect (length errors) + :to-equal + (length (flycheck-overlays-in (point-min) (point-max))))) + +(defun flycheck-buttercup-should-syntax-check-in-buffer (&rest errors) + "Test a syntax check in the current buffer, expecting ERRORS. + +This is like `flycheck-buttercup-should-syntax-check', but with a +buffer in the right mode instead of a file." + ;; Load safe file-local variables because some tests depend on them + (let ((enable-local-variables :safe) + ;; Disable all hooks at this place, to prevent 3rd party packages + ;; from interfering + (hack-local-variables-hook)) + (hack-local-variables)) + ;; Configure config file locating for unit tests + (let ((process-hook-called 0) + (suspicious nil)) + (add-hook 'flycheck-process-error-functions + (lambda (_err) + (setq process-hook-called (1+ process-hook-called)) + nil) + nil :local) + (add-hook 'flycheck-status-changed-functions + (lambda (status) + (when (eq status 'suspicious) + (setq suspicious t))) + nil :local) + (flycheck-buttercup-buffer-sync) + (when suspicious + (signal 'flycheck-buttercup-suspicious-checker nil)) + (apply #'flycheck-buttercup-should-errors errors) + (expect process-hook-called :to-equal (length errors))) + (flycheck-buttercup-ensure-clear)) + +(defun flycheck-buttercup-should-syntax-check (resource-file modes &rest errors) + "Test a syntax check in RESOURCE-FILE with MODES. + +RESOURCE-FILE is the file to check. MODES is a single major mode +symbol or a list thereof, specifying the major modes to syntax +check with. If more than one major mode is specified, the test +is run for each mode separately, so if you give three major +modes, the entire test will run three times. ERRORS is the list +of expected errors, as in `flycheck-buttercup-should-errors'. If +omitted, the syntax check must not emit any errors. The errors +are cleared after each test. + +The syntax checker is selected via standard syntax checker +selection. To test a specific checker, you need to set +`flycheck-checker' or `flycheck-disabled-checkers' accordingly +before using this predicate, depending on whether you want to use +manual or automatic checker selection. + +During the syntax check, configuration files of syntax checkers +are also searched in the `config-files' sub-directory of the +resource directory." + (when (symbolp modes) + (setq modes (list modes))) + (dolist (mode modes) + (unless (fboundp mode) + (buttercup-skip (format "%S missing" mode))) + (flycheck-buttercup-with-resource-buffer resource-file + (funcall mode) + (apply #'flycheck-buttercup-should-syntax-check-in-buffer errors)))) + + +;;; Additional matchers + +(buttercup-define-matcher :to-be-at-flycheck-error (point-val n-val) + "Match that POINT-VAL is at the N-VAL'th Flycheck error." + (let* ((pt (funcall point-val)) + (n (funcall n-val)) + (error (nth (1- n) flycheck-current-errors)) + (mode flycheck-highlighting-mode) + (region (flycheck-error-region-for-mode error mode)) + (at-error (and (member error (flycheck-overlay-errors-at pt)) + (= pt (car region))))) + (if at-error + (cons t (format "Expected point %s not to be at error %s, but it is" + pt n)) + (let ((errors (flycheck-overlay-errors-at pt))) + (if (null errors) + (cons nil + (format "Expected to be at error %s, but no error at point %s" + n pt)) + (let ((pos (cl-position (car errors) flycheck-current-errors))) + (cons nil + (format "Expected to be at point %s and error %s, \ +but point %s is at error %s" + (car (flycheck-error-region-for-mode + (nth (1- n) flycheck-current-errors) + flycheck-highlighting-mode)) + n pt (1+ pos))))))))) + + +;;; Test case definitions + +(defun flycheck-buttercup--parse-keys-and-body (keys-and-body) + "Parse KEYS-AND-BODY into keyword-value pairs and body forms. + +KEYS-AND-BODY is a list of alternating keyword-value pairs +followed by body forms. Return a cons cell (KEYS . BODY)." + (let ((keys nil) + (body keys-and-body)) + (while (keywordp (car body)) + (let ((key (pop body)) + (val (pop body))) + (push key keys) + (push val keys))) + (cons (nreverse keys) body))) + +(defmacro flycheck-buttercup-def-checker-test (checker language name + &rest keys-and-body) + "Define a buttercup test case for a syntax CHECKER for LANGUAGE. + +CHECKER is a symbol or a list of symbols denoting syntax checkers +being tested by the test. The test case is skipped, if any of +these checkers cannot be used. LANGUAGE is a symbol or a list of +symbols denoting the programming languages supported by the +syntax checkers. This is currently only used for naming the test +appropriately. + +NAME is a symbol denoting the local name of the test. The test +itself is ultimately named +`flycheck-define-checker/CHECKER/NAME'. + +Optionally, the keyword arguments `:tags' and `:expected-result' +may be given. `:expected-result :failed' will generate an `xit' +instead of `it' to mark the test as pending. + +The remaining forms KEYS-AND-BODY denote the body of the test +case, including assertions and setup code." + (declare (indent 3)) + (unless checker + (error "No syntax checkers specified")) + (unless language + (error "No languages specified")) + (let* ((checkers (if (symbolp checker) (list checker) checker)) + (checker (car checkers)) + (local-name (or name 'default)) + (full-name (format "flycheck-define-checker/%s/%s" + checker local-name)) + (parsed (flycheck-buttercup--parse-keys-and-body keys-and-body)) + (keys (car parsed)) + (body (cdr parsed)) + (expected-result (plist-get keys :expected-result)) + (it-fn (if (eq expected-result :failed) 'xit 'it)) + (skip-forms (mapcar (lambda (c) + `(assume + ;; Ignore non-command checkers + (or (not (flycheck-checker-get ',c 'command)) + (executable-find + (flycheck-checker-executable ',c))))) + checkers))) + `(,it-fn ,full-name + (lambda () + ,@skip-forms + ,@body)))) + +(provide 'flycheck-buttercup) + +;; Disable byte compilation for this library, to prevent package.el choking on a +;; missing `buttercup' library. See +;; https://github.com/flycheck/flycheck/issues/860 + +;; Local Variables: +;; no-byte-compile: t +;; End: + +;;; flycheck-buttercup.el ends here diff --git a/elpa/flycheck-20251128.1706/flycheck-pkg.el b/elpa/flycheck-20260320.1715/flycheck-pkg.el similarity index 71% rename from elpa/flycheck-20251128.1706/flycheck-pkg.el rename to elpa/flycheck-20260320.1715/flycheck-pkg.el index f7d9a27b..4011a0d4 100644 --- a/elpa/flycheck-20251128.1706/flycheck-pkg.el +++ b/elpa/flycheck-20260320.1715/flycheck-pkg.el @@ -1,11 +1,11 @@ ;; -*- no-byte-compile: t; lexical-binding: nil -*- -(define-package "flycheck" "20251128.1706" +(define-package "flycheck" "20260320.1715" "On-the-fly syntax checking." '((emacs "27.1") (seq "2.24")) - :url "https://www.flycheck.org" - :commit "62570fafbedb8fa3f7d75a50a9364feca3b294ef" - :revdesc "62570fafbedb" + :url "https://github.com/flycheck/flycheck" + :commit "0e5eb8300d32fd562724216c19eaf199ee1451ab" + :revdesc "0e5eb8300d32" :keywords '("convenience" "languages" "tools") :authors '(("Sebastian Wiesner" . "swiesner@lunaryorn.com")) :maintainers '(("Clément Pit-Claudel" . "clement.pitclaudel@live.com") diff --git a/elpa/flycheck-20251128.1706/flycheck.el b/elpa/flycheck-20260320.1715/flycheck.el similarity index 91% rename from elpa/flycheck-20251128.1706/flycheck.el rename to elpa/flycheck-20260320.1715/flycheck.el index 939bdec4..cdaceccd 100644 --- a/elpa/flycheck-20251128.1706/flycheck.el +++ b/elpa/flycheck-20260320.1715/flycheck.el @@ -8,10 +8,10 @@ ;; Maintainer: Clément Pit-Claudel ;; fmdkdd ;; Bozhidar Batsov -;; URL: https://www.flycheck.org +;; URL: https://github.com/flycheck/flycheck ;; Keywords: convenience, languages, tools -;; Package-Version: 20251128.1706 -;; Package-Revision: 62570fafbedb +;; Package-Version: 20260320.1715 +;; Package-Revision: 0e5eb8300d32 ;; Package-Requires: ((emacs "27.1") (seq "2.24")) ;; This file is not part of GNU Emacs. @@ -79,7 +79,6 @@ (require 'rx) ; Regexp fanciness in `flycheck-define-checker' (require 'help-mode) ; `define-button-type' (require 'find-func) ; `find-function-regexp-alist' -(require 'json) ; `flycheck-parse-json' (require 'ansi-color) ; `flycheck-parse-with-patterns-without-color' @@ -91,7 +90,7 @@ (defvar markdown-fontify-code-blocks-natively) ; ;; Tell the byte compiler about autoloaded functions from packages -(declare-function pkg-info-version-info "pkg-info" (package)) +(declare-function org-lint "org-lint" (&optional arg)) ;;; Customization @@ -125,7 +124,6 @@ (defcustom flycheck-checkers '(ada-gnat asciidoctor - asciidoc awk-gawk bazel-build-buildifier bazel-module-buildifier @@ -136,8 +134,6 @@ c/c++-cppcheck cfengine coffee - coffee-coffeelint - css-csslint css-stylelint cuda-nvcc cwl @@ -149,8 +145,6 @@ ember-template erlang-rebar3 erlang - eruby-erubis - eruby-ruumba fortran-gfortran go-gofmt go-vet @@ -168,9 +162,8 @@ haskell-hlint html-tidy javascript-eslint - javascript-jshint + javascript-oxlint javascript-standard - json-jsonlint json-python-json json-jq jsonnet @@ -184,8 +177,8 @@ markdown-mdl markdown-pymarkdown nix - nix-linter opam + org-lint perl perl-perlcritic perl-perlimports @@ -196,7 +189,6 @@ processing proselint protobuf-protoc - protobuf-prototool pug puppet-parser puppet-lint @@ -217,7 +209,6 @@ ruby-standard ruby-reek ruby - ruby-jruby rust-cargo rust rust-clippy @@ -225,12 +216,8 @@ scala scala-scalastyle scheme-chicken - scss-lint sass-stylelint scss-stylelint - sass/scss-sass-lint - sass - scss sh-bash sh-posix-dash sh-posix-bash @@ -248,14 +235,11 @@ tex-lacheck texinfo textlint - typescript-tslint verilog-verilator vhdl-ghdl - xml-xmlstarlet xml-xmllint yaml-actionlint yaml-jsyaml - yaml-ruby yaml-yamllint) "Syntax checkers available for automatic selection. @@ -358,7 +342,7 @@ maximum number of errors per syntax checker and buffer, or nil to not limit the errors reported from a syntax checker. If this variable is a number and a syntax checker reports more -errors than the value of this variable, its errors are not +errors than the value of this variable, its errors are discarded, and not highlighted in the buffer or available in the error list. The affected syntax checker is also disabled for future syntax checks of the buffer." @@ -483,7 +467,7 @@ commands through `bundle exec', `nix-shell' or similar wrappers." The value of this option is a function which is given the name or path of an executable and shall return the full path to the -executable, or nil if the executable does not exit. +executable, or nil if the executable does not exist. The default is `flycheck-default-executable-find', which searches variable `exec-path' when given a command name, and resolves @@ -647,7 +631,7 @@ nil `flycheck-highlighting-mode' to nil. `level-face' - Chose a face depending on the severity of the error, and + Choose a face depending on the severity of the error, and apply it to the whole error text. See also the `flycheck-define-error-level' and `flycheck-error', `flycheck-warning', and `flycheck-info' faces. @@ -700,7 +684,7 @@ The following events are known: Check syntax immediately when variable `flycheck-mode' is non-nil. -Flycheck performs a syntax checks only on events, which are +Flycheck performs syntax checks only on events, which are contained in this list. For instance, if the value of this variable is `(mode-enabled save)', Flycheck will only check if the mode is enabled or the buffer was saved, but never after @@ -834,24 +818,16 @@ display all errors from other files." :package-version '(flycheck . "32")) (defcustom flycheck-relevant-error-other-file-show t - "Whether to show errors from other files." + "Whether to show errors from other files. + +When non-nil, errors reported by a checker that reference files +other than the one being checked are shown in the error list and +highlighted in the buffer." :group 'flycheck :type 'boolean :package-version '(flycheck . "32") :safe #'booleanp) -(defcustom flycheck-completing-read-function #'completing-read - "Function to read from minibuffer with completion. - -The function must be compatible to the built-in `completing-read' -function." - :group 'flycheck - :type '(choice (const :tag "Default" completing-read) - (const :tag "IDO" ido-completing-read) - (function :tag "Custom function")) - :risky t - :package-version '(flycheck . "26")) - (defcustom flycheck-temp-prefix "flycheck" "Prefix for temporary files created by Flycheck." :group 'flycheck @@ -1033,7 +1009,7 @@ is used." (defface flycheck-error-list-column-number '((t)) - "Face for line numbers in the error list." + "Face for column numbers in the error list." :group 'flycheck-faces :package-version '(flycheck . "0.16")) @@ -1101,17 +1077,16 @@ is used." map) "Keymap of Flycheck interactive commands.") +(fset 'flycheck-command-map flycheck-command-map) + (defcustom flycheck-keymap-prefix (kbd "C-c !") "Prefix for key bindings of Flycheck. Changing this variable outside Customize does not have any -effect. To change the keymap prefix from Lisp, you need to -explicitly re-define the prefix key: +effect. To change the keymap prefix from Lisp, use +`customize-set-variable': - (define-key flycheck-mode-map flycheck-keymap-prefix nil) - (setq flycheck-keymap-prefix (kbd \"C-c f\")) - (define-key flycheck-mode-map flycheck-keymap-prefix - flycheck-command-map) + (customize-set-variable \\='flycheck-keymap-prefix (kbd \"C-c f\")) Please note that Flycheck's manual documents the default keybindings. Changing this variable is at your own risk." @@ -1272,27 +1247,20 @@ Only has effect when variable `global-flycheck-mode' is non-nil." ["Read the Flycheck manual" flycheck-manual t])) "Menu of command `flycheck-mode'.") -(easy-menu-add-item nil '("Tools") flycheck-mode-menu-map "Spell Checking") +(when (lookup-key global-map [menu-bar tools]) + (easy-menu-add-item nil '("Tools") flycheck-mode-menu-map "Spell Checking")) -(defconst flycheck-version "35.0" +(defconst flycheck-version "36.0" "The current version of Flycheck. Should be kept in sync with the package version metadata. -Used only when `package-get-function' is not available -or fails.") +Used as fallback when `package-get-version' returns nil.") (defun flycheck--pkg-version () "Extract FLYCHECK's package version from its package metadata." - ;; Use `cond' below to avoid a compiler unused return value warning - ;; when `package-get-version' returns nil. See #3181. - (cond ((fboundp 'package-get-version) - (package-get-version)) - ((fboundp 'pkg-info-version-info) - (pkg-info-version-info 'flycheck)) - (t - flycheck-version))) + (or (package-get-version) flycheck-version)) ;;; Version information, manual and loading of Flycheck (defun flycheck-version (&optional show-version) @@ -1302,7 +1270,7 @@ If called interactively or if SHOW-VERSION is non-nil, show the version in the echo area and the messages buffer. The returned string includes both, the version from package.el -and the library version, if both a present and different. +and the library version, if both are present and different. If the version number could not be determined, signal an error, if called interactively, or if SHOW-VERSION is non-nil, otherwise @@ -1316,7 +1284,8 @@ just return nil." (defun flycheck-unload-function () "Unload function for Flycheck." (global-flycheck-mode -1) - (easy-menu-remove-item nil '("Tools") (cadr flycheck-mode-menu-map)) + (when (lookup-key global-map [menu-bar tools]) + (easy-menu-remove-item nil '("Tools") (cadr flycheck-mode-menu-map))) (remove-hook 'kill-emacs-hook #'flycheck-global-teardown) (setq find-function-regexp-alist (assq-delete-all 'flycheck-checker find-function-regexp-alist))) @@ -1333,7 +1302,7 @@ just return nil." (interactive) (with-current-buffer (get-buffer-create "*flycheck-quick-help*") (with-help-window (current-buffer) - (flycheck-mode) ;; so that we can exapnd \\[flycheck-] + (flycheck-mode) ;; so that we can expand \\[flycheck-] (let ((help (substitute-command-keys "Flycheck automatically runs checks on writable files when changed. @@ -1363,9 +1332,6 @@ Key bindings: (read-only-mode 0) (insert help))))) -(define-obsolete-function-alias 'flycheck-info - 'flycheck-manual "Flycheck 26" "Open the Flycheck manual.") - ;;; Utility functions (defun flycheck-sexp-to-string (sexp) @@ -1387,10 +1353,6 @@ to a number and return it. Otherwise return nil." (when (and (stringp string) (string-match-p number-re string)) (string-to-number string)))) -(defun flycheck-string-or-nil-p (obj) - "Determine if OBJ is a string or nil." - (or (null obj) (stringp obj))) - (defun flycheck-string-list-p (obj) "Determine if OBJ is a list of strings." (and (listp obj) (seq-every-p #'stringp obj))) @@ -1545,7 +1507,7 @@ spliced into the resulting list." ((and (listp result) (seq-every-p #'stringp result)) result) ((stringp result) (list result)) (t (error "Invalid result type for option: %S" result))))))) - (apply #'append (seq-map prepend items)))) + (seq-mapcat prepend items))) (defun flycheck-find-in-buffer (pattern) "Find PATTERN in the current buffer. @@ -1612,20 +1574,33 @@ Safely delete all files and directories listed in (seq-do #'flycheck-safe-delete flycheck-temporaries) (setq flycheck-temporaries nil)) -(defun flycheck-rx-file-name (form) - "Translate the `(file-name)' FORM into a regular expression." - (let ((body (or (cdr form) '((minimal-match - (one-or-more not-newline)))))) - (rx-to-string `(group-n 1 ,@body) t))) - -(defun flycheck-rx-message (form) - "Translate the `(message)' FORM into a regular expression." - (let ((body (or (cdr form) '((one-or-more not-newline))))) - (rx-to-string `(group-n 4 ,@body) t))) - -(defun flycheck-rx-id (form) - "Translate the `(id)' FORM into a regular expression." - (rx-to-string `(group-n 5 ,@(cdr form)) t)) +;; We use a custom tree-walking expander instead of `rx-define' or +;; `rx-let' because those don't support optional arguments with +;; defaults. For example, `(file-name)' should use a default body +;; while `(file-name SEXP ...)' uses a custom one — this conditional +;; logic cannot be expressed with `rx-define's parameter mechanism, +;; which only supports required args and `&rest'. +(defun flycheck--rx-expand (form) + "Expand Flycheck-specific rx constructs in FORM. + +Recursively walks the form tree and expands `file-name', `line', +`column', `message', `id', `end-line', and `end-column'." + (pcase form + ('line '(group-n 2 (one-or-more digit))) + ('column '(group-n 3 (one-or-more digit))) + ('end-line '(group-n 6 (one-or-more digit))) + ('end-column '(group-n 7 (one-or-more digit))) + (`(file-name . ,body) + (let ((body (or body '((minimal-match (one-or-more not-newline)))))) + `(group-n 1 ,@(mapcar #'flycheck--rx-expand body)))) + (`(message . ,body) + (let ((body (or body '((one-or-more not-newline))))) + `(group-n 4 ,@(mapcar #'flycheck--rx-expand body)))) + (`(id . ,body) + `(group-n 5 ,@(mapcar #'flycheck--rx-expand body))) + ((pred consp) + (mapcar #'flycheck--rx-expand form)) + (_ form))) (defun flycheck-rx-to-string (form &optional no-group) "Like `rx-to-string' for FORM, but with special keywords: @@ -1659,17 +1634,7 @@ Safely delete all files and directories listed in NO-GROUP is passed to `rx-to-string'. See `rx' for a complete list of all built-in `rx' forms." - (let ((rx-constituents - (append - `((file-name flycheck-rx-file-name 0 nil) ;; group 1 - (line . ,(rx (group-n 2 (one-or-more digit)))) - (column . ,(rx (group-n 3 (one-or-more digit)))) - (message flycheck-rx-message 0 nil) ;; group 4 - (id flycheck-rx-id 0 nil) ;; group 5 - (end-line . ,(rx (group-n 6 (one-or-more digit)))) - (end-column . ,(rx (group-n 7 (one-or-more digit))))) - rx-constituents nil))) - (rx-to-string form no-group))) + (rx-to-string (flycheck--rx-expand form) no-group)) (defun flycheck-current-load-file () "Get the source file currently being loaded. @@ -1730,7 +1695,7 @@ FILE-NAME is nil, return `default-directory'." tick point line) (defvar-local flycheck--line-cache nil - "Cache used to speed ip `flycheck-goto-line'.") + "Cache used to speed up `flycheck-goto-line'.") (defsubst flycheck--init-line-cache () "Initialize or reinitialize `flycheck--line-cache'." @@ -1783,17 +1748,13 @@ COLUMN is one-based." (defun flycheck-completing-read (prompt candidates default &optional history) "Read a value from the minibuffer. -Use `flycheck-completing-read-function' to read input from the -minibuffer with completion. - Show PROMPT and read one of CANDIDATES, defaulting to DEFAULT. -HISTORY is passed to `flycheck-completing-read-function'. +HISTORY is passed to `completing-read'. -Note that `flycheck-completing-read-function' may return an empty -string instead of nil, even when \"\" isn't among the candidates. -See `completing-read' for more details." - (funcall flycheck-completing-read-function - prompt candidates nil 'require-match nil history default)) +Note that `completing-read' may return an empty string instead of +nil, even when \"\" isn't among the candidates. Customize +`completing-read-function' to change the completion UI globally." + (completing-read prompt candidates nil 'require-match nil history default)) (defun flycheck-read-checker (prompt &optional default property candidates) "Read a flycheck checker from minibuffer with PROMPT and DEFAULT. @@ -1813,7 +1774,7 @@ chosen. If DEFAULT is nil and no checker was chosen, signal a a default on its own." (when (and default (not (flycheck-valid-checker-p default))) (error "%S is no valid Flycheck checker" default)) - (let* ((candidates (seq-map #'symbol-name + (let* ((candidates (mapcar #'symbol-name (or candidates (flycheck-defined-checkers property)))) (default (and default (symbol-name default))) @@ -1832,9 +1793,9 @@ a default on its own." (defun flycheck-read-error-level (prompt) "Read an error level from the user with PROMPT. -Only offers level for which errors currently exist, in addition +Only offers levels for which errors currently exist, in addition to the default levels." - (let* ((levels (seq-map #'flycheck-error-level + (let* ((levels (mapcar #'flycheck-error-level (flycheck-error-list-current-errors))) (levels-with-defaults (append '(info warning error) levels)) (uniq-levels (seq-uniq levels-with-defaults)) @@ -1850,7 +1811,7 @@ to the default levels." PROPERTY is a symbol. If given, only return syntax checkers with a non-nil value for PROPERTY. -The returned list is sorted alphapetically by the symbol name of +The returned list is sorted alphabetically by the symbol name of the syntax checkers." (let (defined-checkers) (mapatoms (lambda (symbol) @@ -1935,7 +1896,7 @@ Signal an error if NEXT is not a valid entry for (defun flycheck-define-generic-checker (symbol docstring &rest properties) "Define SYMBOL as generic syntax checker. -Any syntax checker defined with this macro is eligible for manual +Any syntax checker defined with this function is eligible for manual syntax checker selection with `flycheck-select-checker'. To make the new syntax checker available for automatic selection, it must be registered in `flycheck-checkers'. @@ -2148,7 +2109,7 @@ are mandatory. then run a linting tool that checks for insecure code, or questionable style. - This property is optional. If omitted, it defaults to the + This property is optional. If omitted, it defaults to nil, i.e. no other syntax checkers are applied after this syntax checker. @@ -2368,7 +2329,7 @@ nil otherwise." '(flycheck-checker . flycheck-find-checker-regexp)) (defun flycheck-goto-checker-definition (checker file) - "Go to to the definition of CHECKER in FILE." + "Go to the definition of CHECKER in FILE." (let ((location (find-function-search-for-symbol checker 'flycheck-checker file))) (pop-to-buffer (car location)) @@ -2429,7 +2390,7 @@ Pop up a help buffer with the documentation of CHECKER." ;; it later (princ " This syntax checker checks syntax in the major mode(s) ") (princ (string-join - (seq-map (apply-partially #'format "`%s'") modes) + (mapcar (apply-partially #'format "`%s'") modes) ", ")) (when predicate (princ ", and uses a custom predicate")) @@ -2617,9 +2578,9 @@ When WITH-SELECT is non-nil, add a button to select this checker." (princ "\n")) (defun flycheck--get-next-checker-symbol (next) - "Get the checker symmbol of NEXT checker. + "Get the checker symbol of NEXT checker. -NEXT should be either a cons (NEXT-CHECKER . LEVEL) or a +NEXT should be either a cons (LEVEL . CHECKER) or a symbol." (if (consp next) (cdr next) next)) @@ -2668,7 +2629,7 @@ return value is a list of checkers, not including CHECKER." "Print a title with DESC for BUFFER in the current buffer. DESC is an arbitrary string containing a description, and BUFFER -is the buffer being verified. The name and the major mode mode +is the buffer being verified. The name and the major mode of BUFFER are printed. DESC and information about BUFFER are printed in the current @@ -2751,7 +2712,7 @@ is applicable from Emacs Lisp code. Use "Check whether Flycheck can be used in this buffer. Display a new buffer listing all syntax checkers that could be -applicable in the current buffer. For each syntax checkers, +applicable in the current buffer. For each syntax checker, possible problems are shown." (interactive) ;; Save to make sure checkers that only work on saved buffers will pass the @@ -2922,7 +2883,7 @@ Slots: The context object. `working-directory' - Working directory for the syntax checker. Serve as a value for + Working directory for the syntax checker. Serves as a value for `default-directory' for a checker." buffer checker context working-directory) @@ -2964,7 +2925,8 @@ Slots: ;; Handle events that may start automatic syntax checks (after-save-hook . flycheck-handle-save) (after-change-functions . flycheck-handle-change) - ;; Handle events that may triggered pending deferred checks + (after-revert-hook . flycheck-handle-revert) + ;; Handle events that may trigger pending deferred checks (window-configuration-change-hook . flycheck-perform-deferred-syntax-check) (post-command-hook . flycheck-perform-deferred-syntax-check) ;; Teardown Flycheck whenever the buffer state is about to get lost, to @@ -2975,16 +2937,11 @@ Slots: ;; Update the error list if necessary (post-command-hook . flycheck-error-list-update-source) (post-command-hook . flycheck-error-list-highlight-errors) - ;; Display errors. Show errors at point after commands (like movements) and - ;; when Emacs gets focus. Cancel the display timer when Emacs looses focus - ;; (as there's no need to display errors if the user can't see them), and - ;; hide the error buffer (for large error messages) if necessary. Note that - ;; the focus hooks only work on Emacs 24.4 and upwards, but since undefined - ;; hooks are perfectly ok we don't need a version guard here. They'll just - ;; not work silently. + ;; Display errors. Show errors at point after commands (like movements) + ;; and hide the error buffer (for large error messages) if necessary. + ;; Focus change handling is done separately via + ;; `after-focus-change-function' (see `flycheck-handle-focus-change'). (post-command-hook . flycheck-display-error-at-point-soon) - (focus-in-hook . flycheck-display-error-at-point-soon) - (focus-out-hook . flycheck-cancel-error-display-error-at-point-timer) (post-command-hook . flycheck-hide-error-buffer) ;; Immediately show error popups when navigating to an error (next-error-hook . flycheck-display-error-at-point)) @@ -3115,7 +3072,7 @@ CHECKER will be used, even if it is not contained in (list nil) (list (flycheck-read-checker "Select checker: " (flycheck-get-checker-for-buffer))))) - (when (not (eq checker flycheck-checker)) + (unless (eq checker flycheck-checker) (unless (or (not checker) (flycheck-may-use-checker checker)) (flycheck-verify-checker checker) (user-error "Can't use syntax checker %S in this buffer" checker)) @@ -3174,7 +3131,7 @@ buffer-local value of `flycheck-disabled-checkers'." ;;; Syntax checks for the current buffer (defvar-local flycheck-current-syntax-check nil - "The current syntax check in the this buffer.") + "The current syntax check in this buffer.") (put 'flycheck-current-syntax-check 'permanent-local t) (defun flycheck-start-current-syntax-check (checker) @@ -3244,11 +3201,11 @@ Get a syntax checker for the current buffer with (defun flycheck-report-buffer-checker-status (syntax-check status &optional data) - "In BUFFER, report a SYNTAX-CHECK STATUS with DATA. + "Report a SYNTAX-CHECK STATUS with DATA. SYNTAX-CHECK is the `flycheck-syntax-check' which reported -STATUS. STATUS denotes the status of CHECKER, with an optional -DATA. STATUS may be one of the following symbols: +STATUS. STATUS denotes the status of the syntax check, with an +optional DATA. STATUS may be one of the following symbols: `errored' The syntax checker has errored. DATA is an optional error @@ -3396,8 +3353,7 @@ current syntax check." "Empty variables used by Flycheck." (kill-local-variable 'flycheck--file-truename-cache) (kill-local-variable 'flycheck--idle-trigger-timer) - (kill-local-variable 'flycheck--idle-trigger-conditions) - (kill-local-variable 'flycheck--last-error-display-tick)) + (kill-local-variable 'flycheck--idle-trigger-conditions)) (defun flycheck-teardown (&optional ignore-global) "Teardown Flycheck in the current buffer. @@ -3482,17 +3438,18 @@ The syntax check is deferred if FORCE-DEFERRED is non-nil, or if (defun flycheck--handle-idle-trigger (buffer) "Run a syntax check in BUFFER if appropriate. This function is called by `flycheck--idle-trigger-timer'." - (let ((current-buffer (current-buffer))) - (when (buffer-live-p buffer) - (with-current-buffer buffer - (unless (or flycheck-buffer-switch-check-intermediate-buffers - (eq buffer current-buffer)) - (setq flycheck--idle-trigger-conditions - (delq 'idle-buffer-switch - flycheck--idle-trigger-conditions))) - (when flycheck--idle-trigger-conditions - (flycheck-buffer-automatically flycheck--idle-trigger-conditions) - (setq flycheck--idle-trigger-conditions nil)))))) + (save-match-data + (let ((current-buffer (current-buffer))) + (when (buffer-live-p buffer) + (with-current-buffer buffer + (unless (or flycheck-buffer-switch-check-intermediate-buffers + (eq buffer current-buffer)) + (setq flycheck--idle-trigger-conditions + (delq 'idle-buffer-switch + flycheck--idle-trigger-conditions))) + (when flycheck--idle-trigger-conditions + (flycheck-buffer-automatically flycheck--idle-trigger-conditions) + (setq flycheck--idle-trigger-conditions nil))))))) (defun flycheck-handle-change (beg end _len) "Handle a buffer change between BEG and END. @@ -3557,6 +3514,14 @@ If a buffer switch actually happened, schedule a syntax check." "Handle a save of the buffer." (flycheck-buffer-automatically 'save)) +(defun flycheck-handle-revert () + "Handle a buffer revert. +Start a syntax check after the buffer has been reverted, but only +if `flycheck-mode' is still active (it may have been killed by +`revert-buffer' via `kill-all-local-variables')." + (when flycheck-mode + (flycheck-buffer))) + ;;; Deferred syntax checking (defvar-local flycheck-deferred-syntax-check nil @@ -3609,6 +3574,7 @@ Flycheck mode is not enabled for - the minibuffer, - `fundamental-mode' - major modes whose `mode-class' property is `special', +- Flycheck's own error message buffer, - ephemeral buffers (see `flycheck-ephemeral-buffer-p'), - encrypted buffers (see `flycheck-encrypted-buffer-p'), - remote files (see `file-remote-p'), @@ -3624,6 +3590,7 @@ otherwise." (not (or (minibufferp) (eq major-mode 'fundamental-mode) (eq (get major-mode 'mode-class) 'special) + (derived-mode-p 'flycheck-error-message-mode) (flycheck-ephemeral-buffer-p) (flycheck-encrypted-buffer-p) (and (buffer-file-name) @@ -3732,7 +3699,7 @@ Slots: The column at which the error ends. If nil, this is computed according to `flycheck-highlighting-mode'. Error intervals are right-open: the end-column points to the first character not included in the error. For - example, 1:1 is an empty range. and in \"line-number-at-pos\", the range + example, 1:1 is an empty range, and in \"line-number-at-pos\", the range 6:12 covers the word \"number\". `message' (optional) @@ -3820,7 +3787,7 @@ return nil." "Get the line region of position POS. Return a cons cell `(BEG . END)' where BEG is the first -non-whitespace character on the line ERR refers to, and END the +non-whitespace character on the line POS refers to, and END the end of the line." (save-excursion (goto-char pos) @@ -3841,18 +3808,18 @@ end of the line." (defun flycheck--column-region (pos) "Get the column region of position POS. -Return a cons cell `(BEG . END)' where BEG is the character -before the column, and END the actual column." +Return a cons cell `(BEG . END)' where BEG is the position at +the column, and END is one past it." (save-excursion (goto-char pos) - ;; (eobp): No enough lines in the buffer + ;; (eobp): Not enough lines in the buffer (if (eobp) (cons (1- (point-max)) (point-max)) (cons pos (1+ pos))))) (defun flycheck-bounds-of-thing-at-point (thing pos) "Get the region of THING at position POS. -THING is a understood by `thing-at-point'. +THING is understood by `thing-at-point'. Return a cons cell `(BEG . END)' where BEG is the beginning of the THING at the column, and END the end of the THING." @@ -3934,7 +3901,8 @@ beginning position)." (concat (and other-file-p (format "In %S:\n" (file-relative-name fname))) (and include-snippet (when-let* ((snippet (flycheck-error-format-snippet err))) - (format-message "`%s': " snippet))) + (format-message "`\N{FIRST STRONG ISOLATE}%s\N{POP DIRECTIONAL ISOLATE}': " + snippet))) (or (flycheck-error-message err) (format "Unknown %S" (flycheck-error-level err))) (and id (format " [%s]" id))))) @@ -4030,15 +3998,10 @@ Add ERRORS to `flycheck-current-errors' and process each error with `flycheck-process-error-functions'." (setq flycheck-current-errors (append errors flycheck-current-errors)) (overlay-recenter (point-max)) - ;; We can't use `seq-sort-by' because it's not in Emacs 25's built-in `seq', - ;; and installing an updated version doesn't help (this is a package.el bug; - ;; see https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg01974.html). (seq-do (lambda (err) (run-hook-with-args-until-success 'flycheck-process-error-functions err)) - (seq-sort (lambda (e1 e2) - (< (flycheck-error-line e1) (flycheck-error-line e2))) - errors))) + (seq-sort-by #'flycheck-error-line #'< errors))) (defun flycheck-clear-errors () "Remove all error information from the current buffer." @@ -4185,8 +4148,9 @@ nil." (`errored "!") (`finished (let-alist (flycheck-count-errors flycheck-current-errors) - (if (or .error .warning) - (format ":%s|%s" (or .error 0) (or .warning 0)) + (if (or .error .warning .info) + (format ":%s|%s|%s" (or .error 0) (or .warning 0) + (or .info 0)) flycheck-mode-success-indicator))) (`interrupted ".") (`suspicious "?"))) @@ -4379,10 +4343,6 @@ show the indicator." ""))) (_ (error "Invalid fringe side: %S" side))))) -(define-obsolete-function-alias - 'flycheck-error-level-make-fringe-icon - 'flycheck-error-level-make-indicator - "33") ;;; Built-in error levels @@ -4522,7 +4482,7 @@ symbols, as in `flycheck-define-error-level')." (defun flycheck-filter-errors (errors checker) "Filter ERRORS from CHECKER. -Apply the error filter of CHECKER to ERRORs and return the +Apply the error filter of CHECKER to ERRORS and return the result. If CHECKER has no error filter, fall back to `flycheck-sanitize-errors'." (let ((filter (or (flycheck-checker-get checker 'error-filter) @@ -4614,7 +4574,7 @@ Return ERRORS, with in-place modifications." (back-to-indentation) ;; If the current line starts with sufficient whitespace, delete the ;; indentation offset. Otherwise keep the line intact, as we might - ;; loose valuable information + ;; lose valuable information (when (>= (- (point) (line-beginning-position)) indent-offset) (delete-char (- indent-offset))) (forward-line 1))) @@ -4757,7 +4717,7 @@ level." (defun flycheck-has-current-errors-p (&optional level) "Determine if the current buffer has errors with LEVEL. -If LEVEL is omitted if the current buffer has any errors at all." +If LEVEL is omitted, check if the current buffer has any errors at all." (if level (flycheck-has-errors-p flycheck-current-errors level) (and flycheck-current-errors t))) @@ -4778,7 +4738,7 @@ preserve overlay order when calling `overlays-at').") "Determine the highlighting style to apply to ERR. Styles are documented in `flycheck-highlighting-style'; this -functions resolves `conditional' style specifications." +function resolves `conditional' style specifications." (let* ((style flycheck-highlighting-style) (first-line (flycheck-error-line err)) (end-line (or (flycheck-error-end-line err) first-line)) @@ -4805,9 +4765,18 @@ functions resolves `conditional' style specifications." (setf (overlay-get overlay 'before-string) (flycheck-error-level-make-indicator level flycheck-indication-mode)) - (setf (overlay-get overlay 'line-prefix) + (setf (overlay-get overlay 'wrap-prefix) (flycheck-error-level-make-indicator - level flycheck-indication-mode t))) + level flycheck-indication-mode t)) + ;; Preserve any existing line-prefix text property (e.g. from + ;; org-indent-mode) so the overlay doesn't clobber indentation. + (when (buffer-live-p (overlay-buffer overlay)) + (save-restriction + (widen) + (let ((existing-prefix (get-text-property + (overlay-start overlay) 'line-prefix))) + (when existing-prefix + (setf (overlay-get overlay 'line-prefix) existing-prefix)))))) (pcase (flycheck--highlighting-style err) ((or `nil (guard (null flycheck-highlighting-mode))) ;; Erase the highlighting @@ -4886,10 +4855,9 @@ overlays." ;; The order of errors returned from overlays is not stable, so we sort ;; them again using the internal index to guarantee errors are always ;; displayed in the same order. - (seq-sort - ;; We can't use `seq-sort-by' here; see above - (lambda (o1 o2) (< (overlay-get o1 'flycheck-error-index) - (overlay-get o2 'flycheck-error-index))) + (seq-sort-by + (lambda (o) (overlay-get o 'flycheck-error-index)) + #'< (seq-filter (lambda (o) (overlay-get o 'flycheck-overlay)) overlays))) (defun flycheck-overlays-at (pos) @@ -4902,16 +4870,16 @@ overlays." (defun flycheck-overlay-errors-at (pos) "Return a list of all flycheck errors overlaid at POS." - (seq-map (lambda (o) (overlay-get o 'flycheck-error)) + (mapcar (lambda (o) (overlay-get o 'flycheck-error)) (flycheck-overlays-at pos))) (defun flycheck-overlay-errors-in (beg end) "Return a list of all flycheck errors overlaid between BEG and END." - (seq-map (lambda (o) (overlay-get o 'flycheck-error)) + (mapcar (lambda (o) (overlay-get o 'flycheck-error)) (flycheck-overlays-in beg end))) (defvar-local flycheck-overlays-to-delete nil - "Overlays mark for deletion after all syntax checks completed.") + "Overlays marked for deletion after all syntax checks completed.") (put 'flycheck-overlays-to-delete 'permanent-local t) (defun flycheck-delete-all-overlays () @@ -4942,15 +4910,11 @@ overlays." (flycheck-error-level-interesting-p (get-char-property pos 'flycheck-error))) (defun flycheck-error-level-interesting-p (err) - "Check if ERR severity is >= `flycheck-navigation-minimum-level'. - -ERR is also interesting (the function returns true) if there are -no errors as or more severe than `flycheck-navigation-minimum-level'." + "Check if ERR severity is >= `flycheck-navigation-minimum-level'." (when (flycheck-error-p err) (if-let (min-level flycheck-navigation-minimum-level) - (or (<= (flycheck-error-level-severity min-level) - (flycheck-error-level-severity (flycheck-error-level err))) - (not (flycheck-has-current-errors-p min-level))) + (<= (flycheck-error-level-severity min-level) + (flycheck-error-level-severity (flycheck-error-level err))) t))) (defun flycheck-next-error-pos (n &optional reset) @@ -5080,7 +5044,7 @@ message to stretch arbitrarily far." (format "%s (%s)" message checker-name))) (defconst flycheck-error-list-format - `[("File" 6) + `[("File" 12) ("Line" 5 flycheck-error-list-entry-< :right-align t) ("Col" 3 nil :right-align t) ("Level" 8 flycheck-error-list-entry-level-<) @@ -5120,7 +5084,7 @@ message to stretch arbitrarily far." (defvar-local flycheck-error-list-source-buffer nil "The current source buffer of the error list.") -;; Needs to permanently local to preserve the source buffer across buffer +;; Needs to be permanently local to preserve the source buffer across buffer ;; reversions (put 'flycheck-error-list-source-buffer 'permanent-local t) @@ -5188,9 +5152,9 @@ string with attached text properties." face)) (defun flycheck-error-list-make-entry (error) - "Make a table cell for the given ERROR. + "Make a table entry for the given ERROR. -Return a list with the contents of the table cell." +Return a list of (ID CELLS) for `tabulated-list-entries'." (let* ((level (flycheck-error-level error)) (level-face (flycheck-error-level-error-list-face level)) (filename (flycheck-error-filename error)) @@ -5217,7 +5181,7 @@ Return a list with the contents of the table cell." column 'flycheck-error-list-column-number) (flycheck-error-list-make-cell (symbol-name (flycheck-error-level error)) level-face) - ;; Error ID use a different face when an error-explainer is + ;; Error IDs use a different face when an error-explainer is ;; present (flycheck-error-list-make-cell id-str (if explainer 'flycheck-error-list-id-with-explainer @@ -5246,7 +5210,7 @@ ensure that they line up properly once the message is displayed." "Create the entries for the error list." (when-let* ((errors (flycheck-error-list-current-errors)) (filtered (flycheck-error-list-apply-filter errors))) - (seq-map #'flycheck-error-list-make-entry filtered))) + (mapcar #'flycheck-error-list-make-entry filtered))) (defun flycheck-error-list-entry-< (entry1 entry2) "Determine whether ENTRY1 is before ENTRY2 by location. @@ -5377,13 +5341,26 @@ Interactively, or with non-nil REFRESH, refresh the error list." errors) errors)) +(defcustom flycheck-error-list-after-jump-hook nil + "Functions to run after jumping to an error from the error list. + +This hook is run in the source buffer after +`flycheck-error-list-goto-error' jumps to the error location. +Useful for post-jump actions like recentering: + + (add-hook \\='flycheck-error-list-after-jump-hook #\\='recenter)" + :group 'flycheck + :type 'hook + :package-version '(flycheck . "36")) + (defun flycheck-error-list-goto-error (&optional pos) "Go to the location of the error at POS in the error list. POS defaults to `point'." (interactive) (when-let* ((error (tabulated-list-get-id pos))) - (flycheck-jump-to-error error))) + (flycheck-jump-to-error error) + (run-hooks 'flycheck-error-list-after-jump-hook))) (defun flycheck-jump-to-error (error) "Go to the location of ERROR." @@ -5401,9 +5378,7 @@ POS defaults to `point'." ;; if necessary. (when other-file-error (with-current-buffer buffer - ;; `seq-contains-p' is only in seq >= 2.21 - (unless (with-no-warnings - (seq-contains flycheck-current-errors error-copy 'equal)) + (unless (seq-contains-p flycheck-current-errors error-copy #'equal) (when flycheck-mode (flycheck-buffer)))))))) @@ -5490,8 +5465,11 @@ nil, if there is no next error." Highlight all errors in the error list that are at point in the source buffer, and on the same line as point. Then recenter the error list to the highlighted error, unless PRESERVE-POS is -non-nil." - (when (get-buffer flycheck-error-list-buffer) +non-nil. + +Skip highlighting when the error list buffer is not visible, to +avoid slowing down editing when the error list is hidden." + (when (get-buffer-window flycheck-error-list-buffer) (with-current-buffer flycheck-error-list-buffer (let ((current-errors (when (buffer-live-p flycheck-error-list-source-buffer) @@ -5597,6 +5575,20 @@ If there are no errors, clears the error messages at point." 'flycheck-display-error-at-point))) +(defun flycheck-handle-focus-change () + "Handle frame focus changes for Flycheck error display. + +When the frame gains focus, schedule error display at point. +When the frame loses focus, cancel any pending error display." + (when flycheck-mode + (if (frame-focus-state) + (flycheck-display-error-at-point-soon) + (flycheck-cancel-error-display-error-at-point-timer)))) + +(add-function :after after-focus-change-function + #'flycheck-handle-focus-change) + + ;;; Functions to display errors (defconst flycheck-error-message-buffer "*Flycheck error messages*" "The name of the buffer to show long error messages in.") @@ -5698,10 +5690,10 @@ universal prefix arg, and only the id with normal prefix arg." ((pred not) #'flycheck-error-message) ((pred consp) #'flycheck-error-format-message-and-id) (_ #'flycheck-error-id)))) - (let ((messages (delq nil (seq-map (or formatter #'flycheck-error-message) + (let ((messages (delq nil (mapcar (or formatter #'flycheck-error-message) (flycheck-overlay-errors-at pos))))) (when messages - (seq-do #'kill-new (reverse messages)) + (seq-do #'kill-new (nreverse messages)) (message (string-join messages "\n"))))) (defun flycheck-explain-error-at-point () @@ -5952,7 +5944,7 @@ default `:verify' function of command checkers." ;; Pre-compile all errors patterns into strings, so that we don't need to do ;; that on each error parse - (let ((patterns (seq-map (lambda (p) + (let ((patterns (mapcar (lambda (p) (cons (flycheck-rx-to-string `(and ,@(cdr p)) 'no-group) (car p))) @@ -6030,7 +6022,7 @@ the error checking automatically." (let ((exit-code (apply #'flycheck-call-checker-process checker infile temp error args)) (output (with-current-buffer temp (buffer-string)))) - (if (eql 0 exit-code) output + (if (zerop exit-code) output (when error (error "Process %s failed with %S (%s)" checker exit-code output)))) @@ -6045,7 +6037,7 @@ the error checking automatically." Return a list of real arguments for the executable of CHECKER, substituted for the symbolic argument ARG. Single arguments, -e.g. if ARG is a literal strings, are wrapped in a list. +e.g. if ARG is a literal string, are wrapped in a list. ARG may be one of the following forms: @@ -6094,7 +6086,7 @@ STRING `null-device' first. symbol `null-device' - Return the value of variable `null-device', i.e the system + Return the value of variable `null-device', i.e. the system null device. Use this option to ignore the output of a syntax checker. @@ -6110,7 +6102,7 @@ symbol `null-device' PREPEND-FN is called with the OPTION and the located configuration file, and should return OPTION prepended - before the file, either a string or as list. If omitted, + before the file, either as a string or as a list. If omitted, PREPEND-FN defaults to `list'. `(option OPTION VARIABLE [PREPEND-FN [FILTER]])' @@ -6120,7 +6112,7 @@ symbol `null-device' PREPEND-FN is called with the OPTION and the value of VARIABLE, and should return OPTION prepended before the - file, either a string or as list. If omitted, PREPEND-FN + file, either as a string or as a list. If omitted, PREPEND-FN defaults to `list'. FILTER is an optional function to be applied to the value of @@ -6135,7 +6127,7 @@ symbol `null-device' PREPEND-FN is called with the OPTION and each item of the list as second argument, and should return OPTION prepended - before the item, either as string or as list. If omitted, + before the item, either as a string or as a list. If omitted, PREPEND-FN defaults to `list'. FILTER is an optional function to be applied to each item in @@ -6219,7 +6211,7 @@ are substituted within the body of cells!" value variable option-name)) (flycheck-prepend-with-option option-name value prepend-fn))) (`(option-list ,option-name ,variable ,prepend-fn ,filter) - (let ((value (delq nil (seq-map filter (symbol-value variable))))) + (let ((value (delq nil (mapcar filter (symbol-value variable))))) (unless (and (listp value) (seq-every-p #'stringp value)) (error "Value %S of %S for option %S is not a list of strings" value variable option-name)) @@ -6228,7 +6220,7 @@ are substituted within the body of cells!" (when (symbol-value variable) (list option-name))) (`(eval ,form) - (let ((result (eval form))) + (let ((result (eval form t))) (cond ((and (listp result) (seq-every-p #'stringp result)) result) ((stringp result) (list result)) @@ -6241,57 +6233,17 @@ are substituted within the body of cells!" Substitute each argument of CHECKER using `flycheck-substitute-argument'. This replaces any special symbols in the command." - (apply #'append - (seq-map (lambda (arg) (flycheck-substitute-argument arg checker)) - (flycheck-checker-arguments checker)))) - -(defun flycheck--process-send-buffer-contents-chunked (process) - "Send contents of current buffer to PROCESS in small batches. - -Send the entire buffer to the standard input of PROCESS in chunks -of 4096 characters. Chunking is done in Emacs Lisp, hence this -function is probably far less efficient than -`send-process-region'. Use only when required." - (let ((from (point-min))) - (while (< from (point-max)) - (let ((to (min (+ from 4096) (point-max)))) - (process-send-region process from to) - (setq from to))))) - -(defvar flycheck-chunked-process-input - ;; Chunk process output on Windows to work around - ;; https://github.com/flycheck/flycheck/issues/794 and - ;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=22344. The presence of - ;; `w32-pipe-buffer-size' denotes an Emacs version (> Emacs 25.1) where pipe - ;; writes on Windows are fixed. - ;; - ;; TODO: Remove option and chunking when dropping Emacs 24 support, see - ;; https://github.com/flycheck/flycheck/issues/856 - (and (eq system-type 'windows-nt) (not (boundp 'w32-pipe-buffer-size))) - "If non-nil send process input in small chunks. - -If this variable is non-nil `flycheck-process-send-buffer' sends -buffer contents in small chunks. - -Defaults to nil, except on Windows to work around Emacs bug -#22344.") + (seq-mapcat (lambda (arg) (flycheck-substitute-argument arg checker)) + (flycheck-checker-arguments checker))) (defun flycheck-process-send-buffer (process) "Send all contents of current buffer to PROCESS. Sends all contents of the current buffer to the standard input of -PROCESS, and terminates standard input with EOF. - -If `flycheck-chunked-process-input' is non-nil, send buffer -contents in chunks via -`flycheck--process-send-buffer-contents-chunked', which see. -Otherwise use `process-send-region' to send all contents at once -and rely on Emacs' own buffering and chunking." +PROCESS, and terminates standard input with EOF." (save-restriction (widen) - (if flycheck-chunked-process-input - (flycheck--process-send-buffer-contents-chunked process) - (process-send-region process (point-min) (point-max)))) + (process-send-region process (point-min) (point-max))) (process-send-eof process)) (defun flycheck--wrap-command (prog args) @@ -6314,12 +6266,15 @@ and rely on Emacs' own buffering and chunking." ;; more efficient and more robust than PTYs, which Emacs uses by ;; default, and since we don't need any job control features, we ;; can easily use pipes. - (process-connection-type nil)) - ;; We pass do not associate the process with any buffer, by + (process-connection-type nil) + ;; Force English messages from checker processes so that + ;; error patterns can match reliably. + (process-environment (cons "LC_ALL=C" process-environment))) + ;; We do not associate the process with any buffer, by ;; passing nil for the BUFFER argument of `start-process'. ;; Instead, we just remember the buffer being checked in a ;; process property (see below). This neatly avoids all - ;; side-effects implied by attached a process to a buffer, which + ;; side-effects implied by attaching a process to a buffer, which ;; may cause conflicts with other packages. ;; ;; See https://github.com/flycheck/flycheck/issues/298 for an @@ -6428,7 +6383,7 @@ CHECKER." :label "configuration file" :message (if path (format "Found at %S" path) "Not found") :face (if path 'success 'warning))))) - ,@(when (not (flycheck-temp-files-writable-p checker)) + ,@(unless (flycheck-temp-files-writable-p checker) (list (flycheck-verification-result-new :label "temp directory" :message (format "%s is not writable" @@ -6503,7 +6458,7 @@ output checker))) (funcall callback 'finished ;; Fix error file names, by substituting them backwards from the ;; temporaries. - (seq-map (lambda (e) (flycheck-fix-error-filename e files cwd)) + (mapcar (lambda (e) (flycheck-fix-error-filename e files cwd)) errors)))) @@ -6544,7 +6499,7 @@ reset the executable of CHECKER. Interactively, prompt for a syntax checker and an executable file, and set the executable of the selected syntax checker. With prefix arg, prompt for a syntax checker only, and reset the -executable of the select checker to the default. +executable of the selected checker to the default. Set the executable variable of CHECKER, that is, `flycheck-CHECKER-executable' to EXECUTABLE. Signal @@ -6602,7 +6557,7 @@ argument to `flycheck-define-checker'." If set to a string, locate the configuration file using the functions from `flycheck-locate-config-file-functions'. If the -file is found pass it to the syntax checker as configuration +file is found, pass it to the syntax checker as configuration file. If no configuration file is found, or if this variable is set to @@ -6640,7 +6595,7 @@ configuration file was found." (defun flycheck-locate-config-file-by-path (filepath _checker) "Locate a configuration file by a FILEPATH. -If FILEPATH is a contains a path separator, expand it against the +If FILEPATH contains a path separator, expand it against the default directory and return it if it points to an existing file. Otherwise return nil. @@ -6692,7 +6647,7 @@ appears in the help output." ;;;###autoload (defmacro flycheck-def-option-var (symbol init-value checkers docstring &rest custom-args) - "Define SYMBOL as option variable with INIT-VALUE for CHECKER. + "Define SYMBOL as option variable with INIT-VALUE for CHECKERS. SYMBOL is declared as customizable variable using `defcustom', to provide an option for the given syntax CHECKERS (a checker or a @@ -6726,13 +6681,6 @@ If VALUE is nil, return nil. Otherwise return VALUE converted to a string." (and value (number-to-string value))) -(defun flycheck-option-symbol (value) - "Convert a symbol option VALUE to string. - -If VALUE is nil return nil. Otherwise return VALUE converted to -a string." - (and value (symbol-name value))) - (defun flycheck-option-comma-separated-list (value &optional separator filter) "Convert VALUE into a list separated by SEPARATOR. @@ -6749,7 +6697,7 @@ SEPARATOR is ignored in this case." (let ((filter (or filter #'identity)) (separator (or separator ","))) (if (listp value) - (when-let (value (delq nil (seq-map filter value))) + (when-let (value (delq nil (mapcar filter value))) (string-join value separator)) (funcall filter value)))) @@ -6790,7 +6738,7 @@ Return a list representing PATTERN, suitable as element in Return an alist of all error patterns of CHECKER, suitable for use with `compilation-error-regexp-alist'." - (seq-map #'flycheck-checker-pattern-to-error-regexp + (mapcar #'flycheck-checker-pattern-to-error-regexp (flycheck-checker-get checker 'error-patterns))) (defun flycheck--substitute-shell-command-argument (arg checker) @@ -6807,10 +6755,9 @@ source-inplace, and source-original." Substitute each argument of CHECKER using `flycheck-substitute-shell-command-argument'." - (apply #'append - (seq-map (lambda (arg) - (flycheck--substitute-shell-command-argument arg checker)) - (flycheck-checker-arguments checker)))) + (seq-mapcat (lambda (arg) + (flycheck--substitute-shell-command-argument arg checker)) + (flycheck-checker-arguments checker))) (defun flycheck-checker-shell-command (checker) "Get a shell command for CHECKER. @@ -6936,8 +6883,7 @@ Try parsing with libxml first; if that fails, revert to XML (see URL `https://github.com/flycheck/flycheck/issues/1298'), or on Windows by a missing libxml DLL with a libxml-enabled Emacs \(see URL `https://github.com/flycheck/flycheck/issues/1330')." - ;; FIXME use `libxml-available-p' when it gets implemented. - (or (and (fboundp 'libxml-parse-xml-region) + (or (and (libxml-available-p) (libxml-parse-xml-region beg end)) (flycheck-parse-xml-region beg end))) @@ -6954,7 +6900,7 @@ Return the document tree parsed from XML in the form `(ROOT ATTRS BODY...)'. ROOT is a symbol identifying the name of the root element. ATTRS is an alist of the attributes of the root node. BODY is zero or more body elements, either as strings (in case of -text nodes) or as XML nodes, in the same for as the root node." +text nodes) or as XML nodes, in the same form as the root node." (with-temp-buffer (insert xml) (funcall flycheck-xml-parser (point-min) (point-max)))) @@ -6965,10 +6911,10 @@ text nodes) or as XML nodes, in the same for as the root node." Parse Checkstyle-like XML output. Use this error parser for checkers that have an option to output errors in this format. -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and +CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. -See URL `https://checkstyle.sourceforge.net/' for information +See URL `https://checkstyle.org/' for information about Checkstyle." (pcase (flycheck-parse-xml-string output) (`(checkstyle ,_ . ,file-nodes) @@ -7001,7 +6947,7 @@ about Checkstyle." Parse Cppcheck XML v2 output. -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and +CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. See URL `https://cppcheck.sourceforge.net/' for more information @@ -7043,7 +6989,7 @@ about Cppcheck." (defun flycheck-parse-phpmd (output checker buffer) "Parse phpmd errors from OUTPUT. -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and +CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. See URL `https://phpmd.org/' for more information about phpmd." @@ -7097,13 +7043,13 @@ about Reek." (nreverse errors))) (defun flycheck-parse-go-staticcheck (output checker buffer) - "Parse staticheck warnings from JSON OUTPUT. + "Parse staticcheck warnings from JSON OUTPUT. CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. See URL `https://staticcheck.io/docs/formatters' for more -information about staticheck." +information about staticcheck." (let ((errors nil)) (dolist (msg (flycheck-parse-json output)) (let-alist msg @@ -7125,32 +7071,6 @@ information about staticheck." errors))) (nreverse errors))) -(defun flycheck-parse-tslint (output checker buffer) - "Parse TSLint errors from JSON OUTPUT. - -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and -the BUFFER that was checked respectively. - -See URL `https://palantir.github.io/tslint/' for more information -about TSLint." - (seq-map (lambda (message) - (let-alist message - (flycheck-error-new-at - (+ 1 .startPosition.line) - (+ 1 .startPosition.character) - (pcase .ruleSeverity - ("ERROR" 'error) - ("WARNING" 'warning) - (_ 'warning)) - .failure - :id .ruleName - :checker checker - :buffer buffer - :filename .name - :end-line (+ 1 .endPosition.line) - :end-column (+ 1 .endPosition.character)))) - (car (flycheck-parse-json output)))) - (defun flycheck-parse-rust-collect-spans (span) "Return a list of spans contained in a SPAN object." (let ((spans)) @@ -7303,14 +7223,10 @@ https://github.com/rust-lang/rust/blob/master/src/librustc_errors/json.rs#L154" (nreverse errors))) (defconst flycheck--json-parser - (if (and (functionp 'json-parse-buffer) - ;; json-parse-buffer only supports keyword arguments in Emacs 27+ - (>= emacs-major-version 27)) - (lambda () - (json-parse-buffer - :object-type 'alist :array-type 'list - :null-object nil :false-object nil)) - #'json-read) + (lambda () + (json-parse-buffer + :object-type 'alist :array-type 'list + :null-object nil :false-object nil)) "Function to use to parse JSON strings.") (defun flycheck-parse-json (output) @@ -7322,9 +7238,7 @@ JSON object (starting with `{'). This function ignores the plain text lines, parses the JSON lines, and returns the parsed JSON lines in a list." - (let ((objects nil) - (json-array-type 'list) - (json-false nil)) + (let ((objects nil)) (with-temp-buffer (insert output) (goto-char (point-min)) @@ -7362,7 +7276,7 @@ JSON lines. This function ignores the plain text lines and parses only JSON lines. Each JSON line is expected to be a JSON object that represents a message from Cargo. The format of messages emitted by Cargo is described in cargo's -machine_message.rs at URL `https://git.io/vh24R'." +machine_message.rs at URL `https://github.com/rust-lang/cargo/blob/master/src/cargo/util/machine_message.rs'." (let ((errors)) (dolist (msg (flycheck-parse-json output)) (let-alist msg @@ -7390,14 +7304,14 @@ machine_message.rs at URL `https://git.io/vh24R'." CHECKER and BUFFER are passed along as well." (flycheck-parse-with-patterns - (and (fboundp 'ansi-color-filter-apply) (ansi-color-filter-apply output)) + (ansi-color-filter-apply output) checker buffer)) ;;; Error parsing with regular expressions (defun flycheck-get-regexp (patterns) "Create a single regular expression from PATTERNS." - (rx-to-string `(or ,@(seq-map (lambda (p) (list 'regexp (car p))) patterns)) + (rx-to-string `(or ,@(mapcar (lambda (p) (list 'regexp (car p))) patterns)) 'no-group)) (defun flycheck-tokenize-output-with-patterns (output patterns) @@ -7416,7 +7330,7 @@ Return a list of error tokens." (while (string-match regexp output last-match) (push (match-string 0 output) errors) (setq last-match (match-end 0))) - (reverse errors))) + (nreverse errors))) (defun flycheck-try-parse-error-with-pattern (err pattern checker) "Try to parse a single ERR with a PATTERN for CHECKER. @@ -7473,13 +7387,13 @@ tries to parse each error token with all patterns, in the order of declaration. Hence an error is never matched twice by two different patterns. The pattern declared first always wins. -_BUFFER is ignored. +BUFFER is the buffer being checked. Return a list of parsed errors and warnings (as `flycheck-error' objects)." (with-current-buffer buffer (let ((patterns (flycheck-checker-get checker 'error-patterns))) - (seq-map (lambda (err) + (mapcar (lambda (err) (flycheck-parse-error-with-patterns err patterns checker)) (flycheck-tokenize-output-with-patterns output patterns))))) @@ -7552,7 +7466,7 @@ standard, or nil, to use the default standard. When non-nil, pass the language standard via the `-std' option." :type '(choice (const :tag "Default standard" nil) (string :tag "Language standard")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "0.20")) (flycheck-def-option-var flycheck-gnat-warnings @@ -7600,24 +7514,6 @@ Uses the GNAT compiler from GCC. See URL ": " (message) line-end)) :modes ada-mode) -(flycheck-define-checker asciidoc - "A AsciiDoc syntax checker using the AsciiDoc compiler. - -See URL `https://www.methods.co.nz/asciidoc'." - :command ("asciidoc" "-o" null-device "-") - :standard-input t - :error-patterns - ((error line-start - "asciidoc: ERROR: : Line " line ": " (message) - line-end) - (warning line-start - "asciidoc: WARNING: : Line " line ": " (message) - line-end) - (info line-start - "asciidoc: DEPRECATED: : Line " line ": " (message) - line-end)) - :modes adoc-mode) - (flycheck-define-checker asciidoctor "An AsciiDoc syntax checker using the Asciidoctor compiler. @@ -7657,7 +7553,7 @@ See URL `https://asciidoctor.org'." "GNU awk's built-in --lint checker." :command ("gawk" ;; Avoid code execution. See https://github.com/w0rp/ale/pull/1411 - "--source" "'BEGIN{exit} END{exit 1}'" + "--source" "BEGIN{exit} END{exit 1}" "-f" source "--lint" "/dev/null") @@ -7786,7 +7682,7 @@ standard, or nil, to use the default standard. When non-nil, pass the language standard via the `-std' option." :type '(choice (const :tag "Default standard" nil) (string :tag "Language standard")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "0.15")) (make-variable-buffer-local 'flycheck-clang-language-standard) @@ -7849,7 +7745,7 @@ information about the standard library." (const "libc++") (const :tag "GNU libstdc++" "libstdc++") (string :tag "Library name")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "0.15")) (flycheck-def-option-var flycheck-clang-warnings '("all" "extra") c/c++-clang @@ -7977,7 +7873,7 @@ standard, or nil, to use the default standard. When non-nil, pass the language standard via the `-std' option." :type '(choice (const :tag "Default standard" nil) (string :tag "Language standard")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "0.20")) (make-variable-buffer-local 'flycheck-gcc-language-standard) @@ -8127,7 +8023,7 @@ use, or nil to pass nothing to cppcheck. When non-nil, pass the suppressions file via the `--suppressions-list=' option." :type '(choice (const :tag "Default" nil) (file :tag "Suppressions file")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (make-variable-buffer-local 'flycheck-cppcheck-suppressions-file) @@ -8211,37 +8107,8 @@ See URL `https://coffeescript.org/'." :error-patterns ((error line-start "[stdin]:" line ":" column ": error: " (message) line-end)) - :modes coffee-mode - :next-checkers ((warning . coffee-coffeelint))) - -(flycheck-def-config-file-var flycheck-coffeelintrc coffee-coffeelint - ".coffeelint.json") - -(flycheck-define-checker coffee-coffeelint - "A CoffeeScript style checker using coffeelint. - -See URL `https://www.coffeelint.org/'." - :command - ("coffeelint" - (config-file "--file" flycheck-coffeelintrc) - "--stdin" "--reporter" "checkstyle") - :standard-input t - :error-parser flycheck-parse-checkstyle - :error-filter (lambda (errors) - (flycheck-remove-error-file-names - "stdin" (flycheck-remove-error-ids - (flycheck-sanitize-errors errors)))) :modes coffee-mode) -(flycheck-define-checker css-csslint - "A CSS syntax and style checker using csslint. - -See URL `https://github.com/CSSLint/csslint'." - :command ("csslint" "--format=checkstyle-xml" source) - :error-parser flycheck-parse-checkstyle - :error-filter flycheck-dequalify-error-ids - :modes (css-mode css-ts-mode)) - (defconst flycheck-stylelint-args '("--formatter" "json") "Common arguments to stylelint invocations.") @@ -8263,12 +8130,13 @@ When non-nil, enable quiet mode, via `--quiet'." (defconst flycheck-stylelint-error-re (flycheck-rx-to-string - '(: line-start (id (one-or-more word)) ": " (message) line-end))) + '(: line-start (id (one-or-more word)) ": " (message) line-end)) + "Fallback regex for parsing stylelint errors from non-JSON output.") (defun flycheck-parse-stylelint (output checker buffer) "Parse stylelint errors from OUTPUT. -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and +CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. The CHECKER usually returns the errors as JSON. @@ -8294,16 +8162,18 @@ If the CHECKER throws an Error it returns an Error message with a stacktrace." (defun flycheck-parse-stylelint-json (output checker buffer) "Parse stylelint JSON errors from OUTPUT. -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and +CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. See URL `https://stylelint.io/developer-guide/formatters/' for information about the JSON format of stylelint." - (let ((json-object-type 'plist)) - - ;; stylelint returns a vector of result objects - ;; Since we only passed one file, the first element is enough - (let* ((stylelint-output (elt (json-read-from-string output) 0)) + ;; stylelint returns a vector of result objects + ;; Since we only passed one file, the first element is enough + (let* ((stylelint-output (elt (json-parse-string output + :object-type 'plist + :null-object nil + :false-object nil) + 0)) (filename (buffer-file-name buffer)) ;; Turn all deprecations into warnings @@ -8348,11 +8218,11 @@ about the JSON format of stylelint." (plist-get stylelint-output :warnings)))) ;; Return the combined errors (deprecations, invalid options, warnings) - (append deprecations invalid-options warnings)))) + (append deprecations invalid-options warnings))) (defun flycheck--stylelint-config-exists-p (checker) "Whether there is a valid stylelint CHECKER config for the current buffer." - (eql 0 (flycheck-call-checker-process + (zerop (flycheck-call-checker-process checker nil nil nil "--print-config" (or buffer-file-name "index.js")))) @@ -8375,7 +8245,7 @@ about the JSON format of stylelint." :message (if have-config "yes" "no config file found") :face (if have-config 'success '(bold error))) (flycheck-verification-result-new - :label "stylecheck version" + :label "stylelint version" :message (number-to-string (flycheck--stylelint-get-major-version checker)) :face 'success)))) @@ -8400,36 +8270,38 @@ See URL `https://stylelint.io/'." (and error-code `(url . ,(format url error-code)))))) (flycheck-def-option-var flycheck-cuda-language-standard nil cuda-nvcc - "Our CUDA Language Standard." + "The CUDA language standard to use in nvcc." :type '(choice (const :tag "Default standard" nil) (string :tag "Language standard")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (make-variable-buffer-local 'flycheck-cuda-language-standard) (flycheck-def-option-var flycheck-cuda-compiler-options '("-Wall" "-Wextra") cuda-nvcc - "Specify options directly to the compiler/preprocessor." + "Additional options to pass to the compiler via `-Xcompiler'." :type '(choice (const :tag "No additional compiler options" nil) - (repeat :tag "Addition compiler options" + (repeat :tag "Additional compiler options" (string :tag "Compiler option"))) :safe #'flycheck-string-list-p :package-version '(flycheck . "35")) (flycheck-def-option-var flycheck-cuda-gencodes nil cuda-nvcc - "Our real and virtual GPU architectures to pass to nvcc." - :type '(repeat (file :tag "GPU architecture")) + "GPU architectures to pass to nvcc via `-gencode'." + :type '(repeat (string :tag "GPU architecture")) :safe #'flycheck-string-list-p :package-version '(flycheck . "32")) (flycheck-def-option-var flycheck-cuda-includes nil cuda-nvcc - "Our include directories to pass to nvcc." - :type '(repeat (file :tag "Include file")) + "A list of include directories for nvcc." + :type '(repeat (directory :tag "Include directory")) :safe #'flycheck-string-list-p :package-version '(flycheck . "32")) (flycheck-def-option-var flycheck-cuda-definitions nil cuda-nvcc "Additional preprocessor definitions for nvcc. -A list of strings to pass to cuda, a la flycheck-clang" + +The value of this variable is a list of strings, where each +string is an additional definition to pass to nvcc via `-D'." :type '(repeat (string :tag "Definitions")) :safe #'flycheck-string-list-p :package-version '(flycheck . "32")) @@ -8504,7 +8376,7 @@ The value of this variable is a string that denotes a path for the schema file of Common Workflow Language." :type '(choice (const :tag "None" nil) (file :tag "Schema file")) - :safe #'flycheck-string-or-nil-p) + :safe #'string-or-null-p) (flycheck-define-checker cwl "A CWL syntax checker using Schema Salad validator. @@ -8579,7 +8451,7 @@ Requires DMD 2.066 or newer. See URL `https://dlang.org/'." :modes d-mode) (flycheck-define-checker dockerfile-hadolint - "A Dockerfile syntax checker using the hadolint. + "A Dockerfile syntax checker using hadolint. See URL `https://github.com/hadolint/hadolint/'." :command ("hadolint" "--no-color" "-") @@ -8634,7 +8506,7 @@ See `https://credo-ci.org/'." (warning line-start (file-name) ":" line (optional ":" column) ": " (or "D" "W") ": " (message) line-end)) - :modes elixir-mode) + :modes (elixir-mode elixir-ts-mode)) (defconst flycheck-this-emacs-executable (concat invocation-directory invocation-name) @@ -8673,6 +8545,10 @@ See `https://credo-ci.org/'." (defconst flycheck-emacs-lisp-check-form (flycheck-prepare-emacs-lisp-form + ;; Mitigate CVE-2024-53920: prevent arbitrary code execution via + ;; file-local eval: directives during byte-compilation. + (setq enable-local-eval nil + enable-local-variables :safe) ;; Keep track of the generated bytecode files, to delete them after byte ;; compilation. (require 'bytecomp) @@ -8823,7 +8699,7 @@ See Info Node `(elisp)Byte Compilation'." (eval (let ((path (pcase flycheck-emacs-lisp-load-path (`inherit load-path) - (p (seq-map #'expand-file-name p))))) + (p (mapcar #'expand-file-name p))))) (flycheck-prepend-with-option "--directory" path))) (option "--eval" flycheck-emacs-lisp-package-user-dir nil flycheck-option-emacs-lisp-package-user-dir) @@ -8841,6 +8717,16 @@ See Info Node `(elisp)Byte Compilation'." (message (zero-or-more not-newline) (zero-or-more "\n " (zero-or-more not-newline))) line-end) + ;; Parse errors subsequent to byte-compilation (e.g., unbalanced + ;; parentheses) may lack line/column info. + (error line-start (file-name) ":" + (zero-or-more whitespace) "Error:" (zero-or-more whitespace) + (message (or "End of file during parsing" + (seq "Invalid read syntax:" + (zero-or-more not-newline)))) + (optional "," (zero-or-more whitespace) line + "," (zero-or-more whitespace) column) + line-end) (warning line-start (file-name) ":" line ":" column ":" (zero-or-more whitespace) "Warning:" (zero-or-more whitespace) (message (zero-or-more not-newline) @@ -8851,7 +8737,7 @@ See Info Node `(elisp)Byte Compilation'." (message (zero-or-more " " (zero-or-more not-newline)) (zero-or-more "\n " (zero-or-more not-newline))) line-end) - ;; The following is for Emacs 24 ‘check-declare-file’, which uses a + ;; The following is for Emacs 24 'check-declare-file', which uses a ;; less informative format. (warning line-start "Warning (check-declare): " (file-name) " said " (message (zero-or-more not-newline)) @@ -8888,7 +8774,7 @@ See Info Node `(elisp)Byte Compilation'." (insert-file-contents source 'visit) (setq buffer-file-name source) ;; And change back to the process default directory to make file-name - ;; back-substutition work + ;; back-substitution work (setq default-directory process-default-directory) (with-demoted-errors "Error in checkdoc: %S" ;; Checkdoc needs the Emacs Lisp syntax table and comment syntax to @@ -8913,7 +8799,10 @@ See Info Node `(elisp)Byte Compilation'." checkdoc-max-keyref-before-warn sentence-end-double-space ,@(and (>= emacs-major-version 28) - '(checkdoc-column-zero-backslash-before-paren))) + '(checkdoc-column-zero-backslash-before-paren)) + ,@(and (>= emacs-major-version 31) + '(checkdoc-allow-quoting-nil-and-t + checkdoc-arguments-missing-flag))) "Variables inherited by the checkdoc subprocess.") (defun flycheck-emacs-lisp-checkdoc-variables-form () @@ -8921,9 +8810,14 @@ See Info Node `(elisp)Byte Compilation'." Variables are taken from `flycheck-emacs-lisp-checkdoc-variables'." `(progn - ,@(seq-map (lambda (opt) `(setq-default ,opt ',(symbol-value opt))) + ,@(mapcar (lambda (opt) `(setq-default ,opt ',(symbol-value opt))) (seq-filter #'boundp flycheck-emacs-lisp-checkdoc-variables)))) +(defun flycheck-org-lint-available-p () + "Check if org-lint is available." + (and (fboundp 'org-lint) + (require 'org nil 'no-error))) + (flycheck-define-checker emacs-lisp-checkdoc "An Emacs Lisp style checker using CheckDoc. @@ -8942,6 +8836,43 @@ The checker runs `checkdoc-current-buffer'." (setf (car (flycheck-checker-get checker 'command)) flycheck-this-emacs-executable)) +(flycheck-define-generic-checker 'org-lint + "An Org mode syntax checker using `org-lint'. + +The checker runs `org-lint' in the current Emacs process, so it +has access to all installed packages and user configuration." + :start (lambda (checker callback) + (condition-case err + (let ((errors + (delq nil + (mapcar + (lambda (e) + (pcase e + (`(,_n [,line ,_trust ,desc ,_checker]) + (flycheck-error-new-at + line nil 'info desc + :checker checker)) + (_ + (flycheck-error-new-at + 1 nil 'warning + (format "Unexpected org-lint format: %S" e) + :checker checker)))) + (org-lint))))) + (funcall callback 'finished errors)) + (error (funcall callback 'errored + (error-message-string err))))) + :modes '(org-mode) + :enabled #'flycheck-org-lint-available-p + :verify (lambda (_) + (let ((org-version (when (require 'org nil 'no-error) + (org-version)))) + (list (flycheck-verification-result-new + :label "Org-lint available" + :message (if (fboundp 'org-lint) + (format "yes (Org %s)" org-version) + "no") + :face (if (fboundp 'org-lint) 'success 'warning)))))) + (defun flycheck-ember-template--check-for-config (&rest _ignored) "Check the required config file is available up the file system." (and buffer-file-name @@ -9019,7 +8950,8 @@ See URL `https://www.erlang.org/'." (error line-start (file-name) ":" line ":" (optional column ":") " " (message) line-end)) :modes erlang-mode - :enabled (lambda () (string-suffix-p ".erl" (buffer-file-name)))) + :enabled (lambda () (and buffer-file-name + (string-suffix-p ".erl" (buffer-file-name))))) (defun flycheck--contains-rebar-config (dir-name) "Return DIR-NAME if rebar config file exists in DIR-NAME, nil otherwise." @@ -9053,7 +8985,8 @@ Return the absolute path to the directory" (defun flycheck-rebar3-project-root (&optional _checker) "Return directory where rebar.config is located." - (flycheck--locate-rebar3-project-root buffer-file-name)) + (when buffer-file-name + (flycheck--locate-rebar3-project-root buffer-file-name))) (flycheck-def-option-var flycheck-erlang-rebar3-profile nil erlang-rebar3 "The rebar3 profile to use. @@ -9063,7 +8996,7 @@ when the file is located in test directory, otherwise \"default\" will be used as profile." :type '(choice (const :tag "Automatic" nil) (string :tag "Profile")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (defun flycheck-erlang-rebar3-get-profile () @@ -9073,13 +9006,11 @@ Use flycheck-erlang-rebar3-profile if set, otherwise use test or eqc profile if directory name is \"test\" or \"eqc\", or else \"default\"." (or flycheck-erlang-rebar3-profile - (with-no-warnings - ;; `seq-contains-p' is only in seq >= 2.21 - (seq-contains '("test" "eqc") + (seq-contains-p '("test" "eqc") (and buffer-file-name (file-name-base (directory-file-name - (file-name-directory buffer-file-name)))))) + (file-name-directory buffer-file-name))))) "default")) (flycheck-define-checker erlang-rebar3 @@ -9096,56 +9027,6 @@ directory name is \"test\" or \"eqc\", or else \"default\"." :predicate flycheck-buffer-saved-p :working-directory flycheck-rebar3-project-root) -(flycheck-define-checker eruby-erubis - "An eRuby syntax checker using the `erubis' command. - -See URL `https://www.kuwata-lab.com/erubis/'." - :command ("erubis" "-z" source) - :error-patterns - ((error line-start (file-name) ":" line ": " (message) line-end)) - :modes (html-erb-mode rhtml-mode) - :next-checkers ((warning . eruby-ruumba))) - -(flycheck-def-config-file-var flycheck-ruumbarc eruby-ruumba ".ruumba.yml") - -(flycheck-def-option-var flycheck-ruumba-lint-only nil eruby-ruumba - "Whether to only report code issues in Ruumba. - -When non-nil, only report code issues in Ruumba, via `--lint'. -Otherwise report style issues as well." - :safe #'booleanp - :type 'boolean - :package-version '(flycheck . "32")) - -(flycheck-define-checker eruby-ruumba - "An eRuby syntax and style checker using the Ruumba tool. - -You need at least Ruumba 0.1.7 for this syntax checker. - -See URL `https://github.com/ericqweinstein/ruumba'." - :command ("ruumba" - "--display-cop-names" - "--force-exclusion" - "--format" "emacs" - "--cache" "false" - (config-file "--config" flycheck-ruumbarc) - (option-flag "--lint" flycheck-ruumba-lint-only) - ;; Ruumba takes the original file name as argument when reading - ;; from standard input - "--stdin" source-original) - :standard-input t - :working-directory flycheck-ruby--find-project-root - :error-patterns - ((info line-start (file-name) ":" line ":" column ": C: " - (optional (id (one-or-more (not (any ":")))) ": ") (message) line-end) - (warning line-start (file-name) ":" line ":" column ": W: " - (optional (id (one-or-more (not (any ":")))) ": ") (message) - line-end) - (error line-start (file-name) ":" line ":" column ": " (or "E" "F") ": " - (optional (id (one-or-more (not (any ":")))) ": ") (message) - line-end)) - :modes (html-erb-mode rhtml-mode)) - (flycheck-def-args-var flycheck-gfortran-args fortran-gfortran :package-version '(flycheck . "0.22")) @@ -9219,7 +9100,7 @@ about warnings" :package-version '(flycheck . "0.20")) (flycheck-define-checker fortran-gfortran - "An Fortran syntax checker using GCC. + "A Fortran syntax checker using GCC. Uses GCC's Fortran compiler gfortran. See URL `https://gcc.gnu.org/onlinedocs/gfortran/'." @@ -9257,14 +9138,15 @@ See URL https://github.com/rhysd/actionlint/." :error-patterns ((error line-start (file-name) ":" line ":" column ": " (message) line-end)) :modes (yaml-mode yaml-ts-mode) :predicate (lambda () - (string-match-p - (rx (or ".github/workflows" ".github\\workflows")) - (buffer-file-name)))) + (and buffer-file-name + (string-match-p + (rx (or ".github/workflows" ".github\\workflows")) + (buffer-file-name))))) (flycheck-define-checker go-gofmt "A Go syntax and style checker using the gofmt utility. -See URL `https://golang.org/cmd/gofmt/'." +See URL `https://go.dev/cmd/gofmt/'." :command ("gofmt") :standard-input t :error-patterns @@ -9278,32 +9160,12 @@ See URL `https://golang.org/cmd/gofmt/'." (warning . go-unconvert) (warning . go-staticcheck))) -(flycheck-def-option-var flycheck-go-vet-print-functions nil go-vet - "A list of print-like functions for `go vet'. - -Go vet will check these functions for format string problems and -issues, such as a mismatch between the number of formats used, -and the number of arguments given. - -Each entry is in the form Name:N where N is the zero-based -argument position of the first argument involved in the print: -either the format or the first print argument for non-formatted -prints. For example, if you have Warn and Warnf functions that -take an io.Writer as their first argument, like Fprintf, --printfuncs=Warn:1,Warnf:1 " - :type '(repeat :tag "print-like functions" - (string :tag "function")) - :safe #'flycheck-string-list-p) - (flycheck-define-checker go-vet "A Go syntax checker using the `go vet' command. -See URL `https://golang.org/cmd/go/' and URL -`https://golang.org/cmd/vet/'." - :command ("go" "vet" - (option "-printf.funcs=" flycheck-go-vet-print-functions concat - flycheck-option-comma-separated-list) - (source ".go")) +See URL `https://go.dev/cmd/go/' and URL +`https://pkg.go.dev/cmd/vet/'." + :command ("go" "vet" (source ".go")) :error-patterns ((warning line-start (file-name) ":" line ": " (message) line-end)) :modes (go-mode go-ts-mode) @@ -9323,15 +9185,6 @@ See URL `https://golang.org/cmd/go/' and URL :message (if have-vet "present" "missing") :face (if have-vet 'success '(bold error))))))) -(flycheck-def-option-var flycheck-go-build-install-deps nil (go-build go-test) - "Whether to install dependencies in `go build' and `go test'. - -If non-nil automatically install dependencies with `go build' -while syntax checking." - :type 'boolean - :safe #'booleanp - :package-version '(flycheck . "0.25")) - (flycheck-def-option-var flycheck-go-build-tags nil (go-build go-test go-errcheck go-staticcheck) "A list of tags for `go build'. @@ -9350,17 +9203,17 @@ See `https://staticcheck.io/docs/#targeting-go-versions' for details." :type '(choice (const :tag "Unspecified" nil) (string :tag "Version")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "0.32")) (flycheck-define-checker go-build "A Go syntax and type checker using the `go build' command. -Requires Go 1.6 or newer. See URL `https://golang.org/cmd/go'." +See URL `https://go.dev/cmd/go/'." :command ("go" "build" - (option-flag "-i" flycheck-go-build-install-deps) - ;; multiple tags are listed as "dev debug ..." - (option-list "-tags=" flycheck-go-build-tags concat) + ;; multiple tags are comma-separated: "dev,debug" + (option "-tags=" flycheck-go-build-tags concat + flycheck-option-comma-separated-list) "-o" null-device) :error-patterns ((error line-start (file-name) ":" line ":" @@ -9396,10 +9249,10 @@ Requires Go 1.6 or newer. See URL `https://golang.org/cmd/go'." (flycheck-define-checker go-test "A Go syntax and type checker using the `go test' command. -Requires Go 1.6 or newer. See URL `https://golang.org/cmd/go'." +See URL `https://go.dev/cmd/go/'." :command ("go" "test" - (option-flag "-i" flycheck-go-build-install-deps) - (option-list "-tags=" flycheck-go-build-tags concat) + (option "-tags=" flycheck-go-build-tags concat + flycheck-option-comma-separated-list) "-c" "-o" null-device) :error-patterns ((error line-start (file-name) ":" line ":" @@ -9423,7 +9276,8 @@ Requires errcheck newer than commit 8515d34 (Aug 28th, 2015). See URL `https://github.com/kisielk/errcheck'." :command ("errcheck" "-abspath" - (option-list "-tags=" flycheck-go-build-tags concat) + (option "-tags=" flycheck-go-build-tags concat + flycheck-option-comma-separated-list) ".") :error-patterns ((warning line-start @@ -9459,11 +9313,12 @@ See URL `https://github.com/mdempsky/unconvert'." the `staticcheck' command. `staticcheck' is explicitly fully compatible with \"the last two -versions of go\". `staticheck' can target earlier versions (with +versions of go\". `staticcheck' can target earlier versions (with limited features) if `flycheck-go-version' is set. See URL `https://staticcheck.io/'." :command ("staticcheck" "-f" "json" - (option-list "-tags" flycheck-go-build-tags concat) + (option "-tags" flycheck-go-build-tags nil + flycheck-option-comma-separated-list) (option "-go" flycheck-go-version)) :error-parser flycheck-parse-go-staticcheck @@ -9560,7 +9415,7 @@ resolved against the checker's working directory. When non-nil, stack will get overridden value via `--stack-yaml'." :type '(choice (const :tag "Unspecified" nil) (file :tag "Project file")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (flycheck-def-option-var flycheck-ghc-no-user-package-database nil haskell-ghc @@ -9697,7 +9552,7 @@ See URL `https://github.com/commercialhaskell/stack'." :error-filter (lambda (errors) (flycheck-sanitize-errors (flycheck-dedent-error-messages errors))) - :modes (haskell-mode haskell-literate-mode) + :modes (haskell-mode haskell-literate-mode haskell-ts-mode) :next-checkers ((warning . haskell-hlint)) :working-directory (lambda (_) (flycheck-haskell--find-stack-default-directory)) @@ -9757,7 +9612,7 @@ See URL `https://www.haskell.org/ghc/'." :error-filter (lambda (errors) (flycheck-sanitize-errors (flycheck-dedent-error-messages errors))) - :modes (haskell-mode haskell-literate-mode) + :modes (haskell-mode haskell-literate-mode haskell-ts-mode) :next-checkers ((warning . haskell-hlint)) :working-directory flycheck-haskell--ghc-find-default-directory) @@ -9832,12 +9687,12 @@ See URL `https://github.com/ndmitchell/hlint'." ": Error: " (message (one-or-more (and (one-or-more (not (any ?\n))) ?\n))) line-end)) - :modes (haskell-mode haskell-literate-mode)) + :modes (haskell-mode haskell-literate-mode haskell-ts-mode)) (flycheck-def-config-file-var flycheck-tidyrc html-tidy ".tidyrc") (flycheck-define-checker html-tidy - "A HTML syntax and style checker using Tidy. + "An HTML syntax and style checker using Tidy. See URL `https://github.com/htacg/tidy-html5'." :command ("tidy" (config-file "-config" flycheck-tidyrc) @@ -9853,46 +9708,7 @@ See URL `https://github.com/htacg/tidy-html5'." "line " line " column " column " - Warning: " (message) line-end)) - :modes (html-mode mhtml-mode nxhtml-mode)) - -(flycheck-def-config-file-var flycheck-jshintrc javascript-jshint ".jshintrc") - -(flycheck-def-option-var flycheck-jshint-extract-javascript nil - javascript-jshint - "Whether jshint should extract Javascript from HTML. - -If nil no extract rule is given to jshint. If `auto' only -extract Javascript if a HTML file is detected. If `always' or -`never' extract Javascript always or never respectively. - -Refer to the jshint manual at the URL -`https://jshint.com/docs/cli/#flags' for more information." - :type - '(choice (const :tag "No extraction rule" nil) - (const :tag "Try to extract Javascript when detecting HTML files" - auto) - (const :tag "Always try to extract Javascript" always) - (const :tag "Never try to extract Javascript" never)) - :safe #'symbolp - :package-version '(flycheck . "26")) - -(flycheck-define-checker javascript-jshint - "A Javascript syntax and style checker using jshint. - -See URL `https://www.jshint.com'." - :command ("jshint" "--reporter=checkstyle" - "--filename" source-original - (config-file "--config" flycheck-jshintrc) - (option "--extract=" flycheck-jshint-extract-javascript - concat flycheck-option-symbol) - "-") - :standard-input t - :error-parser flycheck-parse-checkstyle - :error-filter - (lambda (errors) - (flycheck-remove-error-file-names - "stdin" (flycheck-dequalify-error-ids errors))) - :modes (js-mode js2-mode js3-mode rjsx-mode js-ts-mode)) + :modes (html-mode mhtml-mode nxhtml-mode html-ts-mode)) (flycheck-def-args-var flycheck-eslint-args javascript-eslint :package-version '(flycheck . "32")) @@ -9912,7 +9728,7 @@ for more information about the custom directories." (defun flycheck-eslint-config-exists-p () "Whether there is a valid eslint config for the current buffer." - (eql 0 (flycheck-call-checker-process + (zerop (flycheck-call-checker-process 'javascript-eslint nil nil nil "--print-config" (or buffer-file-name "index.js")))) @@ -9989,10 +9805,24 @@ See URL `https://eslint.org/'." (url "https://eslint.org/docs/rules/%s")) (and error-code ;; skip non-builtin rules - (not ;; `seq-contains-p' is only in seq >= 2.21 - (with-no-warnings (seq-contains error-code ?/))) + (not (seq-contains-p error-code ?/)) `(url . ,(format url error-code)))))) +(flycheck-define-checker javascript-oxlint + "A JavaScript and TypeScript linter using oxlint. + +See URL `https://oxc.rs/'." + :command ("oxlint" + "--format" "checkstyle" + source-inplace) + :error-parser flycheck-parse-checkstyle + :error-filter + (lambda (errors) + (flycheck-sanitize-errors + (flycheck-dequalify-error-ids errors))) + :modes (js-mode js-jsx-mode js2-mode js2-jsx-mode js3-mode rjsx-mode + typescript-mode js-ts-mode typescript-ts-mode tsx-ts-mode)) + (flycheck-define-checker javascript-standard "A Javascript code and style checker for the (Semi-)Standard Style. @@ -10009,24 +9839,6 @@ See URL `https://github.com/standard/standard' and URL :modes (js-mode js-jsx-mode js2-mode js2-jsx-mode js3-mode rjsx-mode js-ts-mode)) -(flycheck-define-checker json-jsonlint - "A JSON syntax and style checker using jsonlint. - -See URL `https://github.com/zaach/jsonlint'." - ;; We can't use standard input for jsonlint, because it doesn't output errors - ;; anymore when using -c -q with standard input :/ - :command ("jsonlint" "-c" "-q" source) - :error-patterns - ((error line-start - (file-name) - ": line " line - ", col " column ", " - (message) line-end)) - :error-filter - (lambda (errors) - (flycheck-sanitize-errors (flycheck-increment-error-columns errors))) - :modes (json-mode js-json-mode json-ts-mode)) - (flycheck-define-checker json-python-json "A JSON syntax checker using Python json.tool module. @@ -10062,9 +9874,10 @@ See URL `https://stedolan.github.io/jq/'." :modes (json-mode js-json-mode json-ts-mode)) (flycheck-def-option-var flycheck-jsonnet-include-paths nil jsonnet - "a list of include paths to specify to the jsonnet binary, via -J . + "A list of include paths for the jsonnet binary. -For example (\"./lib\") ." +The value of this variable is a list of strings, where each +string is a directory to add to the include path via `-J'." :type '(repeat (directory :tag "Include directory")) :safe #'flycheck-string-list-p :package-version '(flycheck . "35.0")) @@ -10208,7 +10021,7 @@ See URL `https://www.lua.org/'." :modes (lua-mode lua-ts-mode)) (flycheck-define-checker opam - "A Opam syntax and style checker using opam lint. + "An Opam syntax and style checker using opam lint. See URL `https://opam.ocaml.org/doc/man/opam-lint.html'." :command ("opam" "lint" "-") @@ -10237,7 +10050,7 @@ See URL `https://opam.ocaml.org/doc/man/opam-lint.html'." (lambda (errors) (flycheck-increment-error-columns (flycheck-fill-empty-line-numbers errors))) - :modes tuareg-opam-mode) + :modes (tuareg-opam-mode neocaml-opam-mode)) (flycheck-def-option-var flycheck-perl-include-path nil perl "A list of include directories for Perl. @@ -10254,7 +10067,7 @@ Relative paths are relative to the file being checked." The value of this variable is a list of strings, where each string is a module to `use' in Perl." - :type '(repeat :tag "Module") + :type '(repeat (string :tag "Module")) :safe #'flycheck-string-list-p :package-version '(flycheck . "32")) @@ -10290,7 +10103,7 @@ The value of this variable is passed as the `--theme' option to details." :type '(choice (const :tag "None" nil) (string :tag "Theme expression")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32-csv")) (flycheck-def-config-file-var flycheck-perlcriticrc perl-perlcritic @@ -10332,7 +10145,7 @@ See URL `https://metacpan.org/pod/Perl::Critic'." (defun flycheck-perl-perlimports-parse-errors (output checker buffer) "Parse perlimports json output errors from OUTPUT. -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and +CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. See URL `https://metacpan.org/dist/App-perlimports/view/script/perlimports' @@ -10413,11 +10226,11 @@ See URL `https://phpmd.org/'." When nil, use the default standard from the global PHP CodeSniffer configuration. When set to a string, pass the string -to PHP CodeSniffer which will interpret it as name as a standard, +to PHP CodeSniffer which will interpret it as the name of a standard, or as path to a standard specification." :type '(choice (const :tag "Default standard" nil) (string :tag "Standard name or file")) - :safe #'flycheck-string-or-nil-p) + :safe #'string-or-null-p) (flycheck-define-checker php-phpcs "A PHP style checker using PHP Code Sniffer. @@ -10456,24 +10269,33 @@ See URL `https://pear.php.net/package/PHP_CodeSniffer/'." ;; buffer is empty, see https://github.com/flycheck/flycheck/issues/907 :predicate flycheck-buffer-nonempty-p) +(flycheck-def-option-var flycheck-phpcs-changed-git-base "trunk" + php-phpcs-changed + "The git base branch for PHPCS-Changed. + +The value of this variable is a string specifying the git branch +to compare against (e.g. \"main\", \"master\", \"trunk\")." + :type '(string :tag "Branch name") + :safe #'stringp) + (flycheck-define-checker php-phpcs-changed "A PHP style checker using PHPCS-Changed. - Needs PHP Code Sniffer 2.6 or newer. - See `https://github.com/sirbrillig/phpcs-changed'." + +Needs PHP Code Sniffer 2.6 or newer. +See URL `https://github.com/sirbrillig/phpcs-changed'." :command ("phpcs-changed" "--git" - "--git-base trunk" + "--git-base" (eval flycheck-phpcs-changed-git-base) "--git-unstaged" (option "--standard=" flycheck-phpcs-standard concat) - (eval (buffer-file-name)) - ) + (eval (buffer-file-name))) :standard-input t :error-parser flycheck-parse-checkstyle :error-filter (lambda (errors) (flycheck-sanitize-errors (flycheck-remove-error-file-names "STDIN" errors))) - :modes (php-mode php+-mode) + :modes (php-mode php-ts-mode php+-mode) ;; phpcs seems to choke on empty standard input, hence skip phpcs if the ;; buffer is empty, see https://github.com/flycheck/flycheck/issues/907 :predicate flycheck-buffer-nonempty-p) @@ -10498,7 +10320,7 @@ See https://github.com/processing/processing/wiki/Command-Line" (defun flycheck-proselint-parse-errors (output checker buffer) "Parse proselint json output errors from OUTPUT. -CHECKER and BUFFER denoted the CHECKER that returned OUTPUT and +CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively. See URL `https://proselint.com/' for more information about proselint." @@ -10537,22 +10359,35 @@ See URL `https://proselint.com/' for more information about proselint." (let-alist (car response) .result..diagnostics))))) +(defvar flycheck--proselint-use-old-args 'unknown + "Cache for proselint version detection. +Value is t for old (<= 0.14.0), nil for new (>= 0.16.0), +or `unknown' if not yet detected.") + +(defvar flycheck-proselint-executable) + +(defun flycheck--proselint-args () + "Return command arguments for proselint, detecting the version once." + (when (eq flycheck--proselint-use-old-args 'unknown) + (setq flycheck--proselint-use-old-args + (zerop (call-process + (or flycheck-proselint-executable "proselint") + nil nil nil "--version")))) + (if flycheck--proselint-use-old-args + ;; Proselint versions <= 0.14.0: + (list "--json" "-") + ;; Proselint versions >= 0.16.0 + (list "check" "--output-format=json"))) + (flycheck-define-checker proselint "Flycheck checker using Proselint. See URL `https://proselint.com/'." :command ("proselint" - (eval - (if (= (call-process (or flycheck-proselint-executable "proselint") - nil nil nil "--version") - 0) - ;; Proselint versions <= 0.14.0: - (list "--json" "-") - ;; Proselint versions >= 0.16.0 - (list "check" "--output-format=json")))) + (eval (flycheck--proselint-args))) :standard-input t :error-parser flycheck-proselint-parse-errors - :modes (text-mode markdown-mode gfm-mode message-mode org-mode)) + :modes (text-mode markdown-mode gfm-mode message-mode org-mode rst-mode)) (flycheck-def-option-var flycheck-protoc-import-path nil protobuf-protoc "A list of directories to resolve import directives. @@ -10563,6 +10398,7 @@ are relative to the file being checked." :type '(repeat (directory :tag "Import directory")) :safe #'flycheck-string-list-p :package-version '(flycheck . "32")) +(make-variable-buffer-local 'flycheck-protoc-import-path) (flycheck-define-checker protobuf-protoc "A protobuf syntax checker using the protoc compiler. @@ -10589,22 +10425,6 @@ See URL `https://developers.google.com/protocol-buffers/'." :modes protobuf-mode :predicate (lambda () (buffer-file-name))) -(defun flycheck-prototool-project-root (&optional _checker) - "Return the nearest directory holding the prototool.yaml configuration." - (and buffer-file-name - (locate-dominating-file buffer-file-name "prototool.yaml"))) - -(flycheck-define-checker protobuf-prototool - "A protobuf syntax checker using prototool. - -See URL `https://github.com/uber/prototool'." - :command ("prototool" "lint" source-original) - :error-patterns - ((warning line-start (file-name) ":" line ":" column ":" (message) line-end)) - :modes protobuf-mode - :enabled flycheck-prototool-project-root - :predicate flycheck-buffer-saved-p) - (flycheck-define-checker pug "A Pug syntax checker using the pug compiler. @@ -10661,7 +10481,11 @@ See URL `https://puppet.com/'." (minimal-match (zero-or-more not-newline)) ": Could not parse for environment " (one-or-more word) ": " (message (minimal-match (zero-or-more anything))) - " at " (file-name "/" (zero-or-more not-newline)) ":" line line-end)) + " at " (file-name "/" (zero-or-more not-newline)) ":" line line-end) + ;; Errors without line/column (e.g., "end of file" or "end of input") + (error line-start "Error: Could not parse for environment " + (one-or-more (in "a-z" "0-9" "_")) ":" + (message) line-end)) :modes (puppet-mode puppet-ts-mode) :next-checkers ((warning . puppet-lint))) @@ -10690,7 +10514,7 @@ and their names." See URL `https://puppet-lint.com/'." ;; We must check the original file, because Puppetlint is quite picky on the - ;; names of files and there place in the directory structure, to comply with + ;; names of files and their place in the directory structure, to comply with ;; Puppet's autoload directory layout. For instance, a class foo::bar is ;; required to be in a file foo/bar.pp. Any other place, such as a Flycheck ;; temporary file will cause an error. @@ -10718,7 +10542,7 @@ CHECKER's executable is assumed to be a Python REPL." (string-trim output))) (defun flycheck-python-get-path (checker) - "Compute the current Python path (CHECKER is a Python REPL) ." + "Compute the current Python path (CHECKER is a Python REPL)." (flycheck-python-run-snippet checker "import sys; print(sys.path[1:])")) (defun flycheck-python-find-module (checker module) @@ -10731,7 +10555,7 @@ CHECKER's executable is assumed to be a Python REPL." "Determine whether CHECKER needs to be invoked through Python. Previous versions of Flycheck called pylint and flake8 directly, -while new version call them through `python -c'. This check +while new versions call them through `python -c'. This check ensures that we don't break existing code; it also allows people who use virtualenvs to run globally-installed checkers." (not (string-match-p (rx (or "pylint" "pylint3" "flake8") @@ -10743,7 +10567,7 @@ who use virtualenvs to run globally-installed checkers." "Verify that a Python MODULE is available. Return nil if CHECKER's executable is not a Python REPL. This -function's is suitable for a checker's :verify." +function is suitable for a checker's :verify." (when (flycheck-python-needs-module-p checker) (let ((mod-path (flycheck-python-find-module checker module))) (list (flycheck-verification-result-new @@ -10768,7 +10592,7 @@ because it adds the current directory to Python's path)." "Files used to find where to run Python checkers from. Currently used for pylint, flake8, and pyright. -The presence of one in these files indicates the root of the +The presence of one of these files indicates the root of the current project; `.pylintrc' is not part of the list because it is commonly found in ~/." :group 'flycheck @@ -10859,17 +10683,13 @@ of 79 characters if there is no configuration with this setting." Update the error level of ERR according to `flycheck-flake8-error-level-alist'." - (pcase-dolist (`(,pattern . ,level) flycheck-flake8-error-level-alist) - (when (string-match-p pattern (flycheck-error-id err)) - (setf (flycheck-error-level err) level))) + (when-let* ((entry (seq-find + (lambda (e) + (string-match-p (car e) (flycheck-error-id err))) + flycheck-flake8-error-level-alist))) + (setf (flycheck-error-level err) (cdr entry))) err) -(defun flycheck-flake8--find-project-root (_checker) - "Find setup.cfg in a parent directory of the current buffer." - ;; This is a workaround for `https://gitlab.com/pycqa/flake8/issues/517'; see - ;; also `https://github.com/flycheck/flycheck/issues/1722' - (locate-dominating-file (or buffer-file-name default-directory) "setup.cfg")) - (flycheck-define-checker python-flake8 "A Python syntax and style checker using Flake8. @@ -10892,7 +10712,7 @@ Requires Flake8 3.0 or newer. See URL :working-directory flycheck-python-find-project-root :error-filter (lambda (errors) (let ((errors (flycheck-sanitize-errors errors))) - (seq-map #'flycheck-flake8-fix-error-level errors))) + (mapcar #'flycheck-flake8-fix-error-level errors))) :error-patterns ((warning line-start (file-name) ":" line ":" (optional column ":") " " @@ -10910,14 +10730,19 @@ Requires Flake8 3.0 or newer. See URL (flycheck-def-config-file-var flycheck-python-ruff-config python-ruff '("pyproject.toml" "ruff.toml" ".ruff.toml")) +(defun flycheck--explain-error-via-checker (checker &rest args) + "Return an explainer function that calls CHECKER with ARGS. +The checker output is fontified as Markdown." + (lambda () + (apply #'flycheck-call-checker-process + checker nil standard-output t args) + (with-current-buffer standard-output + (flycheck--fontify-as-markdown)))) + (defun flycheck-python-ruff-explainer (err) - "Return documentation for the ruff `flycheck-error' ERR." + "Return an explainer function for the ruff error ERR." (when-let (error-code (flycheck-error-id err)) - (lambda () - (flycheck-call-checker-process - 'python-ruff nil standard-output t "rule" error-code) - (with-current-buffer standard-output - (flycheck--fontify-as-markdown))))) + (flycheck--explain-error-via-checker 'python-ruff "rule" error-code))) (flycheck-define-checker python-ruff "A Python syntax and style checker using Ruff. @@ -10932,11 +10757,11 @@ See URL `https://docs.astral.sh/ruff/'." "-") :standard-input t :error-filter (lambda (errors) - (let* ((errors (flycheck-sanitize-errors errors)) - (errors-with-ids (seq-filter #'flycheck-error-id errors))) - (seq-union - (seq-difference errors errors-with-ids) - (seq-map #'flycheck-flake8-fix-error-level errors-with-ids)))) + (let ((errors (flycheck-sanitize-errors errors))) + (dolist (err errors) + (when (flycheck-error-id err) + (flycheck-flake8-fix-error-level err))) + errors)) :error-patterns ((error line-start (or "-" (file-name)) ":" line ":" (optional column ":") " " @@ -11031,26 +10856,29 @@ See URL `https://www.pylint.org/'." See URL `https://docs.python.org/3.4/library/py_compile.html'." :command ("python3" "-m" "py_compile" source) :error-patterns - ;; Python 2.7 ((error line-start " File \"" (file-name) "\", line " line "\n" (>= 2 (zero-or-more not-newline) "\n") "SyntaxError: " (message) line-end) (error line-start "Sorry: IndentationError: " (message) "(" (file-name) ", line " line ")" - line-end) - ;; 2.6 - (error line-start "SyntaxError: ('" (message (one-or-more (not (any "'")))) - "', ('" (file-name (one-or-more (not (any "'")))) "', " - line ", " column ", " (one-or-more not-newline) line-end)) + line-end)) :working-directory flycheck-python-find-project-root :modes (python-mode python-ts-mode) :next-checkers ((warning . python-mypy))) +;; On systems where "python3" is not a working interpreter (e.g., Windows +;; where python3.exe is a Microsoft Store stub), fall back to "python". +(unless (ignore-errors (zerop (call-process "python3" nil nil nil "--version"))) + (dolist (checker '(json-python-json python-flake8 python-pylint + python-pycompile)) + (let ((var (flycheck-checker-executable-variable checker))) + (set-default var "python")))) + (defun flycheck-pyright--parse-error (output checker buffer) "Parse pyright errors/warnings from JSON OUTPUT. CHECKER and BUFFER denote the CHECKER that returned OUTPUT and the BUFFER that was checked respectively." - (seq-map + (mapcar (lambda (err) (let-alist err (flycheck-error-new-at @@ -11061,6 +10889,7 @@ the BUFFER that was checked respectively." ("warning" 'warning) (_ 'warning)) .message + :id .rule :end-line (+ 1 .range.end.line) :end-column (+ 1 .range.end.character) :checker checker @@ -11069,9 +10898,9 @@ the BUFFER that was checked respectively." (cdr (nth 2 (car (flycheck-parse-json output)))))) (flycheck-define-checker python-pyright - "Static type checker for Python + "A Python static type checker using Pyright. -See URL https://github.com/microsoft/pyright." +See URL `https://github.com/microsoft/pyright'." :command ("pyright" "--outputjson" source-inplace) @@ -11091,14 +10920,14 @@ See URL https://github.com/microsoft/pyright." (const :tag "Write to the working directory" nil) (const :tag "Never write .mypy_cache directories" null-device) (string :tag "Path")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (flycheck-def-option-var flycheck-python-mypy-python-executable nil python-mypy "Python executable to find the installed PEP 561 packages." :type '(choice (const :tag "Same as mypy's" nil) (string :tag "Path")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "33")) (flycheck-define-checker python-mypy @@ -11107,6 +10936,7 @@ See URL https://github.com/microsoft/pyright." See URL `https://mypy-lang.org/'." :command ("mypy" "--show-column-numbers" + "--show-error-codes" "--no-pretty" (config-file "--config-file" flycheck-python-mypy-config) (option "--cache-dir" flycheck-python-mypy-cache-dir) @@ -11119,6 +10949,14 @@ See URL `https://mypy-lang.org/'." ": warning:" (message) line-end) (info line-start (file-name) ":" line (optional ":" column) ": note:" (message) line-end)) + :error-filter + (lambda (errors) + (dolist (err errors) + (let ((msg (flycheck-error-message err))) + (when (and msg (string-match "\\(.*?\\) \\[\\([^]]+\\)\\]\\'" msg)) + (setf (flycheck-error-message err) (match-string 1 msg)) + (setf (flycheck-error-id err) (match-string 2 msg))))) + errors) :working-directory flycheck-python-find-project-root :modes (python-mode python-ts-mode) ;; Ensure the file is saved, to work around @@ -11146,7 +10984,7 @@ expression, which selects linters for lintr." (defun flycheck-r-has-lintr (checker) "Whether CHECKER (R) has installed the `lintr' library." - (eql 0 (flycheck-call-checker-process + (zerop (flycheck-call-checker-process checker nil nil nil "--slave" "--no-restore" "--no-save" "-e" "library('lintr')"))) @@ -11202,7 +11040,7 @@ See URL: `https://www.r-project.org/'." (defun flycheck-racket-has-expand-p (checker) "Whether the executable of CHECKER provides the `expand' command." - (eql 0 (flycheck-call-checker-process checker nil nil nil "expand"))) + (zerop (flycheck-call-checker-process checker nil nil nil "expand"))) (flycheck-define-checker racket "A Racket syntax checker with `raco expand'. @@ -11270,14 +11108,15 @@ See URL `https://github.com/rpm-software-management/rpmlint'." :error-filter ;; rpmlint 1.1 outputs a spurious error for the temp file created by flycheck (lambda (errors) - (dolist (err (seq-remove - (lambda (err) - (string-suffix-p "(none)" (flycheck-error-filename err))) - errors)) + (let ((filtered (seq-remove + (lambda (err) + (string-suffix-p "(none)" (flycheck-error-filename err))) + errors))) ;; Add fake line numbers if they are missing in the lint output - (unless (flycheck-error-line err) - (setf (flycheck-error-line err) 1))) - errors) + (dolist (err filtered) + (unless (flycheck-error-line err) + (setf (flycheck-error-line err) 1))) + filtered)) :error-explainer (lambda (error) (when-let* ((error-message (flycheck-error-message error)) @@ -11312,6 +11151,17 @@ See URL `https://github.com/rpm-software-management/rpmlint'." :safe #'flycheck-string-list-p :package-version '(flycheck . "33")) +(defun flycheck-markdownlint-error-filter (errors) + "Error filter for markdownlint checkers." + (flycheck-sanitize-errors + (flycheck-remove-error-file-names "(string)" errors))) + +(defun flycheck-markdownlint-error-explainer (err) + "Error explainer for markdownlint checkers." + (let ((error-code (substring (flycheck-error-id err) 0 5)) + (url "https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#%s")) + (and error-code `(url . ,(format url error-code))))) + (flycheck-define-checker markdown-markdownlint-cli "Markdown checker using markdownlint-cli. @@ -11323,20 +11173,22 @@ See URL `https://github.com/igorshubovych/markdownlint-cli'." "--" source) :error-patterns - ((error line-start + (;; markdownlint-cli v0.42+/cli2 v0.14+ include a severity word + (error line-start + (file-name) ":" line + (? ":" column) " " + (or "error" "warning") " " + (id (one-or-more (not (any space)))) + " " (message) line-end) + ;; older versions without severity word + (error line-start (file-name) ":" line (? ":" column) " " (id (one-or-more (not (any space)))) " " (message) line-end)) - :error-filter - (lambda (errors) - (flycheck-sanitize-errors - (flycheck-remove-error-file-names "(string)" errors))) + :error-filter flycheck-markdownlint-error-filter :modes (markdown-mode gfm-mode) - :error-explainer - (lambda (err) - (let ((error-code (substring (flycheck-error-id err) 0 5)) - (url "https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#%s")) - (and error-code `(url . ,(format url error-code)))))) + :error-explainer flycheck-markdownlint-error-explainer + :next-checkers ((warning . proselint))) (flycheck-def-config-file-var flycheck-markdown-markdownlint-cli2-config markdown-markdownlint-cli2 @@ -11352,20 +11204,22 @@ See URL `https://github.com/DavidAnson/markdownlint-cli2'." "--" source) :error-patterns - ((error line-start + (;; markdownlint-cli v0.42+/cli2 v0.14+ include a severity word + (error line-start + (file-name) ":" line + (? ":" column) " " + (or "error" "warning") " " + (id (one-or-more (not (any space)))) + " " (message) line-end) + ;; older versions without severity word + (error line-start (file-name) ":" line (? ":" column) " " (id (one-or-more (not (any space)))) " " (message) line-end)) - :error-filter - (lambda (errors) - (flycheck-sanitize-errors - (flycheck-remove-error-file-names "(string)" errors))) + :error-filter flycheck-markdownlint-error-filter :modes (markdown-mode gfm-mode) - :error-explainer - (lambda (err) - (let ((error-code (substring (flycheck-error-id err) 0 5)) - (url "https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#%s")) - (and error-code `(url . ,(format url error-code)))))) + :error-explainer flycheck-markdownlint-error-explainer + :next-checkers ((warning . proselint))) (flycheck-def-option-var flycheck-markdown-mdl-rules nil markdown-mdl "Rules to enable for mdl. @@ -11375,7 +11229,7 @@ the name of a rule to enable. By default all rules are enabled. -See URL `https://git.io/vhi2t'." +See URL `https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md'." :type '(repeat :tag "Enabled rules" (string :tag "rule name")) :safe #'flycheck-string-list-p @@ -11389,7 +11243,7 @@ the name of a rule tag. Only rules with these tags are enabled. By default all rules are enabled. -See URL `https://git.io/vhi2t'." +See URL `https://github.com/markdownlint/markdownlint/blob/main/docs/RULES.md'." :type '(repeat :tag "Enabled tags" (string :tag "tag name")) :safe #'flycheck-string-list-p @@ -11417,7 +11271,8 @@ See URL `https://github.com/markdownlint/markdownlint'." (lambda (errors) (flycheck-sanitize-errors (flycheck-remove-error-file-names "(stdin)" errors))) - :modes (markdown-mode gfm-mode)) + :modes (markdown-mode gfm-mode) + :next-checkers ((warning . proselint))) (flycheck-def-config-file-var flycheck-markdown-pymarkdown-config markdown-pymarkdown nil @@ -11440,7 +11295,8 @@ See URL `https://pypi.org/project/pymarkdownlnt/'." (lambda (errors) (flycheck-sanitize-errors (flycheck-remove-error-file-names "(string)" errors))) - :modes (markdown-mode gfm-mode)) + :modes (markdown-mode gfm-mode) + :next-checkers ((warning . proselint))) (flycheck-define-checker nix "Nix checker using nix-instantiate. @@ -11464,44 +11320,6 @@ See URL `https://nixos.org/nix/manual/#sec-nix-instantiate'." (lambda (errors) (flycheck-sanitize-errors (flycheck-remove-error-file-names "(string)" errors))) - :next-checkers ((warning . nix-linter)) - :modes (nix-mode nix-ts-mode)) - -(defun flycheck-parse-nix-linter (output checker buffer) - "Parse nix-linter warnings from JSON OUTPUT. - -CHECKER and BUFFER denote the CHECKER that returned OUTPUT and -the BUFFER that was checked respectively. - -See URL `https://github.com/Synthetica9/nix-linter' for more -information about nix-linter." - (mapcar (lambda (err) - (let-alist err - (flycheck-error-new-at - .pos.spanBegin.sourceLine - .pos.spanBegin.sourceColumn - 'warning - .description - :id .offense - :checker checker - :buffer buffer - :filename (buffer-file-name buffer) - :end-line .pos.spanEnd.sourceLine - :end-column .pos.spanEnd.sourceColumn))) - (flycheck-parse-json output))) - -(flycheck-define-checker nix-linter - "Nix checker using nix-linter. - -See URL `https://github.com/Synthetica9/nix-linter'." - :command ("nix-linter" "--json-stream" "-") - :standard-input t - :error-parser flycheck-parse-nix-linter - :error-explainer - (lambda (error) - (when-let (error-code (flycheck-error-id error)) - (flycheck-call-checker-process-for-output - 'nix-linter nil t "--help-for" error-code))) :modes (nix-mode nix-ts-mode)) (defun flycheck-parse-statix (output checker buffer) @@ -11513,31 +11331,26 @@ the BUFFER that was checked respectively. See URL `https://github.com/nerdypepper/statix' for more information about statix." (mapcar (lambda (err) - ;; Diagnostic information is a (seemingly always) 1 element array. - (let-alist (car (alist-get 'diagnostics err)) - (let ((message .message) - (start-line .at.from.line) - (start-column .at.from.column) - (end-line .at.to.line) - (end-column .at.to.column)) - - (let-alist err - (flycheck-error-new-at - start-line - start-column - (pcase .severity ("Error" 'error) - ("Warn" 'warning) - (_ 'warning)) - (format "%s: %s" .note message) - :id (format "%s%02d" (pcase .severity - ("Error" "E") - ("Warn" "W") - (_ "")) .code) - :checker checker - :buffer buffer - :filename (buffer-file-name buffer) - :end-line end-line - :end-column end-column))))) + (let-alist err + ;; Diagnostic information is a (seemingly always) 1 element array. + (let-alist (car .diagnostics) + (flycheck-error-new-at + .at.from.line + .at.from.column + (pcase (alist-get 'severity err) + ("Error" 'error) + (_ 'warning)) + (format "%s: %s" (alist-get 'note err) .message) + :id (format "%s%02d" (pcase (alist-get 'severity err) + ("Error" "E") + ("Warn" "W") + (_ "")) + (alist-get 'code err)) + :checker checker + :buffer buffer + :filename (buffer-file-name buffer) + :end-line .at.to.line + :end-column .at.to.column)))) (alist-get 'report (car (flycheck-parse-json output))))) (flycheck-define-checker statix @@ -11546,7 +11359,7 @@ information about statix." See URL `https://github.com/nerdypepper/statix'." :command ("statix" "check" "-o=json" source) :error-parser flycheck-parse-statix - :modes nix-mode) + :modes (nix-mode nix-ts-mode)) (defun flycheck-locate-sphinx-source-directory () "Locate the Sphinx source directory for the current buffer. @@ -11560,7 +11373,7 @@ part of a Sphinx project." (flycheck-define-checker rst "A ReStructuredText (RST) syntax checker using Docutils. -See URL `https://docutils.sourceforge.net/'." +See URL `https://docutils.sourceforge.io/'." ;; include:: directives :command ("rst2pseudoxml.py" "--report=2" "--halt=5" ;; Read from standard input and throw output away @@ -11571,7 +11384,8 @@ See URL `https://docutils.sourceforge.net/'." (error line-start ":" line ": (" (or "ERROR/3" "SEVERE/4") ") " (message) line-end)) - :modes rst-mode) + :modes rst-mode + :next-checkers ((warning . proselint))) (flycheck-def-option-var flycheck-sphinx-warn-on-missing-references t rst-sphinx "Whether to warn about missing references in Sphinx. @@ -11601,7 +11415,8 @@ Requires Sphinx 1.2 or newer. See URL `https://sphinx-doc.org'." (message) line-end)) :modes rst-mode :predicate (lambda () (and (flycheck-buffer-saved-p) - (flycheck-locate-sphinx-source-directory)))) + (flycheck-locate-sphinx-source-directory))) + :next-checkers ((warning . proselint))) (defun flycheck-ruby--find-project-root (_checker) "Compute an appropriate working-directory for flycheck-ruby. @@ -11637,7 +11452,8 @@ report style issues as well." line-end) (error line-start (file-name) ":" line ":" column ": " (or "E" "F") ": " (optional (id (one-or-more (not (any ":")))) ": ") (message) - line-end))) + line-end)) + "Error patterns shared by RuboCop-based checkers.") (flycheck-def-executable-var ruby-rubocop "rubocop") (flycheck-define-command-checker 'ruby-rubocop @@ -11766,23 +11582,6 @@ See URL `https://www.ruby-lang.org/'." :modes (enh-ruby-mode ruby-mode ruby-ts-mode) :next-checkers ((warning . ruby-chef-cookstyle))) -(flycheck-define-checker ruby-jruby - "A Ruby syntax checker using the JRuby interpreter. - -This syntax checker is very primitive, and may break on future -versions of JRuby. - -Please consider using `ruby-rubocop' instead. - -See URL `https://jruby.org/'." - :command ("jruby" "-w" "-c") - :standard-input t - :error-patterns - ((error line-start "SyntaxError in -:" line ": " (message) line-end) - (warning line-start "-:" line ": warning: " (message) line-end) - (error line-start "-:" line ": " (message) line-end)) - :modes (enh-ruby-mode ruby-mode ruby-ts-mode)) - (flycheck-def-args-var flycheck-cargo-check-args (rust-cargo) :package-version '(flycheck . "32")) @@ -11813,11 +11612,11 @@ The value of this variable is either a string with the path to the crate root for the current buffer, or nil if the current buffer is a crate. A relative path is relative to the current buffer. -If this variable is non nil the current buffer will only be checked +If this variable is non-nil the current buffer will only be checked if it is not modified, i.e. after it has been saved." :type '(choice (const :tag "Unspecified" nil) (file :tag "Root")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "0.20")) (make-variable-buffer-local 'flycheck-rust-crate-root) @@ -11859,7 +11658,7 @@ This always requires a non-nil value, unless ignored." :type '(choice (const :tag "Unspecified" nil) (string :tag "Binary name")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "28")) (make-variable-buffer-local 'flycheck-rust-binary-name) @@ -11896,13 +11695,9 @@ Relative paths are relative to the file being checked." (font-lock-ensure)))) (defun flycheck-rust-error-explainer (error) - "Return an explanation for the given `flycheck-error' ERROR." + "Return an explainer function for the given rustc error ERROR." (when-let (error-code (flycheck-error-id error)) - (lambda () - (flycheck-call-checker-process - 'rust nil standard-output t "--explain" error-code) - (with-current-buffer standard-output - (flycheck--fontify-as-markdown))))) + (flycheck--explain-error-via-checker 'rust "--explain" error-code))) (defun flycheck-rust-error-filter (errors) "Filter ERRORS from rustc output that have no explanatory value." @@ -11956,7 +11751,7 @@ Execute `cargo --list' to find out whether COMMAND is present." (let ((cargo (funcall flycheck-executable-find "cargo"))) (member command (mapcar (lambda (line) - (replace-regexp-in-string "\\s-*\\(\\S-+\\).*\\'" "\\1" line)) + (car (split-string (string-trim line)))) (ignore-errors (process-lines cargo "--list")))))) (defun flycheck-rust-valid-crate-type-p (crate-type) @@ -12039,13 +11834,14 @@ This syntax checker requires Rust 1.17 or newer. See URL (t 'success)))))))) (flycheck-define-checker rust - "A Rust syntax checker using Rust compiler. + "A Rust syntax checker using the Rust compiler. This syntax checker needs Rust 1.18 or newer. See URL `https://www.rust-lang.org'." :command ("rustc" (option "--crate-type" flycheck-rust-crate-type) - "--emit=mir" "-o" "/dev/null" ; avoid creating binaries + "--emit=metadata" + "--out-dir" (eval (flycheck-temp-dir-system)) ; avoid creating binaries "--error-format=json" (option-flag "--test" flycheck-rust-check-tests) (option-list "-L" flycheck-rust-library-path concat) @@ -12089,107 +11885,43 @@ See URL `https://github.com/rust-lang-nursery/rust-clippy'." :face (if has-toml 'success '(bold warning)))))))) (flycheck-define-checker salt-lint - "A salt linter which apply common best practices for SaltStack. + "A salt linter which applies common best practices for SaltStack. See URL `https://salt-lint.readthedocs.io/en/latest/'." :command ("python" "-m" "saltlint" "--json") :standard-input t :error-parser flycheck-salt-lint-parser - :error-filter (lambda (errors) (flycheck-sanitize-errors errors)) + :error-filter flycheck-sanitize-errors :modes salt-mode) (defun flycheck-salt-lint-parser (output checker buffer) "Parse salt lint JSON errors from OUTPUT. -The arguments CHECKER and BUFFER are only passed through." +CHECKER and BUFFER are used to construct the error objects." (condition-case nil - (let* ((json-array-type 'list) - (json-object-type 'plist) - (filename (buffer-file-name buffer)) - (errors (json-read-from-string output))) + (let ((filename (buffer-file-name buffer)) + (errors (json-parse-string output + :object-type 'alist + :array-type 'list + :null-object nil + :false-object nil))) (mapcar (lambda (e) - (flycheck-error-new - :checker checker - :buffer buffer - :filename filename - :level (pcase (plist-get e :severity) - ("HIGH" 'error) - ("MEDIUM" 'warning) - ("LOW" 'warning) - ("INFO" 'info) - (_ 'info)) - :line (plist-get e :linenumber) - :column 0 - :message (concat (plist-get e :message) (plist-get e :line)) - :id (plist-get e :id))) errors)) - (json-error nil))) - -(defvar flycheck-sass-scss-cache-directory nil - "The cache directory for `sass' and `scss'.") - -(defun flycheck-sass-scss-cache-location () - "Get the cache location for `sass' and `scss'. - -If no cache directory exists yet, create one and return it. -Otherwise return the previously used cache directory." - (setq flycheck-sass-scss-cache-directory - (or flycheck-sass-scss-cache-directory - (make-temp-file "flycheck-sass-scss-cache" 'directory)))) - -(flycheck-def-option-var flycheck-sass-compass nil sass - "Whether to enable the Compass CSS framework. - -When non-nil, enable the Compass CSS framework, via `--compass'." - :type 'boolean - :safe #'booleanp - :package-version '(flycheck . "0.16")) - -(flycheck-define-checker sass - "A Sass syntax checker using the Sass compiler. - -See URL `https://sass-lang.com'." - :command ("sass" - "--cache-location" (eval (flycheck-sass-scss-cache-location)) - (option-flag "--compass" flycheck-sass-compass) - "--check" "--stdin") - :standard-input t - :error-patterns - ((error line-start - (or "Syntax error: " "Error: ") - (message (one-or-more not-newline) - (zero-or-more "\n" - (one-or-more " ") - (one-or-more not-newline))) - (optional "\r") "\n" (one-or-more " ") "on line " line - " of standard input" - line-end) - (warning line-start - "WARNING: " - (message (one-or-more not-newline) - (zero-or-more "\n" - (one-or-more " ") - (one-or-more not-newline))) - (optional "\r") "\n" (one-or-more " ") "on line " line - " of " (one-or-more not-newline) - line-end)) - :modes sass-mode) - -(flycheck-def-config-file-var flycheck-sass-lintrc sass/scss-sass-lint - ".sass-lint.yml" - :package-version '(flycheck . "30")) - -(flycheck-define-checker sass/scss-sass-lint - "A SASS/SCSS syntax checker using sass-Lint. - -See URL `https://github.com/sasstools/sass-lint'." - :command ("sass-lint" - "--verbose" - "--no-exit" - "--format" "Checkstyle" - (config-file "--config" flycheck-sass-lintrc) - source) - :error-parser flycheck-parse-checkstyle - :modes (sass-mode scss-mode)) + (let-alist e + (flycheck-error-new-at + .linenumber 0 + (pcase .severity + ("HIGH" 'error) + ("MEDIUM" 'warning) + ("LOW" 'warning) + ("INFO" 'info) + (_ 'info)) + (concat .message .line) + :id .id + :checker checker + :buffer buffer + :filename filename))) + errors)) + (json-parse-error nil))) (flycheck-define-checker scala "A Scala syntax checker using the Scala compiler. @@ -12197,8 +11929,9 @@ See URL `https://github.com/sasstools/sass-lint'." See URL `https://www.scala-lang.org/'." :command ("scalac" "-Ystop-after:parser" source) :error-patterns - ((error line-start (file-name) ":" line ": error: " (message) line-end)) - :modes scala-mode + ((error line-start (file-name) ":" line ": error: " (message) line-end) + (warning line-start (file-name) ":" line ": warning: " (message) line-end)) + :modes (scala-mode scala-ts-mode) :next-checkers ((warning . scala-scalastyle))) (flycheck-def-config-file-var flycheck-scalastylerc scala-scalastyle nil @@ -12222,7 +11955,7 @@ See URL `https://www.scalastyle.org'." :error-filter (lambda (errors) (flycheck-sanitize-errors (flycheck-increment-error-columns errors))) - :modes scala-mode + :modes (scala-mode scala-ts-mode) :predicate ;; Inhibit this syntax checker if the JAR or the configuration are unset or ;; missing @@ -12238,7 +11971,7 @@ See URL `https://www.scalastyle.org'." :label "Configuration file" :message (cond ((not flycheck-scalastylerc) - "`flycheck-scalastyletrc' not set") + "`flycheck-scalastylerc' not set") ((not config-file) (format "file %s not found" flycheck-scalastylerc)) (t (format "found at %s" config-file))) @@ -12280,7 +12013,7 @@ See URL `https://call-cc.org/'." (zero-or-more not-newline)) (one-or-more space) "<--") line-end) - ;; A of version 4.12.0, the chicken compiler doesn't provide a + ;; As of version 4.12.0, the chicken compiler doesn't provide a ;; line number for this error. (error line-start "Syntax error: " (message (one-or-more not-newline) @@ -12293,7 +12026,7 @@ See URL `https://call-cc.org/'." "Error: " (zero-or-more not-newline) ":\n" (one-or-more (any space)) "(" (file-name) ":" line ") " (message) line-end) - ;; A of version 4.12.0, the chicken compiler doesn't provide a + ;; As of version 4.12.0, the chicken compiler doesn't provide a ;; line number for this error. (error line-start "Error: " (message (one-or-more not-newline) @@ -12323,63 +12056,6 @@ See URL `https://call-cc.org/'." (t '(bold error))))))) :modes scheme-mode) -(defconst flycheck-scss-lint-checkstyle-re - (rx "cannot load such file" (1+ not-newline) "scss_lint_reporter_checkstyle") - "Regular expression to parse missing checkstyle error.") - -(defun flycheck-parse-scss-lint (output checker buffer) - "Parse SCSS-Lint OUTPUT from CHECKER and BUFFER. - -Like `flycheck-parse-checkstyle', but catches errors about -missing checkstyle reporter from SCSS-Lint." - (if (string-match-p flycheck-scss-lint-checkstyle-re output) - (list (flycheck-error-new-at - 1 nil 'error "Checkstyle reporter for SCSS-Lint missing. -Please run gem install scss_lint_reporter_checkstyle" - :checker checker - :buffer buffer - :filename (buffer-file-name buffer))) - (flycheck-parse-checkstyle output checker buffer))) - -(flycheck-def-config-file-var flycheck-scss-lintrc scss-lint ".scss-lint.yml" - :package-version '(flycheck . "0.23")) - -(flycheck-define-checker scss-lint - "A SCSS syntax checker using SCSS-Lint. - -Needs SCSS-Lint 0.43.2 or newer. - -See URL `https://github.com/brigade/scss-lint'." - :command ("scss-lint" - "--require=scss_lint_reporter_checkstyle" - "--format=Checkstyle" - (config-file "--config" flycheck-scss-lintrc) - "--stdin-file-path" source-original "-") - :standard-input t - ;; We cannot directly parse Checkstyle XML, since for some mysterious reason - ;; SCSS-Lint doesn't have a built-in Checkstyle reporter, and instead ships it - ;; as an addon which might not be installed. We use a custom error parser to - ;; check whether the addon is missing and turn that into a special kind of - ;; Flycheck error. - :error-parser flycheck-parse-scss-lint - :modes scss-mode - :verify - (lambda (checker) - (when-let - (output (flycheck-call-checker-process-for-output - checker nil nil "--require=scss_lint_reporter_checkstyle")) - (let ((reporter-missing - (string-match-p flycheck-scss-lint-checkstyle-re output))) - (list - (flycheck-verification-result-new - :label "checkstyle reporter" - :message (if reporter-missing - "scss_lint_reporter_checkstyle plugin missing" - "present") - :face (if reporter-missing - '(bold error) - 'success))))))) - (flycheck-define-checker scss-stylelint "A SCSS syntax and style checker using stylelint. @@ -12408,44 +12084,6 @@ See URL `https://stylelint.io/'." :predicate flycheck-buffer-nonempty-p :modes (sass-mode)) -(flycheck-def-option-var flycheck-scss-compass nil scss - "Whether to enable the Compass CSS framework. - -When non-nil, enable the Compass CSS framework, via `--compass'." - :type 'boolean - :safe #'booleanp - :package-version '(flycheck . "0.16")) - -(flycheck-define-checker scss - "A SCSS syntax checker using the SCSS compiler. - -See URL `https://sass-lang.com'." - :command ("scss" - "--cache-location" (eval (flycheck-sass-scss-cache-location)) - (option-flag "--compass" flycheck-scss-compass) - "--check" "--stdin") - :standard-input t - :error-patterns - ((error line-start - (or "Syntax error: " "Error: ") - (message (one-or-more not-newline) - (zero-or-more "\n" - (one-or-more " ") - (one-or-more not-newline))) - (optional "\r") "\n" (one-or-more " ") "on line " line - " of standard input" - line-end) - (warning line-start - "WARNING: " - (message (one-or-more not-newline) - (zero-or-more "\n" - (one-or-more " ") - (one-or-more not-newline))) - (optional "\r") "\n" (one-or-more " ") "on line " line - " of an unknown file" - line-end)) - :modes scss-mode) - (flycheck-def-args-var flycheck-sh-bash-args (sh-bash) :package-version '(flycheck . "32")) @@ -12547,6 +12185,22 @@ shellcheck directives in the script." :safe #'booleanp :package-version '(flycheck . "36")) +(flycheck-def-option-var flycheck-shellcheck-enabled-checks nil sh-shellcheck + "A list of enabled optional checks for ShellCheck. + +The value of this variable is a list of strings, where each +string is the name of an optional check to enable. Use \"all\" +to enable all optional checks. + +See the ShellCheck man page for a list of available optional checks." + :type '(repeat :tag "Enabled checks" + (string :tag "Check name")) + :safe #'flycheck-string-list-p + :package-version '(flycheck . "36")) + +(flycheck-def-args-var flycheck-shellcheck-args sh-shellcheck + :package-version '(flycheck . "36")) + (flycheck-define-checker sh-shellcheck "A shell script syntax and style checker using Shellcheck. @@ -12560,6 +12214,9 @@ See URL `https://github.com/koalaman/shellcheck/'." flycheck-shellcheck-follow-sources) (option "--exclude" flycheck-shellcheck-excluded-warnings list flycheck-option-comma-separated-list) + (option "--enable" flycheck-shellcheck-enabled-checks list + flycheck-option-comma-separated-list) + (eval flycheck-shellcheck-args) "-") :standard-input t :error-parser flycheck-parse-checkstyle @@ -12644,7 +12301,7 @@ See URL (flycheck-def-config-file-var flycheck-chktexrc tex-chktex ".chktexrc") (flycheck-define-checker tcl-nagelfar - "An extensible tcl syntax checker + "A Tcl syntax checker using Nagelfar. See URL `https://nagelfar.sourceforge.net/'." :command ("nagelfar" "-H" source) @@ -12673,7 +12330,7 @@ See URL `https://www.terraform.io/docs/commands/fmt.html'." (message (one-or-more (and (one-or-more (not (any ?\n))) ?\n))) line-end)) :next-checkers ((warning . terraform-tflint)) - :modes terraform-mode) + :modes (terraform-mode terraform-ts-mode)) (flycheck-def-option-var flycheck-tflint-variable-files nil terraform-tflint "A list of files to resolve terraform variables. @@ -12719,7 +12376,7 @@ See URL `https://github.com/terraform-linters/tflint'." (option-list "--var-file=" flycheck-tflint-variable-files concat)) :error-parser flycheck-parse-tflint-linter :predicate flycheck-buffer-saved-p - :modes terraform-mode) + :modes (terraform-mode terraform-ts-mode)) (flycheck-def-option-var flycheck-chktex-extra-flags nil tex-chktex "A list of extra arguments to give to chktex. @@ -12745,11 +12402,13 @@ See URL `https://www.nongnu.org/chktex/'." "--verbosity=0" "--quiet" "--inputfiles") :standard-input t :error-patterns - ((warning line-start "stdin:" line ":" column ":" + ((warning line-start (file-name) ":" line ":" column ":" (id (one-or-more digit)) ":" (message) line-end)) :error-filter (lambda (errors) - (flycheck-sanitize-errors (flycheck-increment-error-columns errors))) + (flycheck-sanitize-errors + (flycheck-remove-error-file-names + "stdin" (flycheck-increment-error-columns errors)))) :modes (latex-mode LaTeX-mode plain-tex-mode plain-TeX-mode)) (flycheck-define-checker tex-lacheck @@ -12842,45 +12501,6 @@ See URL `https://textlint.github.io/'." :message plugin :face 'success))))) -(flycheck-def-config-file-var flycheck-typescript-tslint-config - typescript-tslint "tslint.json" - :package-version '(flycheck . "27")) - -(flycheck-def-option-var flycheck-typescript-tslint-rulesdir - nil typescript-tslint - "The directory of custom rules for TSLint. - -The value of this variable is either a string containing the path -to a directory with custom rules, or nil, to not give any custom -rules to TSLint. - -Refer to the TSLint manual at URL -`https://palantir.github.io/tslint/usage/cli/' -for more information about the custom directory." - :type '(choice (const :tag "No custom rules directory" nil) - (directory :tag "Custom rules directory")) - :safe #'flycheck-string-or-nil-p - :package-version '(flycheck . "27")) - -(flycheck-def-args-var flycheck-tslint-args (typescript-tslint) - :package-version '(flycheck . "31")) - -(flycheck-define-checker typescript-tslint - "TypeScript style checker using TSLint. - -Note that this syntax checker is not used if -`flycheck-typescript-tslint-config' is nil or refers to a -non-existing file. - -See URL `https://github.com/palantir/tslint'." - :command ("tslint" "--format" "json" - (config-file "--config" flycheck-typescript-tslint-config) - (option "--rules-dir" flycheck-typescript-tslint-rulesdir) - (eval flycheck-tslint-args) - source-inplace) - :error-parser flycheck-parse-tslint - :modes (typescript-mode typescript-ts-mode tsx-ts-mode)) - (flycheck-def-option-var flycheck-verilator-include-path nil verilog-verilator "A list of include directories for Verilator. @@ -12917,7 +12537,7 @@ standard, or nil, to use the default standard. When non-nil, pass the language standard via the `--std' option." :type '(choice (const :tag "Default standard" nil) (string :tag "Language standard")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (make-variable-buffer-local 'flycheck-ghdl-language-standard) @@ -12929,7 +12549,7 @@ to use for the file library, or nil, to use the default value. When non-nil, pass the directory via the `--workdir' option." :type '(choice (const :tag "Default directory" nil) (string :tag "Directory for the file library")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (make-variable-buffer-local 'flycheck-ghdl-workdir) @@ -12944,7 +12564,7 @@ pass the ieee library standard via the `--ieee' option." (const :tag "IEEE standard" "standard") (const :tag "Synopsys standard" "synopsys") (const :tag "Mentor standard" "mentor")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "32")) (make-variable-buffer-local 'flycheck-ghdl-ieee-library) @@ -12963,43 +12583,22 @@ See URL `https://github.com/ghdl/ghdl'." (error line-start (file-name) ":" line ":" column ":error: " (message) line-end)) :modes vhdl-mode) -(flycheck-def-option-var flycheck-xml-xmlstarlet-xsd-path nil xml-xmlstarlet - "An XSD schema to validate against." - :type '(choice (const :tag "None" nil) - (file :tag "XSD schema")) - :safe #'flycheck-string-or-nil-p - :package-version '(flycheck . "31")) - -(flycheck-define-checker xml-xmlstarlet - "A XML syntax checker and validator using the xmlstarlet utility. - -See URL `https://xmlstar.sourceforge.net/'." - ;; Validate standard input with verbose error messages, and do not dump - ;; contents to standard output - :command ("xmlstarlet" "val" "--err" "--quiet" - (option "--xsd" flycheck-xml-xmlstarlet-xsd-path) - "-") - :standard-input t - :error-patterns - ((error line-start "-:" line "." column ": " (message) line-end)) - :modes (xml-mode nxml-mode)) - (flycheck-def-option-var flycheck-xml-xmllint-xsd-path nil xml-xmllint "An XSD schema to validate against." :type '(choice (const :tag "None" nil) (file :tag "XSD schema")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "31")) (flycheck-def-option-var flycheck-xml-xmllint-relaxng-path nil xml-xmllint - "An RELAX NG schema to validate against." + "A RELAX NG schema to validate against." :type '(choice (const :tag "None" nil) (file :tag "RELAX NG schema")) - :safe #'flycheck-string-or-nil-p + :safe #'string-or-null-p :package-version '(flycheck . "34")) (flycheck-define-checker xml-xmllint - "A XML syntax checker and validator using the xmllint utility. + "An XML syntax checker and validator using the xmllint utility. The xmllint is part of libxml2, see URL `https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home'." @@ -13009,7 +12608,11 @@ The xmllint is part of libxml2, see URL "-") :standard-input t :error-patterns - ((error line-start "-:" line ": " (message) line-end)) + ((warning line-start "-:" line ": " + (message (one-or-more (not (any ":"))) "warning : " + (one-or-more not-newline)) + line-end) + (error line-start "-:" line ": " (message) line-end)) :modes (xml-mode nxml-mode)) (flycheck-define-checker yaml-jsyaml @@ -13031,26 +12634,6 @@ See URL `https://github.com/nodeca/js-yaml'." :next-checkers ((warning . yaml-yamllint) (warning . cwl))) -(flycheck-define-checker yaml-ruby - "A YAML syntax checker using Ruby's YAML parser. - -This syntax checker uses the YAML parser from Ruby's standard -library. - -See URL `https://www.ruby-doc.org/stdlib-2.0.0/libdoc/yaml/rdoc/YAML.html'." - :command ("ruby" "-ryaml" "-e" "begin; - YAML.load(STDIN); \ - rescue Exception => e; \ - STDERR.puts \"stdin:#{e}\"; \ - end") - :standard-input t - :error-patterns - ((error line-start "stdin:" (zero-or-more not-newline) ":" (message) - "at line " line " column " column line-end)) - :modes (yaml-mode yaml-ts-mode) - :next-checkers ((warning . yaml-yamllint) - (warning . cwl))) - (flycheck-def-config-file-var flycheck-yamllintrc yaml-yamllint '(".yamllint" @@ -13066,9 +12649,19 @@ See URL `https://github.com/adrienverge/yamllint'." (config-file "-c" flycheck-yamllintrc)) :error-patterns ((error line-start - "stdin:" line ":" column ": [error] " (message) line-end) + "stdin:" line ":" column ": [error] " + (message (minimal-match (one-or-more not-newline))) + " (" (id (one-or-more (not (any ")")))) ")" line-end) + (error line-start + "stdin:" line ":" column ": [error] " + (message) line-end) + (warning line-start + "stdin:" line ":" column ": [warning] " + (message (minimal-match (one-or-more not-newline))) + " (" (id (one-or-more (not (any ")")))) ")" line-end) (warning line-start - "stdin:" line ":" column ": [warning] " (message) line-end)) + "stdin:" line ":" column ": [warning] " + (message) line-end)) :modes (yaml-mode yaml-ts-mode) :next-checkers ((warning . cwl))) -- 2.47.3