Troubleshooting CodeScan Self-Hosted

If you can’t find your issue, please post your questions to our Support Team and we’ll do our best to answer.

Compatibility Issues

A lot of issues stem from simply having incompatible versions of CodeScan and SonarQube. Before contacting support, have a quick check against the table below to make sure your versions are compatible.

SonarQube Version 6.7.4 7.0 7.1 7.2 7.3
CodeScan 4.1
CodeScan for Lightning 4.0
CodeScan 4.0 LTS

SonarQube Authentication

If the Anyone group is not granted Execute Analysis permission or if the SonarQube instance is secured (the sonar.forceAuthentication property is set to true), the credentials of a user having been granted Execute Analysis permission have to be provided through the sonar.login and sonar.password properties.

License Errors

Proxy Errors

The most common problem with licensing problems are when your network has a proxy. This can cause licensing problems including:

  • 101: “Couldn’t fetch license for unlicensed project”
  • 104: “Couldn’t fetch license: No response given”

See here for instructions on how to set up CodeScan on a network with a proxy.

Version Errors

Licensing version problems can occur with older versions of CodeScan. When this occurs, you will see the following error:

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

License is not valid:

License is not for this product

Code: 7

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This can be avoided by updating to the latest version of CodeScan.

If this is not an option, contact Support for assistance and we will provide you with the appropriate license version.

Line Count Problems

Licensing problems can occur when you are operating outside the Terms of Service.

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

[License is not valid:

Lines exceed your license (6878 > 1000)

Code: 103

More information: http://www.code-scan.com/troubleshooting/license/

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

This can be avoided by increasing your license limit or reducing the lines of code you are scanning.

Please contact Support for any queries about your license.

Jenkins: java.lang.OutOfMemoryError: Java heap space

This error can be solved by manually adding a parameter to dedicate memory to the build process.

  • In your Jenkins project, click configure.
  • Scroll down to the Build section of the page to the Build Step titled Invoke Ant with the fields:
    • Ant Version: CodeScan Bundled Ant
    • Targets: sonar
  • Click Advanced…
  • In the Java Options field, add the parameter -Xmx2000m. This will assign 2000mb of memory to you build.

java.lang.OutOfMemoryError: GC overhead limit exceeded

This error can be solved by manually adding a parameter to your Ant environment path variable.

In Windows: set ANT_OPTS=%ANT_OPTS% -Xmx2048M

In Linux/OS X: export ANT_OPTS=$ANT_OPTS -Xmx2048M

TLS 1.0 has been disabled in this organization

Salesforce is disabling TLS 1.0: see here

CodeScan connects to Salesforce to download the metadata (ant download) and to run the unit tests. When TLS 1.0 is disabled and your version of Java does not support TLS 1.1, these functionality will fail with an error such as TLS 1.0 has been disabled in this organization. Please use TLS 1.1 or higher when connecting to Salesforce using https..

Depending what version of Java you are running CodeScan/Ant analysis with you may have to make some changes:

Java 8

Works without any modifications. If you do experience any problems please contact support.

Java 7

When using ant, please add the following to your ANT_OPTS environment variable: ANT_OPTS="-Dhttps.protocols=TLSv1.1,TLSv1.2".

Java 6

Java 6 is no longer supported by CodeScan. If you are running an older version of CodeScan that still supports Java 6:

Java 6 (1.6) update 111 and higher: Set environment variable ANT_OPTS="-Dhttps.protocols=TLSv1.1,TLSv1.2" when running the ant command

Java 6 (1.6) before update 111: Does not support TLS 1.0. You can continue to use CodeScan for static analysis only.

Unit tests time out

Timeouts can occur if there are slow or a lot of tests to run. As of CodeScan version 3.5d you can choose to run the tests in two new modes:

  • async - tests are queued and the results polled until completion. Tests are run in batches of 200 classes.
  • history - previous test run results are used. In this mode, test data may be old or non-existent

You can solve timeout problems by changing the Unit Test Timeout setting sf.test.timeout in Administration > Configuration > General Settings > CodeScan to something larger. This parameter’s default setting is one hour (3600 seconds).

Admin operation already in progress

This can occur when running tests in ‘sync’ mode. This happens when a tests requires salesforce.com to temporarily lock your organization’s administration setup. However, the administration setup has already been locked by another change (or a previously incomplete test).

As of CodeScan version 3.5d you can choose to run the tests in two new modes:

  • async - tests are queued and the results polled until completion
  • history - previous test run results are used. In this mode, test data may be old or non-existent

If you choose to continue using ‘synchronous execution’, this information may help

Please wait for the previous action to finish, then try again later. The problem may be related to: https://success.salesforce.com/issues_view?id=a1p3A000000E1YYQA0

The error is intermittent and occurs in developer console or any other tool which uses Salesforce Tooling API.

May also be remedied by enabling and coding correctly for Parallel Test Execution.

  • From Setup, enter Apex Test Execution in the Quick Find box, select Apex Test Execution, then click Options….
  • In the Apex Test Execution Options dialog, deselect Disable Parallel Apex Testing and then click OK.
  • Some testing code may need to be updated. See the Best Practises for Testing section

Best Practices for Testing

Also read: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing_best_practices.htm

Parser Errors

Parser errors (e.g. ERROR error while parsing file) can occur when parsing Apex and VisualForce code. This can occur in various scenarios:

  • You are running an old version of CodeScan: please upgrade
  • Your file is running a very old apiVersion: upgrade the code to a more recent apiVersion. Some things that parse on older versions no longer parse on newer versions of Salesforce, we generally only support fairly new versions of the Salesforce code.
  • Maybe you’ve found a bug: please tell us about it so we can fix it. Please send the full error and the file that it failed on - if you can’t send the whole file please send the line of code it fails on and a few lines above and below for context (the error message mentions the line that the error occurs on).