Skip to content

Commit

Permalink
Merge pull request #1583 from flycheck/1556-remove-megacheck
Browse files Browse the repository at this point in the history
Remove deprecated go-megacheck
  • Loading branch information
cpitclaudel committed Jun 12, 2019
2 parents b91ad8a + d6836d5 commit d41d03a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 95 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- Improve detection of default directory for ``haskell-ghc`` to consider
``hpack`` project files [GH-1435]
- Replace ``go tool vet`` with ``go vet`` [GH-1548]
- Remove the deprecated ``go-megacheck`` checker, which is replaced by
``go-staticcheck``.

- New syntax checkers:

Expand Down
17 changes: 1 addition & 16 deletions doc/languages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,7 @@ to view the docstring of the syntax checker. Likewise, you may use
4. `go-build` or `go-test`
5. `go-errcheck`
6. `go-unconvert`
7. `go-megacheck`
8. `go-staticcheck`
7. `go-staticcheck`

.. syntax-checker:: go-gofmt

Expand Down Expand Up @@ -534,20 +533,6 @@ to view the docstring of the syntax checker. Likewise, you may use

.. _unconvert: https://github.com/mdempsky/unconvert

.. syntax-checker:: go-megacheck

Lint code with megacheck_.

.. note::

megacheck_ is officially deprecated; it's recommended to switch to staticcheck_.

.. defcustom:: flycheck-go-megacheck-disabled-checkers

A list of checkers to disable when running megacheck_.

.. _megacheck: https://github.com/dominikh/go-tools

.. syntax-checker:: go-staticcheck

Perform static analysis and code linting with staticcheck_, the successor to megacheck_.
Expand Down
59 changes: 9 additions & 50 deletions flycheck.el
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ attention to case differences."
go-test
go-errcheck
go-unconvert
go-megacheck
go-staticcheck
groovy
haml
Expand Down Expand Up @@ -7938,8 +7937,7 @@ See URL `https://golang.org/cmd/gofmt/'."
(warning . go-build) (warning . go-test)
(warning . go-errcheck)
(warning . go-unconvert)
(warning . go-staticcheck)
(warning . go-megacheck)))
(warning . go-staticcheck)))

(flycheck-define-checker go-golint
"A Go style checker using Golint.
Expand All @@ -7951,7 +7949,7 @@ See URL `https://github.com/golang/lint'."
:modes go-mode
:next-checkers (go-vet
;; Fall back, if go-vet doesn't exist
go-build go-test go-errcheck go-unconvert go-megacheck))
go-build go-test go-errcheck go-unconvert))

(flycheck-def-option-var flycheck-go-vet-print-functions nil go-vet
"A list of print-like functions for `go vet'.
Expand All @@ -7970,19 +7968,6 @@ take an io.Writer as their first argument, like Fprintf,
(string :tag "function"))
:safe #'flycheck-string-list-p)

(flycheck-def-option-var flycheck-go-megacheck-disabled-checkers nil
go-megacheck
"A list of checkers to disable when running `megacheck'.

The value of this variable is a list of strings, where each
string is a checker to be disabled. Valid checkers are `simple',
`staticcheck' and `unused'. When nil, all checkers will be
enabled. "
:type '(set (const :tag "Disable simple" "simple")
(const :tag "Disable staticcheck" "staticcheck")
(const :tag "Disable unused" "unused"))
:safe #'flycheck-string-list-p)

(flycheck-define-checker go-vet
"A Go syntax checker using the `go vet' command.

Expand All @@ -8000,8 +7985,7 @@ See URL `https://golang.org/cmd/go/' and URL
;; Fall back if `go build' or `go test' can be used
go-errcheck
go-unconvert
go-staticcheck
go-megacheck)
go-staticcheck)
:verify (lambda (_)
(let* ((go (flycheck-checker-executable 'go-vet))
(have-vet (member "vet" (ignore-errors
Expand All @@ -8022,8 +8006,7 @@ while syntax checking."
:package-version '(flycheck . "0.25"))

(flycheck-def-option-var flycheck-go-build-tags nil
(go-build go-test go-errcheck
go-megacheck go-staticcheck)
(go-build go-test go-errcheck go-staticcheck)
"A list of tags for `go build'.

Each item is a string with a tag to be given to `go build'."
Expand Down Expand Up @@ -8080,8 +8063,7 @@ Requires Go 1.6 or newer. See URL `https://golang.org/cmd/go'."
(not (string-suffix-p "_test.go" (buffer-file-name)))))
:next-checkers ((warning . go-errcheck)
(warning . go-unconvert)
(warning . go-staticcheck)
(warning . go-megacheck)))
(warning . go-staticcheck)))

(flycheck-define-checker go-test
"A Go syntax and type checker using the `go test' command.
Expand All @@ -8103,8 +8085,7 @@ Requires Go 1.6 or newer. See URL `https://golang.org/cmd/go'."
(string-suffix-p "_test.go" (buffer-file-name))))
:next-checkers ((warning . go-errcheck)
(warning . go-unconvert)
(warning . go-staticcheck)
(warning . go-megacheck)))
(warning . go-staticcheck)))

(flycheck-define-checker go-errcheck
"A Go checker for unchecked errors.
Expand Down Expand Up @@ -8133,8 +8114,7 @@ See URL `https://github.com/kisielk/errcheck'."
:modes go-mode
:predicate (lambda () (flycheck-buffer-saved-p))
:next-checkers ((warning . go-unconvert)
(warning . go-staticcheck)
(warning . go-megacheck)))
(warning . go-staticcheck)))

(flycheck-define-checker go-unconvert
"A Go checker looking for unnecessary type conversions.
Expand All @@ -8144,32 +8124,11 @@ See URL `https://github.com/mdempsky/unconvert'."
:error-patterns
((warning line-start (file-name) ":" line ":" column ": " (message) line-end))
:modes go-mode
:predicate (lambda () (flycheck-buffer-saved-p))
:next-checkers ((warning . go-megacheck)))

(flycheck-define-checker go-megacheck
"A Go checker that performs static analysis and linting using the `megacheck'
command.

Requires Go 1.6 or newer. See URL
`https://github.com/dominikh/go-tools'."
:command ("megacheck"
(option-list "-tags=" flycheck-go-build-tags concat)
(eval (mapcar (lambda (checker) (concat "-" checker
".enabled=false"))
flycheck-go-megacheck-disabled-checkers))
;; Run in current directory to make megacheck aware of symbols
;; declared in other files.
".")
:error-patterns
((warning line-start (file-name) ":" line ":" column ": " (message) line-end))
:modes go-mode)
:predicate (lambda () (flycheck-buffer-saved-p)))

(flycheck-define-checker go-staticcheck
"A Go checker that performs static analysis and linting using
the `staticcheck' command. `staticcheck' is the successor to
`megacheck'; while the latter isn't fully deprecated yet, it's
recommended to migrate to `staticcheck'.
the `staticcheck' command.

`staticcheck' is explicitly fully compatible with \"the last two
versions of go\". `staticheck' can target earlier versions (with
Expand Down
34 changes: 5 additions & 29 deletions test/flycheck-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -3379,7 +3379,7 @@ See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
:checker go-build)))))

(flycheck-ert-def-checker-test go-build go directory-with-two-packages
(let ((flycheck-disabled-checkers '(go-errcheck go-unconvert go-megacheck go-staticcheck)))
(let ((flycheck-disabled-checkers '(go-errcheck go-unconvert go-staticcheck)))
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "checkers/go")))
(flycheck-ert-should-syntax-check
Expand Down Expand Up @@ -3417,32 +3417,6 @@ See https://github.com/flycheck/flycheck/issues/531 and Emacs bug #19206"))
'(7 17 warning "unnecessary conversion"
:checker go-unconvert))))

(flycheck-ert-def-checker-test go-megacheck go nil
:tags '(language-go external-tool)
(let ((flycheck-disabled-checkers '(go-golint go-staticcheck)))
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
(flycheck-ert-should-syntax-check
"language/go/src/megacheck/megacheck1.go" 'go-mode
'(8 6 warning "should omit values from range; this loop is equivalent to `for range ...` (S1005)"
:checker go-megacheck)
'(12 21 warning "calling strings.Replace with n == 0 will return no results, did you mean -1? (SA1018)"
:checker go-megacheck)
'(16 6 warning "func unused is unused (U1000)"
:checker go-megacheck)))))

(flycheck-ert-def-checker-test go-megacheck-disabled-checkers go nil
:tags '(language-go external-tool)
(let ((flycheck-disabled-checkers '(go-golint)))
(flycheck-ert-with-env
`(("GOPATH" . ,(flycheck-ert-resource-filename "language/go")))
;; Run with simple and unused checkers disabled
(let ((flycheck-go-megacheck-disabled-checkers '("simple" "unused")))
(flycheck-ert-should-syntax-check
"language/go/src/megacheck/megacheck1.go" 'go-mode
'(12 21 warning "calling strings.Replace with n == 0 will return no results, did you mean -1? (SA1018)"
:checker go-megacheck))))))

(flycheck-ert-def-checker-test go-staticcheck go nil
:tags '(language-go external-tool)
(let ((flycheck-disabled-checkers '(go-golint go-unconvert)))
Expand Down Expand Up @@ -4168,10 +4142,10 @@ Why not:
(flycheck-ert-def-checker-test ruby-rubocop ruby syntax-error
(flycheck-ert-should-syntax-check
"language/ruby/syntax-error.rb" 'ruby-mode
'(5 7 error "unexpected token tCONSTANT (Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)"
'(5 7 error "unexpected token tCONSTANT (Using Ruby 2.3 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)"
:id "Lint/Syntax"
:checker ruby-rubocop)
'(5 24 error "unterminated string meets end of file (Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)"
'(5 24 error "unterminated string meets end of file (Using Ruby 2.3 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)"
:id "Lint/Syntax"
:checker ruby-rubocop)))

Expand Down Expand Up @@ -4199,6 +4173,8 @@ Why not:
(flycheck-ert-def-checker-test (ruby-rubocop ruby-reek ruby-rubylint) ruby with-rubylint
(flycheck-ert-should-syntax-check
"language/ruby/warnings.rb" 'ruby-mode
'(1 1 info "Missing magic comment `# frozen_string_literal: true`."
:id "Style/FrozenStringLiteralComment" :checker ruby-rubocop)
'(3 nil warning "Person assumes too much for instance variable '@name'"
:id "InstanceVariableAssumption" :checker ruby-reek)
'(3 1 info "Missing top-level class documentation comment."
Expand Down

0 comments on commit d41d03a

Please sign in to comment.