Description
If possible, please provide a reproduction repository you discovered this bug in.
No response
Which area/package is the issue in?
@koliveira15/nx-sonarqube
Description
The determinePaths
function AST parsing query fails to retrieve the lcov reports paths for me, using this example vitest config:
// vitest.config.mts
export default defineConfig({
test: {
coverage: {
provider: "istanbul",
reportsDirectory: "../../coverage/apps/whatever",
},
},
});
This is due to different minor things in the determinePaths function:
- the use of
nodes[0]
assumes thatreportsDirectory
is the first property set intest.coverage
replace(new RegExp(/'/g))
will not escape the value as expected if the value uses other string delimiters than single quotes, such as double quotes.
If applicable, please provide the Nx report
NX Report complete - copy this into the issue template
Node : 22.13.1
OS : darwin-arm64
Native Target : aarch64-macos
pnpm : 10.3.0
nx : 20.4.0
@nx/js : 20.4.0
@nx/jest : 20.4.0
@nx/eslint : 20.4.0
@nx/workspace : 20.4.0
@nx/devkit : 20.4.0
@nx/esbuild : 20.4.0
@nx/eslint-plugin : 20.4.0
@nx/module-federation : 20.4.0
@nx/node : 20.4.0
@nx/react : 20.4.0
@nx/vite : 20.4.0
@nx/web : 20.4.0
typescript : 5.7.3
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/jest/plugin
---------------------------------------
Community plugins:
@koliveira15/nx-sonarqube : 4.2.1
Please provide the exception or error you saw
Included lcov paths: coverage/libs/xxx1"/lcov.info,"istanbul"/lcov.info
[...]
java.lang.IllegalStateException: Property: 'sonar.javascript.lcov.reportPaths' doesn't contain a valid CSV value: 'coverage/libs/xxx1"/lcov.info,"istanbul"/lcov.info'
Other information
Assuming my app depends on a lib called xxx1:
Expected log:
Included lcov paths: coverage/libs/xxx1/lcov.info,apps/[REDACTED]/lcov.info
But instead I can see:
Included lcov paths: coverage/libs/xxx1"/lcov.info,"istanbul"/lcov.info
- The lib xxx1 sets
reportsDirectory
as first property undertest.coverage
--> correct node value, but string contains a trailing double quote delimiter. - the app uses
provider: "istanbul"
as first property undertest.coverage
--> wrong node value, string contains both leading and trailing double quotes delimiters.
I believe this may be related to #111
I also tried a config using backticks as delimiters just out of curiosity and the node is ignored from the query parsing in that case.
I sadly do not know AST parsing well enough to propose a better suited query, but I can create a PR using const node = nodes.find(node => node.parent.getText().includes('reportsDirectory')) || nodes[0]
and adding the double quote delimiter to the regexp.
While not perfect, that would fix my initial issue
I would be willing to submit a PR to fix this issue
- Yes
- No