nvuillam / npm-groovy-lint

Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files using command line
https://nvuillam.github.io/npm-groovy-lint/
MIT License
207 stars 63 forks source link

Cannot read properties of undefined (reading 'filename') #419

Closed pbrisbin closed 2 months ago

pbrisbin commented 2 months ago

I'm getting the error in the title attempting to run npm-groovy-lint --version.

You can reproduce using a node20 docker image with the following:

cat >package.json <<'EOM'
{
  "name": "repro",
  "version": "0.0.0",
  "dependencies": {
    "npm-groovy-lint": "15.0.0"
  }
}
EOM

cat >Dockerfile <<'EOM'
FROM node:20-slim
RUN mkdir -p /app
WORKDIR /app
COPY package.json .
RUN npm install
EOM

docker build --tag repro .
docker run --rm repro ./node_modules/.bin/npm-groovy-lint --version

I get:

Unexpected error: Cannot read properties of undefined (reading 'filename')
TypeError: Cannot read properties of undefined (reading 'filename')
    at JavaCaller.manageJavaInstall (/app/node_modules/java-caller/lib/java-caller.js:278:58)
    at async JavaCaller.run (/app/node_modules/java-caller/lib/java-caller.js:95:13)
    at async CodeNarcCaller.startCodeNarcServer (file:///app/node_modules/npm-groovy-lint/lib/codenarc-caller.js:283:28)
    at async CodeNarcCaller.callCodeNarcServer (file:///app/node_modules/npm-groovy-lint/lib/codenarc-caller.js:94:22)
    at async NpmGroovyLint.callCodeNarc (file:///app/node_modules/npm-groovy-lint/lib/groovy-lint.js:275:32)
    at async NpmGroovyLint.run (file:///app/node_modules/npm-groovy-lint/lib/groovy-lint.js:67:13)
    at async NpmGroovyLint.preProcess (file:///app/node_modules/npm-groovy-lint/lib/groovy-lint.js:223:43)
    at async NpmGroovyLint.run (file:///app/node_modules/npm-groovy-lint/lib/groovy-lint.js:65:27)
    at async file:///app/node_modules/npm-groovy-lint/lib/index.js:12:9

Omitting --version produces the same error. But --help seems to work.

Everything was working fine with v14.6.


For context, I maintain Restyled, which wraps this project as a Restyler. Our CI is failing on the update to v15.

nvuillam commented 2 months ago

@pbrisbin thanks for reporting, i'll have a look tonight :)

nvuillam commented 2 months ago

I succeeded to reproduce the issue on linux (MegaLinter build ^^)

I'll do what i can to fix, as it's probably in node-java-caller package ^^

pbrisbin commented 1 month ago

Thanks!

nvuillam commented 1 month ago

@pbrisbin working well now ? :)

pbrisbin commented 1 month ago

Yup, v15.0.2 passed CI and we updated our Restyler to it.

nvuillam commented 1 month ago

@pbrisbin thanks for your feedback :)

it seems there is still an issue with latest version, maybe make some tests before using it ^^

https://github.com/nvuillam/npm-groovy-lint/issues/422

pbrisbin commented 1 month ago

Ah that's too bad. We do have some tests, that passed. So the issue must be limited in scope.