forcedotcom / sfdx-scanner

MIT License
217 stars 50 forks source link

[BUG] ERROR running scanner:run: Cannot read properties of undefined (reading 'getInstance') #891

Closed MarkusF-sub closed 1 year ago

MarkusF-sub commented 2 years ago

Describe the bug I have installed the Code Analyser and tried to run it on several SFDX projects and with different targets (even for single class files).

In each case the scan failed with the same error message: ERROR running scanner:run: Cannot read properties of undefined (reading 'getInstance')

To Reproduce % sfdx scanner:run -t "./force-app" --verbose
WARNING: We're continually improving Salesforce Code Analyzer. Tell us what you think! Give feedback at https://research.net/r/SalesforceCA Cataloger: XML files collected from JAR [/Users/markus/.local/share/sfdx/node_modules/@salesforce/sfdx-scanner/dist/pmd/lib/pmd-visualforce-6.50.0.jar]: [category/vf/bestpractices.xml, category/vf/codestyle.xml, category/vf/design.xml, category/vf/documentation.xml, category/vf/errorprone.xml, category/vf/multithreading.xml, category/vf/performance.xml, category/vf/security.xml, rulesets/vf/security.xml, META-INF/maven/net.sourceforge.pmd/pmd-visualforce/pom.xml] WARNING: Cataloger: Dropping XML file [META-INF/maven/net.sourceforge.pmd/pmd-visualforce/pom.xml] since its path does not conform to Rulesets or Category. Cataloger: XML files collected from JAR [/Users/markus/.local/share/sfdx/node_modules/@salesforce/sfdx-scanner/dist/pmd/lib/pmd-apex-6.50.0.jar]: [category/apex/bestpractices.xml, category/apex/codestyle.xml, category/apex/design.xml, category/apex/documentation.xml, category/apex/errorprone.xml, category/apex/multithreading.xml, category/apex/performance.xml, category/apex/security.xml, rulesets/apex/apexunit.xml, rulesets/apex/braces.xml, rulesets/apex/complexity.xml, rulesets/apex/empty.xml, rulesets/apex/metrics.xml, rulesets/apex/performance.xml, rulesets/apex/quickstart.xml, rulesets/apex/ruleset.xml, rulesets/apex/security.xml, rulesets/apex/style.xml, META-INF/maven/net.sourceforge.pmd/pmd-apex/pom.xml] WARNING: Cataloger: Dropping XML file [META-INF/maven/net.sourceforge.pmd/pmd-apex/pom.xml] since its path does not conform to Rulesets or Category. Implicitly including pmd rules from category 'Design' Implicitly including pmd rules from category 'Multithreading' Implicitly including pmd rules from category 'Documentation' Implicitly including pmd rules from category 'Best Practices' Implicitly including pmd rules from category 'Security' Implicitly including pmd rules from category 'Code Style' Implicitly including pmd rules from category 'Performance' Implicitly including pmd rules from category 'Error Prone' Implicitly including eslint rules from category 'suggestion' Implicitly including eslint rules from category 'layout' Implicitly including eslint rules from category 'problem' Implicitly including eslint-typescript rules from category 'suggestion' Implicitly including eslint-typescript rules from category 'layout' Implicitly including eslint-typescript rules from category 'problem' Implicitly including retire-js rules from category 'Insecure Dependencies' ERROR running scanner:run: Cannot read properties of undefined (reading 'getInstance')

Expected behavior The scanner runs without failure and creates an output.

Screenshots

Desktop (please complete the following information):

Additional context %java --version openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

% npm --version 6.14.11

% sfdx version --verbose CLI Version: sfdx-cli/7.177.1

Architecture: darwin-x64

Node Version: node-v18.12.0

Plugin Version: @oclif/plugin-autocomplete 1.3.5 (core) @oclif/plugin-commands 2.2.1 (core) @oclif/plugin-help 5.1.18 (core) @oclif/plugin-not-found 2.3.8 (core) @oclif/plugin-plugins 2.1.6 (core) @oclif/plugin-update 3.0.6 (core) @oclif/plugin-version 1.1.3 (core) @oclif/plugin-warn-if-update-available 2.0.13 (core) @oclif/plugin-which 2.2.0 (core) alias 2.1.8 (core) apex 1.3.0 (core) auth 2.2.21 (core) community 2.0.15 (core) config 1.4.22 (core) custom-metadata 2.0.4 (core) data 2.1.10 (core) generator 2.0.10 (core) info 2.2.7 (core) limits 2.0.11 (core) org 2.2.12 (core) packaging 1.10.6 (core) schema 2.1.13 (core) signups 1.2.12 (core) source 2.3.4 (core) telemetry 2.0.3 (core) templates 55.1.0 (core) trust 2.1.0 (core) user 2.1.17 (core) @salesforce/sfdx-diff 0.0.6 (user) @salesforce/sfdx-plugin-lwc-test 1.0.1 (core) @salesforce/sfdx-scanner 3.6.2 (user) dependencies-cli 2.0.1 (user) mo-dx-plugin 0.3.2 (user) salesforce-alm 54.8.3 (core)

OS and Version: Darwin 21.6.0

Shell: zsh

Root Path: /Users/markus/.local/share/sfdx/client/7.177.1-617a284

"Workaround": I did not found a workaround so far

"Urgency": Not business-stopping, but blocks me from trying the Code Analyzer

git2gus[bot] commented 2 years ago

This issue has been linked to a new work item: W-12113642

rmohan20 commented 2 years ago

Hi @MarkusF-sub - thanks for letting us know.

Could you share your log file so that we can get a stacktrace to investigate further?

Here are the steps:

  1. Remove the existing log file:
    rm ~/.sfdx/sfdx.log
  2. Rerun the same scanner:run command you've mentioned in the description.
  3. Upload ~/.sfdx/sfdx.log as an attachment to your comment.
MarkusF-sub commented 2 years ago

Hi @rmohan20 this is the logfile

sfdx.log

jfeingold35 commented 1 year ago

@MarkusF-sub , we believe that the new release, v3.7.1, should fix this issue. If possible, could you update to that release and let us know? Thanks!

MarkusF-sub commented 1 year ago

@jfeingold35 Yes, it works now with the new release. Thanks a lot!

jfeingold35 commented 1 year ago

Resolved by PR #896 , released in 3.7.1.