comments_style: Validation of Comments

View source: R/comments_style.R

comments_styleR Documentation

Validation of Comments

Description

Check that comment delimiters and the text of comments, when there is any, are separated by at least one space.

Usage

comments_style(srcData)

Arguments

srcData

a list as returned by getSourceData.

Details

Good coding practices dictate to follow the comment delimiters by at least one space when a comment contains text.

The accepted delimiters are: one or more \# symbols possibly followed immediately by any combination of punctuation characters of the [:punct:] class (see regex).

Value

Boolean. When FALSE, a message indicates the nature of the error and the faulty lines, and the returned value has the following attributes:

lines

faulty line numbers;

message

text of the error message.

Examples

## Keep parse data in non interactive sessions.
if (!interactive())
    op <- options(keep.source = TRUE)

## Correct comments
fil <- tempfile(fileext = ".R")
cat("### foo",
    "##-- bar",
    "##  ",
    "#",
    "#***",
    file = fil, sep = "\n")
comments_style(getSourceData(fil))

## Incorrect comments
fil <- tempfile(fileext = ".R")
cat("###foo",
    "##++bar",
    file = fil, sep = "\n")
comments_style(getSourceData(fil))

roger documentation built on Oct. 24, 2023, 9:07 a.m.

Related to comments_style in roger...