File: test-php.el

package info (click to toggle)
flycheck 35.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,344 kB
  • sloc: lisp: 16,730; python: 739; makefile: 243; cpp: 24; ruby: 23; perl: 21; ada: 17; f90: 16; javascript: 15; haskell: 15; erlang: 14; xml: 14; ansic: 12; sh: 10; php: 9; tcl: 8; fortran: 3; vhdl: 2; awk: 1; sql: 1
file content (77 lines) | stat: -rw-r--r-- 3,408 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; test-php.el --- Flycheck Specs: PHP      -*- lexical-binding: t; -*-

;; Copyright (C) 2016 Sebastian Wiesner and Flycheck contributors

;; 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 <http://www.gnu.org/licenses/>.

;;; Commentary:

;; Specs for PHP support.

;;; Code:

(require 'flycheck-buttercup)

(describe "Language PHP"
  (describe "The PHDMD error parser"
    (it "parses PHPMD XML output"

      (let ((phpmd-xml  "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<pmd version=\"1.5.0\" timestamp=\"2014-12-02T18:13:44+00:00\">
  <file name=\"foo.php\">
    <violation beginline=\"21\" endline=\"21\" rule=\"UnusedPrivateField\"
      ruleset=\"Unused Code Rules\"
      externalInfoUrl=\"http://phpmd.org/rules/unusedcode.html#unusedprivatefield\"
      priority=\"3\">
        Avoid unused private fields such as '$FOO'.
    </violation>
    <violation beginline=\"24\" endline=\"27\" rule=\"UnusedPrivateMethod\"
      ruleset=\"Unused Code Rules\" package=\"Flycheck\"
      externalInfoUrl=\"http://phpmd.org/rules/unusedcode.html#unusedprivatemethod\"
      class=\"A\" method=\"bar\" priority=\"3\">
        Avoid unused private methods such as 'bar'.
    </violation>
    <violation beginline=\"24\" endline=\"24\" rule=\"UnusedFormalParameter\"
      ruleset=\"Unused Code Rules\"
      externalInfoUrl=\"http://phpmd.org/rules/unusedcode.html#unusedformalparameter\"
      priority=\"3\">
        Avoid unused parameters such as '$baz'.
    </violation>
  </file>
</pmd>"))
        (expect (flycheck-parse-phpmd phpmd-xml 'checker 'buffer)
                :to-be-equal-flycheck-errors
                (list
                 (flycheck-error-new-at 21 nil 'warning
                                        "Avoid unused private fields such as '$FOO'."
                                        :id "UnusedPrivateField"
                                        :checker 'checker
                                        :buffer 'buffer
                                        :filename "foo.php")
                 (flycheck-error-new-at 24 nil 'warning
                                        "Avoid unused private methods such as 'bar'."
                                        :id "UnusedPrivateMethod"
                                        :checker 'checker
                                        :buffer 'buffer
                                        :filename "foo.php")
                 (flycheck-error-new-at 24 nil 'warning
                                        "Avoid unused parameters such as '$baz'."
                                        :id "UnusedFormalParameter"
                                        :checker 'checker
                                        :buffer 'buffer
                                        :filename "foo.php")))))))

;;; test-php.el ends here