nvuillam/npm-groovy-lint

--noserver does not honor --parse

tbroyer opened this issue · 5 comments

Tracking differences between using --noserver or not (see #290), I stumbled on another difference: a file with a parse error will be seen as OK with --noserver, whereas it will fail without.

Fwiw, the reason for using --noserver is that I'm using npm-groovy-lint through Docker (on CI, but also locally), so starting a server for a one-shot analysis seemed unnecessary.
Given that --noserver is also used as a fallback for when the server codepath fails, I expect it to behave the same.

$ alias insidedocker
alias insidedocker='docker run --rm -it -u $(id -u):$(id -g) -v "$PWD:$PWD" -w "$PWD"'
$ insidedocker nvuillam/npm-groovy-lint:11.1.1 vars/utils.groovy
***REDACTED***/vars/utils.groovy
  17    error    Unexpected input: '***REDACTED***' @ line 17, column 1.  NglParseError


npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      1      │
│    1    │ 'Warning' │      0      │
│    2    │  'Info'   │      0      │
└─────────┴───────────┴─────────────┘
Failure: 1 error(s) have been found
 0 warning(s) have been found
 0 info(s) have been found
$ insidedocker nvuillam/npm-groovy-lint:11.1.1 --noserver dummy vars/utils.groovy dummy

npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      0      │
│    1    │ 'Warning' │      0      │
│    2    │  'Info'   │      0      │
└─────────┴───────────┴─────────────┘

(using version 11.1.1 here due to #319)

@tbroyer please can you check with v13.0.0 ? :)

Nope, no change with 13.0.0:

$ alias insidedocker
alias insidedocker='docker run --rm -it -u $(id -u):$(id -g) -v "$PWD:$PWD" -w "$PWD"'
$ insidedocker nvuillam/npm-groovy-lint:v13.0.0 vars/utils.groovy
***REDACTED***/vars/utils.groovy
  56    error    Unexpected input: '***REDACTED***' @ line 56, column 1.  NglParseError           


npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      1      │
│    1    │ 'Warning' │      0      │
│    2    │  'Info'   │      0      │
└─────────┴───────────┴─────────────┘
Failure: 1 error(s) have been found 
 0 warning(s) have been found 
 0 info(s) have been found
$ insidedocker nvuillam/npm-groovy-lint:v13.0.0 --noserver vars/utils.groovy

npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      0      │
│    1    │ 'Warning' │      0      │
│    2    │  'Info'   │      0      │
└─────────┴───────────┴─────────────┘

Parsing is done within the CodeNarc server... and with --noserver we directly call CodeNarc... it's possible than --noserver makes that limitation , we should update the doc :/

I wouldn't expect it to differ, do you have an example you can share to test locally?

Sure, using the WithParseError.groovy from lib/examples (here):

$ alias insidedocker
alias insidedocker='docker run --rm -it -u $(id -u):$(id -g) -v "$PWD:$PWD" -w "$PWD"'
$ insidedocker nvuillam/npm-groovy-lint:v14.0.0 WithParseError.groovy 
***REDACTED***/WithParseError.groovy
  3     error    Unexpected input: '\n' @ line 3, column 20.  NglParseError           
  5     info     Static imports should appear before normal imports  MisorderedStaticImports 
  43    warning  The line exceeds 120 characters. The line is 133 characters.  LineLength              


npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      1      │
│    1    │ 'Warning' │      1      │
│    2    │  'Info'   │      1      │
└─────────┴───────────┴─────────────┘
Failure: 1 error(s) have been found 
 1 warning(s) have been found 
 1 info(s) have been found
$ insidedocker nvuillam/npm-groovy-lint:v14.0.0 --noserver WithParseError.groovy 
***REDACTED***/WithParseError.groovy
  5     info     Static imports should appear before normal imports  MisorderedStaticImports 
  43    warning  The line exceeds 120 characters. The line is 133 characters.  LineLength              


npm-groovy-lint results in 1 linted files:
┌─────────┬───────────┬─────────────┐
│ (index) │ Severity  │ Total found │
├─────────┼───────────┼─────────────┤
│    0    │  'Error'  │      0      │
│    1    │ 'Warning' │      1      │
│    2    │  'Info'   │      1      │
└─────────┴───────────┴─────────────┘
Failure: 0 error(s) have been found 
 1 warning(s) have been found 
 1 info(s) have been found