2

I am attempting add an additional Flycheck syntax checker for nxml-mode, however errors/warnings are not showing up even though the linter, igor, is reporting errors/warnings.

Here is the syntax checker definition.

(flycheck-define-checker igor
  "FreeBSD Documentation Project sanity checker.

See URLs http://www.freebsd.org/docproj/ and 
http://www.freshports.org/textproc/igor/."
  :command ("igor" "-X" source-original)
  :standard-input t
  :error-parser flycheck-parse-checkstyle
  :modes (nxml-mode))

I made the new definition available for automatic selection.

(add-to-list 'flycheck-checkers 'igor 'append)

When the major mode is nxml-mode, I can run flycheck-verify-setup to verify that igor is listed as a checker.

Syntax checkers for buffer chapter.xml in nxml-mode:

  xml-xmlstarlet
    - predicate:  t
    - executable: Found at /usr/local/bin/xml

  xml-xmllint
    - predicate:  t
    - executable: Found at /usr/local/bin/xmllint

  igor
    - predicate:  t
    - executable: Found at /usr/local/bin/igor

Flycheck Mode is enabled.  Use C-u C-c ! x to enable disabled checkers.

If I run flycheck-compile and chose igor, I see errors/warnings.

-*- mode: compilation; default-directory: "~/scm/nm/freebsd-docs.svn/doc/head/en_US.ISO8859-1/books/fdp-primer/editor-config/" -*-
Compilation started at Wed Jul 13 15:12:14

igor -X /home/jrm/scm/nm/freebsd-docs.svn/doc/head/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml
<file name="/home/jrm/scm/nm/freebsd-docs.svn/doc/head/en_US.ISO8859-1/books/fdp-primer/editor-config/chapter.xml">
  <error line="49" column="1" severity="warning" message="spelling" source="igor" />
  <error line="56" column="1" severity="warning" message="wrap long line" source="igor" />
  <error line="112" column="1" severity="warning" message="bad tag indent" source="igor" />
  <error line="114" column="1" severity="warning" message="bad tag indent" source="igor" />
  <error line="114" column="1" severity="warning" message="wrap long line" source="igor" />
  <error line="115" column="1" severity="warning" message="bad tag indent" source="igor" />
  <error line="115" column="1" severity="warning" message="wrap long line" source="igor" />
  <error line="119" column="1" severity="warning" message="wrap long line" source="igor" />
  <error line="120" column="1" severity="warning" message="blank line with whitespace" source="igor" />
</file>

Compilation finished at Wed Jul 13 15:12:15

I can get basic error checking using :error-patterns instead of :error-parser in the definition, so the problem may be related to parsing the checkstyle XML output.

I am running the sixth pretest for the soon-to-be-released as Emacs 25.1. What am I missing?

  • How do you know that the syntax checker doesn't report any errors? What happens when you explicitly select it with C-c ! s? – lunaryorn Jul 13 '16 at 20:20
  • Using C-c ! n gives "No more Flycheck errors" even after I insert errors that I know will trigger igor. These errors are reported when I do C-c ! C-c and select igor. Explicitly selecting igor with C-c ! s makes no difference. – jrm Jul 13 '16 at 20:38
  • Does removing :standard-input t from the definition make any difference? – lunaryorn Jul 13 '16 at 20:42
  • 1
    Oh, it occurred to me that the XML you've shown isn't in Checkstyle format, so naturally the checkstyle parser won't find any errors. Why did you even use it in the first place? You'll need a custom error order for this XML format. – lunaryorn Jul 13 '16 at 20:53
  • 1
    Oh this is wrong; please report this to the developers of the tool. Notably the output is missing the proper root node, and there may be further differences (I didn't take a closer look). – lunaryorn Jul 13 '16 at 20:58
2

As we've found out in our discussion in the comments, contrary to its manpage igor does not create proper Checkstyle XML. The XML document lacks the checkstyle root tag.

Flycheck's flycheck-parse-checkstyle parser expects this root tag and thus fails to parse Igor's output. It simply doesn't find the tags it's looking for and can't parse any errors from the XML document.

You need to write a custom error parser. As you've already found out that wrapping the checkstyle tag around the output is sufficient, I'd just do exactly that:

(defun flycheck-parse-igor (output checker buffer)
  (flycheck-parse-checkstyle (concat "<checkstyle version=\"7.0\">"
                                     output
                                     "</checkstyle>")
                             checker buffer))

If you use this function as :error-parser you should see errors from igor in the buffer.


Please also take the time to report this issue to the developers of igor and ask them to either add the checkstyle tag to their output or change the manpage.

  • 1
    I have submitted a patch to the Igor developer. Thanks again. – jrm Jul 14 '16 at 16:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.