gpt4 book ai didi

node.js - 对我的代码运行 Sonar 库分析时出现 NullPointerException

转载 作者:太空宇宙 更新时间:2023-11-04 00:46:08 25 4
gpt4 key购买 nike

我有一项 Jenkins 工作,将单元测试覆盖率(lcov 格式)发布到 SonarQube 服务器,如 question 中所述。及其答案。有时,我会在 Jenkins 控制台日志中的 node_modules 目录中看到以下 JavaScript 文件异常。

16:57:15.037 ERROR - Problem while calculating coverage for /var/lib/jenkins/jobs/jenkins-project-name/workspace/project-name/node_modules/js-tokens/test/fixtures/regex.js
java.lang.NullPointerException: null
at org.sonar.plugins.javascript.lcov.UTCoverageSensor.saveZeroValueForResource(UTCoverageSensor.java:146) [sonar-javascript-plugin-2.9.jar:na]
at org.sonar.plugins.javascript.lcov.UTCoverageSensor.saveMeasureFromLCOVFile(UTCoverageSensor.java:128) [sonar-javascript-plugin-2.9.jar:na]
at org.sonar.plugins.javascript.lcov.UTCoverageSensor.analyse(UTCoverageSensor.java:85) [sonar-javascript-plugin-2.9.jar:na]
at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:58) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:50) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.phases.PhaseExecutor.execute(PhaseExecutor.java:98) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:192) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:258) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:253) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:243) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:100) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:85) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.bootstrap.GlobalContainer.executeAnalysis(GlobalContainer.java:153) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:110) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:76) [sonar-batch-shaded-5.2.jar:na]
at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48) [sonar-runner-batch8900787800742033772.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_79]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_79]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_79]
at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_79]
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75) [sonar-runner-dist-2.4.jar:na]
at java.security.AccessController.doPrivileged(Native Method) [na:1.7.0_79]
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.api.Runner.execute(Runner.java:100) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.Main.executeTask(Main.java:70) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.Main.execute(Main.java:59) [sonar-runner-dist-2.4.jar:na]
at org.sonar.runner.Main.main(Main.java:53) [sonar-runner-dist-2.4.jar:na]

我将 node_modules 目录添加到排除列表中:

sonar.exclusions=./project-name/node_modules/**/*
sonar.test.exclusions=./project-name/node_modules/**/*

但有时我仍然会遇到错误。知道出了什么问题吗?

最佳答案

看来您的情况类似于 known issue这将在 JavaScript 插件的 2.10 版本中修复。此版本应在未来几天内发布。

作为一种解决方法,按照您的方式设置排除项应该可行。如果您仍然遇到相同的错误,我认为 SonarQube 未正确解析您提供的路径:您可以尝试删除开头的 ./

关于node.js - 对我的代码运行 Sonar 库分析时出现 NullPointerException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34644702/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com