get_code_lints: Extract lints from code

View source: R/03b_doubleSpaceLinter.R View source: R/03a_additionalLinters.R

get_code_lintsR Documentation

Extract lints from code

Description

The function logic is to compare locations of nodes in the same 'line1' value, which stands for the line number of a node in a Script. A node in code can be, for example, a comma, an assignment arrow or a number. F.e., consider these three nodes: "(", "," and ")". If the first node ends at position "4" and the second node starts at a position larger than "7", we have at least a double space in between (position 5 + 6). The second node 'i+1' (the right part of a double space) is directly converted into a lint list.

The function logic is to compare locations of nodes in the same 'line1' value, which stands for the line number of a node in a Script. A node in code can be, for example, a comma, an assignment arrow or a number. F.e., consider these three nodes: "(", "," and ")". If the first node ends at position "4" and the second node starts at a position larger than "7", we have at least a double space in between (position 5 + 6). The second node 'i+1' (the right part of a double space) is directly converted into a lint list.

Usage

get_code_lints(unique_lines, code_nodes, source_expression)

get_code_lints(unique_lines, code_nodes, source_expression)

Arguments

unique_lines

A vector of line numbers for each instance of written code

code_nodes

Node list extracted with the XPath for code

source_expression

Contains the XML parsed content. Needed for transforming nodes to lints

Value

List of lints containing invalid double spaces

List of lints containing invalid double spaces


INWT/INWTUtils documentation built on May 22, 2024, 4:45 p.m.