Description

This page describes issues observed when analyzing JS file:

JS methods are not created when they should be (since they are present in the source code).

Observed in CAST Extension
Release
Yes/No
1.7(error)
1.6(error)
1.5(tick)
1.4(tick)
1.3(tick)
1.2(tick)
1.1(tick)
1.0(tick)


*Observed on RDBMS
RDBMS
Yes/No
Oracle Server(tick)
Microsoft SQL Server(error)
CSS2(tick)
CSS3(tick)
Step by Step Scenario
  1. Manage HTML/Javascript extension in Servman.
  2. Create a user defined UA for java script
  3. Run the analysis on javascript source code.
Impact on Analysis Results and Dashboard

When getting this issue, the missing objects are not displayed in the dashboard.

Solution
  1. This problem occurs when parameters of a function contain {}, which is new in javascript 6. 
        Example : 

    export function testMethod(Name, page = 1, queryParams = {})
    {
     const params = new URLSearchParams(qs.stringify({
     page: page,
     count: RESULTS,
     ...queryParams
     }));
    return {
     Name,
     params: params,
     }, },};
    }

    The parser thinks that the first "{" is the beginning of function block and no method gets created as an object.

    when you have "= {}" or ""={}" (space or no space after =) in function definition parameters, as in "function funcName( a = {} )

    { ... }

    1. Workaround is to remove "= {}" or replace by ""= []" by taking help using an file editor, like notepad++. The updated source code snippet will be as  shown below (this is done in the deployment folder):

      export function testMethod(Name, page = 1, queryParams = [])
      {
       const params = new URLSearchParams(qs.stringify({
       page: page,
       count: RESULTS,
       ...queryParams
       }));
      return {
       Name,
       params: params,
       }, },};
      }
    2. After changing save the files and
    3. Run the analysis, you will have JavaScript method saved in the KB.
  2. If you are using com.castsoftware.html5 extension lower than 2.0.0 funcrel then you may encounter the issue whereby JS function is not created when you have async/await keyword in the JS file. These keyword were not supported and hence it lead to the non creation of JS function object.
    1. So you need to remove "async" string from JS file.
    2. Save the file.

    3. Run the analysis. You will have JS function object saved in KB. 

This issue has been fixed in HTML5 2.0.0 funcrel.

Notes/comments

Ticket # 9735, 13928

Related Pages