Instance Scan Linter Check Rhino Error

shalexander
Tera Expert

I'm trying to create a linter check to scan for client scripts on a fresh Australia PDI but am always getting the following Failure.

Rhino error: missing ; before statement

 

I've stripped the linter check script to a barebones version to see if I still get the failure, and I do.

(function (engine) {
	var TABLES_TO_CHECK = ["sys_script_client"];
	if (TABLES_TO_CHECK.indexOf(String(engine.current.getTableName())) == -1) {
		return;
	}

	gs.info(new GlideDateTime().getNumericValue() + " Current script being checked: " + engine.current.getValue("name") + " " + engine.current.sys_id);

})(engine);

 

Is there a way to print a stack trace to see what segment of code is causing this error?

ShinImai_0-1780472655078.png

 

10 REPLIES 10

Mark Roethof
Tera Patron

Just did a copy/past of your code, scan: no error.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Tanushree Maiti
Tera Patron

Hi @shalexander 

 

Can you try this once :

(function (engine) {

              var TABLES_TO_CHECK = "sys_script_client";

              var currentTable = engine.current.getTableName().toString();

              if (TABLES_TO_CHECK.indexOf(currentTable) == -1)

               {                         

                  return;

              }

 

              gs.info(new GlideDateTime().getNumericValue() + " Current script being checked: " + engine.current.getValue('name') + " " + engine.current.sys_id);

 

})(engine);

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

Hi Tanushree,

I tried your code but no luck. Still receiving a rhino error.

 

From my understanding, the AST generated in the lint checker comes directly from rhino, so my assumption is that the lint checker is running into trouble parsing one of the scripts? I just am not able to pinpoint which script that might be because the error message is very vague.

Trying to see if I can print a stack trace of some sorts. Had no luck with wrapping my entire lint checker script in a try catch block either.

 

Thanks!

Hi @shalexander 

 

Can you try 

1. Clear instance cache using cache.do

2.  Test it again in InCognito/InPrivate browser .

 

Check what result you are getting

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

shalexander
Tera Expert

I've exhausted all of my ideas... Not sure if we are able to check which script is causing the rhino error with the tools on-hand because the instantiation of the abstract syntax trees seem very black box-ish.

 

Shamelessly going to tag @Daniel Draes as I have watched one of your instance scan demos on youtube