omnisharp-emacs icon indicating copy to clipboard operation
omnisharp-emacs copied to clipboard

Flycheck reporting strange errors

Open k-ode opened this issue 10 years ago • 9 comments

In most cases, Flycheck works great for catching errors. I do get some weird errors in a file that is otherwise error free though.

Method calls within a file report "Invocation error: AmbigousMatch".

You can reproduce this by running Flycheck on Program.cs in the omnisharp-server project.

image

k-ode avatar May 29 '15 11:05 k-ode

I've noticed that too. I don't know what causes that, but it's a problem on the server side.

I remember doing some hack on the server side to just ignore that error but unfortunately I don't think it's released. @nosami any idea? Have you had this happen?

mikavilpas avatar May 29 '15 19:05 mikavilpas

Could you point me in the direction to where you applied that hack? I could problaby figure something out if I just knew where to look.

k-ode avatar Jun 08 '15 12:06 k-ode

The way I did it was on the server side. I looked at the endpoint for codecheck, and before returning any value from the server to omnisharp-emacs, I would do a filter to drop out the invalid value.

It's pretty ugly as an idea, but extremely practical :)

mikavilpas avatar Jun 08 '15 14:06 mikavilpas

Great, thanks! In case anyone else is wondering, I simply filtered the semantic errors in CodeCheckHandler.cs like this:

image

k-ode avatar Jun 09 '15 08:06 k-ode

Hehe, nice! :D

@nosami do you think this could BE a useful hack to have on the server side BT default? At least until omnisharp-roslyn is released, if you can call it a release. 9.6.2015 11.48 ap. "Kim Grönqvist" [email protected] kirjoitti:

Great, thanks! In case anyone else is wondering, I simply filtered the semantic errors in CodeCheckHandler.cs like this:

[image: image] https://cloud.githubusercontent.com/assets/3421067/8053902/f44b2b1a-0e94-11e5-8138-6e2681f18d36.png

— Reply to this email directly or view it on GitHub https://github.com/OmniSharp/omnisharp-emacs/issues/174#issuecomment-110279832 .

mikavilpas avatar Jun 09 '15 08:06 mikavilpas

It would be nice to have a setting to ignore code issues messages. Also they should problaby be shown as warnings, not errors. I made a quick fix for that here:

(defun omnisharp--flycheck-error-parser-raw-json
  (output checker buffer &optional error-level)
  "Takes either a QuickFixResponse or a SyntaxErrorsResponse as a
json string. Returns flycheck errors created based on the locations in
the json."
  (let* ((json-result
          (omnisharp--json-read-from-string output))
         (errors (omnisharp--vector-to-list
                  ;; Support both a SyntaxErrorsResponse and a
                  ;; QuickFixResponse. they are essentially the same,
                  ;; but have the quickfixes (buffer locations) under
                  ;; different property names.
                  (cdr (or (assoc 'QuickFixes json-result)
                           (assoc 'Errors json-result))))))
    (when (not (equal (length errors) 0))
      (mapcar (lambda (it)
                (flycheck-error-new
                 :buffer buffer
                 :checker checker
                 :filename (cdr (assoc 'FileName it))
                 :line (cdr (assoc 'Line it))
                 :column (cdr (assoc 'Column it))
                 ;; A CodeIssues response has Text instead of Message
                 :message (cdr (or (assoc 'Message it)
                                   (assoc 'Text it)))
                 :level (if (equal (cdr (assoc 'LogLevel it)) "Warning")
                            'warning
                          'error)))
              errors))))

Edit: Too many errors reported was a bug on my end.

k-ode avatar Jun 09 '15 09:06 k-ode

Sorry for not replying to this sooner. You can configure the issues/errors that come back here https://github.com/OmniSharp/omnisharp-server/blob/master/OmniSharp/config.json#L28-L31

nosami avatar Jun 09 '15 10:06 nosami

Thanks! Should I close this and create a new issue in omnisharp-server?

k-ode avatar Jun 12 '15 09:06 k-ode

@kimgronqvist No. Well, you could, but it won't get fixed - omnisharp-server is a dead project and is being replaced with omnisharp-roslyn. I don't have time to work on both.

edit: PRs will still be accepted though :)

nosami avatar Jul 20 '15 00:07 nosami