Closed jhildenbiddle closed 1 year ago
Internal ticket created : CY-6271
Ping @franciscodua since this seems very similar to #61. Thanks!
Hi there,
Thanks for reaching out!
You can use the file extensions feature to configure the accepted extensions for Javascript language.
Let me know if this helps.
Stefan
Thanks @stefanvacareanu7.
TLDR: PMD breaks with .cjs
files.
Details...
The project I was working on is now live, so for context:
The tooltip on the web UI states that only .js
, .jsx
, .jsm
, .vue
, and .mjs
are supported:
Without adding the extension, the log for the latest commit analysis shows the following error:
If I add .cjs
to the file extensions section as instructed, the logs show a different error:
Error on file src/index.cjs:1. Cause: PMDException: Error while parsing /src/src/index.cjs
Error on file src/util.cjs:1. Cause: PMDException: Error while parsing /src/src/util.cjs
Error on file tests/index.test.js:1. Cause: PMDException: Error while processing /src/tests/index.test.js
Since PMD is failing, I disabled this tool and all tests now pass as expected. I can live without PMD, but it would be nice if this tool worked as well since I'm using it to analyze other repos.
Also, while I'm happy to find a workaround for analyzing .cjs
files with Codacy, both .mjs
and .cjs
are widely-used extensions within the Node ecosystem so supporting one by default without the other feels like a miss. Just my $0.02.
Hello,
We already bumped PMD to the latest stable version and we tested already .cjs files with success.
Feel free to make more tests and let us know.
Kind regards, David Marinho
Similar to #61.
I recently ran into an issue using Codacy Coverage Reporter GitHub Action where codacy-coverage-reporter was failing with a "Can't guess the report language" error. I use Codacy on several projects and had not experienced this before. Here are the relevant parts of the log:
I eventually realized that the difference between this project and previous projects is the use of
.cjs
instead of.js
as the file extension for my source files. This was done to differentiate between CommonJS modules (.cjs
), ES modules (.mjs
), and standard Javascript files (.js
). I was able to resolve the coverage reporter issue by forcing the language to "Javascript":This allowed codacy-coverage-reporter to complete without error, but none of the
.cjs
files were processed by Codacy despite the coverage report containing information for them.Looking at the source linked in the docs, it appears that at least part of the issue is the missing
.cjs
association inLanguage.scala
:https://github.com/codacy/codacy-plugins-api/blob/master/src/main/scala/com/codacy/plugins/api/languages/Language.scala#L102
Hopefully a small update there can resolve the issue, but I know it's rarely that easy. :)