Page MenuHomePhabricator

Script and regex linter could use some examples
Closed, WontfixPublic

Description

In the script and regex linter docs I found

Configure this linter by setting these keys in your configuration:

script-and-regex.script Script command to run. This can be the path to a linter script, but may also include flags or use shell features (see below for examples).
script-and-regex.regex The regex to process output with. This regex uses named capturing groups (detailed below) to interpret output.

but it's not clear to me what configuration that refers to. I thought .arclint, but it seems not:

Got unexpected parameters: script-and-regex.script, script-and-regex.regex

It'd be great if the script-and-regex doc included an example of a full configuration, not just the script and regex key/value pairs in isolation.

Event Timeline

emaste raised the priority of this task from to Needs Triage.
emaste updated the task description. (Show Details)
emaste added a project: Arcanist.
emaste added a subscriber: emaste.
chad triaged this task as Wishlist priority.Nov 26 2014, 10:03 PM
chad added a project: Documentation.

+1 I just encountered the same experience

For reference and the benefit of people Googling how to configure a script and regex linter, here is a full example (using sass-lint):

.arcconfig file:

{
"linters": {
    // snip ...
    "sass": {
          "type": "script-and-regex",
          "include": "(\\.scss$)",
          "script-and-regex.script": "sh -c 'sass-lint -v \"$0\" || true'",
          "script-and-regex.regex": "(^((?P<file>.+): line (?P<line>[0-9]+), col (?P<col>[0-9]+), (?P<severity>[^\\-]*) - (?P<message>.*) \\((?P<name>[a-z\\-]+)\\))$)m"
    }
}

I also encounter issues configuring the script and regex linter.
However, I use regex101 to test my regex, so I know that works.
If I remove the || true exit code workaround, I see that the right commands are issued, with the right stdout, so that works as well.

Putting it all together, I'm always met with [OKAY] No lint warnings..

Is there a way to debug arc lint?
arc lint --trace only prints execution times, not what output it got.

Disclaimer: FWIW, this is on a Windows machine

For reference and the benefit of people Googling how to configure a script and regex linter, here is a full example (using sass-lint):

.arcconfig file:

{
"linters": {
    // snip ...
    "sass": {
          "type": "script-and-regex",
          "include": "(\\.scss$)",
          "script-and-regex.script": "sh -c 'sass-lint -v \"$0\" || true'",
          "script-and-regex.regex": "(^((?P<file>.+): line (?P<line>[0-9]+), col (?P<col>[0-9]+), (?P<severity>[^\\-]*) - (?P<message>.*) \\((?P<name>[a-z\\-]+)\\))$)m"
    }
}

Hi @maccath Should the configuration file in .arclint file or .arconfig file.

I am trying for eslint in arc.

{
  "linters": {
    "javascript": {
      "type": "eslint",
      "include": "(\\.js$)",
      "script-and-regex.script": "sh -c 'eslint ./frontend/app/components/app-rule-engine/**/**.js'",
      "script-and-regex.regex": "(^((?P<file>.+): line (?P<line>[0-9]+), col (?P<col>[0-9]+), (?P<severity>[^\\-]*) - (?P<message>.*) \\((?P<name>[a-z\\-]+)\\))$)m"
    }
  }
}

This is my configuration but i'm still getting errors

Hey guys,

I use checkstyle-7.7-all.jar to check my java code, the output put is like this:

Starting audit...
[WARN] /Users/workspace/DcodeBackend/src/test/java/com/dcode/diffparser/email/JavaMailSenderTest.java:24:16: Local variable name 'ABC' must match pattern '^[a-z]([a-z0-9][a-zA-Z0-9]*)?$'. [LocalVariableName]
[WARN] /Users/workspace/DcodeBackend/src/test/java/com/dcode/diffparser/email/JavaMailSenderTest.java:24:19: WhitespaceAround: '=' is not preceded with whitespace. [WhitespaceAround]
[WARN] /Users/workspace/DcodeBackend/src/test/java/com/dcode/diffparser/email/JavaMailSenderTest.java:24:20: WhitespaceAround: '=' is not followed by whitespace. Empty blocks may only be represented as {} when not part of a multi-block statement (4.1.3) [WhitespaceAround]
Audit done.

can anyone teach me how to write script-and-regex.regex?

I'm having problems with script-and-regex too. I have asked in the community forum but without luck. I’m trying to add phpstan to the arc lint workflow, as explained in the documentation, but I’m unable to capture the error message. Here are my files:

.arclint

…
“phpstan”: {
“type”: “script-and-regex”,
“include”: “(\\.php$)”,
“script-and-regex.script”: “sh -c 'phpstan analyse -l 0 -c var/build/phpstan.neon --no-progress --errorFormat=raw \”$0\" || true’",
“script-and-regex.regex”: “/^(?P<name>):(?P<line>):(?P<message>.*)$/m”
},
…

Example of error message:

$>sh -c ‘phpstan analyse -l 0 -c var/build/phpstan.neon --no-progress --errorFormat=raw “$0” || true’ ‘src/AppBundle/Model/Articulos/ArticuloDocnet.php’

/private/var/www/ws/src/AppBundle/Model/Articulos/ArticuloDocnet.php:36:AppBundle\Model\Articulos\ArticuloDocnet::__construct() does not call parent constructor from Aicrag\Util\Produccion\Articulo.

When I run arc lint it’s always saying no lint warnings. I tried without the || true and it raises an exception.

I tried with the simplest valid regex shown in documentation (/^(?P<message>.*)$/m) and it finds the error in that file, but then all the other files (that doesn’t have any error) make phpstan crash saying memory consumption. I have memory_limit=2G, so I don’t think it’s a memory problem. Maybe the regex with an empty string is failing.

What could be wrong?

epriestley added a subscriber: epriestley.

The community forum is a better place for this discussion. You may or may not receive help there, but we're no longer providing general Phabricator support here in the upstream (nor have we for a long time).

(We'll also have a support product available soon if you'd like to be certain you receive an answer.)