neiam
/action-setup-beam
action-setup-beam
public · Issues · Pulls · Labels · Forks · Compare · Actions queued
⭐
Log in to mark this repository.
Add Elixir/credo and Elixir/dialyzer problem matchers (#65)
4fbbcf2 · Blake Kostner · 2021-07-27 21:43
Files changed
modified
.github/elixir-matchers.json
+32
−0
@@ -41,6 +41,38 @@
| 41 | 41 | "line": 2 |
| 42 | 42 | } |
| 43 | 43 | ] |
| 44 | + }, | |
| 45 | + { | |
| 46 | + "owner": "elixir-credoOutputDefault", | |
| 47 | + "severity": "warning", | |
| 48 | + "pattern": [ | |
| 49 | + { | |
| 50 | + "regexp": "^\u2503\\s\\[\\w\\]\\s[\u2191|\u2197|\u2192|\u2198|\u2193]\\s(.*)$", | |
| 51 | + "message": 1 | |
| 52 | + }, | |
| 53 | + { | |
| 54 | + "regexp": "^\u2503\\s{7}(.*):(\\d+):(\\d+)\\s.*$", | |
| 55 | + "file": 1, | |
| 56 | + "line": 2, | |
| 57 | + "column": 3 | |
| 58 | + } | |
| 59 | + ] | |
| 60 | + }, | |
| 61 | + { | |
| 62 | + "owner": "elixir-dialyzerOutputDefault", | |
| 63 | + "severity": "warning", | |
| 64 | + "pattern": [ | |
| 65 | + { | |
| 66 | + "regexp": "^(.*):(\\d+):(.*)", | |
| 67 | + "file": 1, | |
| 68 | + "line": 2, | |
| 69 | + "code": 3 | |
| 70 | + }, | |
| 71 | + { | |
| 72 | + "regexp": "^(.*)$", | |
| 73 | + "message": 1 | |
| 74 | + } | |
| 75 | + ] | |
| 44 | 76 | } |
| 45 | 77 | ] |
| 46 | 78 | } |
modified
__tests__/problem-matchers.test.js
+37
−0
@@ -5,6 +5,8 @@ async function all() {
| 5 | 5 | await testElixirMixCompileError() |
| 6 | 6 | await testElixirMixCompileWarning() |
| 7 | 7 | await testElixirMixTestFailure() |
| 8 | + await testElixirCredoOutputDefault() | |
| 9 | + await testElixirDialyzerOutputDefault() | |
| 8 | 10 | } |
| 9 | 11 | |
| 10 | 12 | async function testElixirMixCompileError() { |
@@ -55,6 +57,41 @@ async function testElixirMixTestFailure() {
| 55 | 57 | assert.equal(line, '9') |
| 56 | 58 | } |
| 57 | 59 | |
| 60 | +async function testElixirCredoOutputDefault() { | |
| 61 | + const [messagePattern, filePattern] = problemMatcher.find( | |
| 62 | + ({ owner }) => owner === 'elixir-credoOutputDefault', | |
| 63 | + ).pattern | |
| 64 | + | |
| 65 | + const firstOutput = '┃ [F] → Function is too complex (CC is 29, max is 9).' | |
| 66 | + const secondOutput = '┃ lib/test.ex:15:7 #(Test.hello)' | |
| 67 | + | |
| 68 | + const [, message] = firstOutput.match(messagePattern.regexp) | |
| 69 | + assert.equal(message, 'Function is too complex (CC is 29, max is 9).') | |
| 70 | + | |
| 71 | + const [, file, line, column] = secondOutput.match(filePattern.regexp) | |
| 72 | + assert.equal(file, 'lib/test.ex') | |
| 73 | + assert.equal(line, '15') | |
| 74 | + assert.equal(column, '7') | |
| 75 | +} | |
| 76 | + | |
| 77 | +async function testElixirDialyzerOutputDefault() { | |
| 78 | + const [messagePattern, filePattern] = problemMatcher.find( | |
| 79 | + ({ owner }) => owner === 'elixir-dialyzerOutputDefault', | |
| 80 | + ).pattern | |
| 81 | + | |
| 82 | + const firstOutput = 'lib/test.ex:15:invalid_contract' | |
| 83 | + const secondOutput = | |
| 84 | + 'The @spec for the function does not match the success typing of the function.' | |
| 85 | + | |
| 86 | + const [, file, line, code] = firstOutput.match(messagePattern.regexp) | |
| 87 | + assert.equal(file, 'lib/test.ex') | |
| 88 | + assert.equal(line, '15') | |
| 89 | + assert.equal(code, 'invalid_contract') | |
| 90 | + | |
| 91 | + const [, message] = secondOutput.match(filePattern.regexp) | |
| 92 | + assert.equal(message, secondOutput) | |
| 93 | +} | |
| 94 | + | |
| 58 | 95 | all() |
| 59 | 96 | .then(() => process.exit(0)) |
| 60 | 97 | .catch((err) => { |
modified
dist/.github/elixir-matchers.json
+32
−0
@@ -41,6 +41,38 @@
| 41 | 41 | "line": 2 |
| 42 | 42 | } |
| 43 | 43 | ] |
| 44 | + }, | |
| 45 | + { | |
| 46 | + "owner": "elixir-credoOutputDefault", | |
| 47 | + "severity": "warning", | |
| 48 | + "pattern": [ | |
| 49 | + { | |
| 50 | + "regexp": "^\u2503\\s\\[\\w\\]\\s[\u2191|\u2197|\u2192|\u2198|\u2193]\\s(.*)$", | |
| 51 | + "message": 1 | |
| 52 | + }, | |
| 53 | + { | |
| 54 | + "regexp": "^\u2503\\s{7}(.*):(\\d+):(\\d+)\\s.*$", | |
| 55 | + "file": 1, | |
| 56 | + "line": 2, | |
| 57 | + "column": 3 | |
| 58 | + } | |
| 59 | + ] | |
| 60 | + }, | |
| 61 | + { | |
| 62 | + "owner": "elixir-dialyzerOutputDefault", | |
| 63 | + "severity": "warning", | |
| 64 | + "pattern": [ | |
| 65 | + { | |
| 66 | + "regexp": "^(.*):(\\d+):(.*)", | |
| 67 | + "file": 1, | |
| 68 | + "line": 2, | |
| 69 | + "code": 3 | |
| 70 | + }, | |
| 71 | + { | |
| 72 | + "regexp": "^(.*)$", | |
| 73 | + "message": 1 | |
| 74 | + } | |
| 75 | + ] | |
| 44 | 76 | } |
| 45 | 77 | ] |
| 46 | 78 | } |
Parents: bae9638