---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# LinterCheckAstNode - Scoped, Global

# LinterCheckAstNode - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

The LinterCheckAstNode API provides methods for getting abstract
syntax tree (AST) node details in linter checks.

This API is included with the Instance Scan (com.glide.instance_scan) plugin and runs in the `sn_instance_scan` namespace. For more information, see [Instance Scan](https://www.servicenow.com/docs/access?context=hs-landing-page&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).

Use the methods in this class to run linter checks on AST node types by adding code to the Script field in the [Linter Check form](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US). For more information, see [Advanced linter check scripts](https://www.servicenow.com/docs/access?context=hs-linter-check-scripts&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).

Create a linter check to identify any issues in a script. When a linter check is run on a
record, an abstract syntax tree for its code is generated. You can use the abstract syntax
tree to analyze issues with the code.

Access methods in this API using the Instance Scan
engine.rootNode object.

## LinterCheckAstNode - getNameIdentifier() {#ariaid-title2}

Retrieves the string value of a name node type. A name node represents a simple
identifier that is not a keyword, such as a function or variable name.
{#LinterCheckAN-getNameIdentifier__table_ckd_hxt_4pb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#LinterCheckAN-getNameIdentifier__table_ckd_hxt_4pb} {#LinterCheckAN-getNameIdentifier__table_dkd_hxt_4pb__entry__2}

| Type | Description |
|-|-|
| String | If the linter object is a name node type, return the name as a string. Null otherwise. |
[Table 2. Returns]

{#LinterCheckAN-getNameIdentifier__table_dkd_hxt_4pb}  
The following example uses the Findings API [incrementWithNode()](https://servicenow-prod.fluidtopics.net/NSJy3Ubfn~n_WOL~~6KkYQ#Findings-incrementWithNode_O "If the current finding is from a linter check, this method increments the current finding count and simultaneously passes the linter node object to the finding.") method in a linter check. Use this method in the Script field
of the [Linter Check form](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-getNameIdentifier__cBlock-instScan-linter-increment}

## LinterCheckAstNode - getParent() {#ariaid-title3}

Gets the parent node object of the accessed node.
{#LinterCheckAN-getParent__table_ckd_hxt_4pb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 3. Parameters]

{#LinterCheckAN-getParent__table_ckd_hxt_4pb} {#LinterCheckAN-getParent__table_dkd_hxt_4pb__entry__2}

| Type | Description |
|-|-|
| Object | Parent node object of the accessed node. |
[Table 4. Returns]

{#LinterCheckAN-getParent__table_dkd_hxt_4pb}  
The following example uses the Findings API [incrementWithNode()](https://servicenow-prod.fluidtopics.net/NSJy3Ubfn~n_WOL~~6KkYQ#Findings-incrementWithNode_O "If the current finding is from a linter check, this method increments the current finding count and simultaneously passes the linter node object to the finding.") method in a linter check. Use this method in the Script field
of the [Linter Check form](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-getParent__cBlock-instScan-linter-increment}

## LinterCheckAstNode - getTypeName() {#ariaid-title4}

Gets the type of the accessed node.
{#LinterCheckAN-getTypeName__table_ckd_hxt_4pb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 5. Parameters]

{#LinterCheckAN-getTypeName__table_ckd_hxt_4pb} {#LinterCheckAN-getTypeName__table_dkd_hxt_4pb__entry__2}

| Type | Description |
|-|-|
| String | Type name of the accessed node. For example, a function call in the source is tokenized as a node with the type name of `CALL`. |
[Table 6. Returns]

{#LinterCheckAN-getTypeName__table_dkd_hxt_4pb}  
The following example uses the Findings API [incrementWithNode()](https://servicenow-prod.fluidtopics.net/NSJy3Ubfn~n_WOL~~6KkYQ#Findings-incrementWithNode_O "If the current finding is from a linter check, this method increments the current finding count and simultaneously passes the linter node object to the finding.") method in a linter check. Use this method in the Script field
of the [Linter Check form](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-getTypeName__cBlock-instScan-linter-increment}

## LinterCheckAstNode - visit(Function callbackFunction) {#ariaid-title5}

Accesses each node in the subtree starting from this node and executes a given callback
function on each node.
{#LinterCheckAN-visit_F__table_vjz_t4s_spb__entry__3}

| Name | Type | Description |
|-|-|-|
| callbackFunction | Function | Callback function to be executed on each node in the subtree of this node. This callback function takes a node as a parameter which is the node to be visited. |
[Table 7. Parameters]

{#LinterCheckAN-visit_F__table_vjz_t4s_spb} {#LinterCheckAN-visit_F__table_qky_bxs_spb__entry__2}

| Type | Description |
|-|-|
| None |   |
[Table 8. Returns]

{#LinterCheckAN-visit_F__table_qky_bxs_spb}  
The following example uses the Findings API [incrementWithNode()](https://servicenow-prod.fluidtopics.net/NSJy3Ubfn~n_WOL~~6KkYQ#Findings-incrementWithNode_O "If the current finding is from a linter check, this method increments the current finding count and simultaneously passes the linter node object to the finding.") method in a linter check. Use this method in the Script field
of the [Linter Check form](https://www.servicenow.com/docs/access?context=hc-linter-check&version=xanadu&pubname=xanadu-platform-administration&ft:locale=en-US).

    (function(engine) {
      engine.rootNode.visit(function(node) {
        if (node.getTypeName() === "NAME" &&
            node.getNameIdentifier() === "soughtFunction" &&
            node.getParent().getTypeName() === "CALL") {
          engine.finding.incrementWithNode(node);
        } 
      });
    })(engine);

{#LinterCheckAN-visit_F__cBlock-instScan-linter-increment}

