这可能有些愚蠢,但我不认为我在Rstudio (0.99.486)中正确设置了lintr。我在Preferences > Code > Diagnostics中有所有选项,并将lintr加载到项目的工作区中。但是,当我运行诊断时,我没有收到语法、赋值等方面的错误。我需要做什么才能启用所有默认的linter?
(请纠正我到目前为止所犯的愚蠢错误。)
# Sample code; only warnings are for unknown symbol, unexpected
# tokens, and missing whitespace around binary operator
testing = function(test1, test2)
{
return paste(test, test1)
}
test.var = 1+2发布于 2017-04-27 06:20:41
我认为RStudio诊断与lintr无关。
从控制台运行lint("your-file-to-test.R") (或其他linter)。
这会将文件加载到RStudio的源代码窗格中(如果它还不在那里),运行测试,并在控制台窗格中打开一个新的选项卡"Markers“,其中包含有关您的文件的所有警告。
现在,您可以非常轻松地处理代码,因为两个窗格都会同时显示相关信息。对于新的检查,您必须从控制台重复该命令。(至少我没有找到一种更方便的周期修正、测试、修正的方法。)
发布于 2015-10-20 03:18:31
“意外符号”错误是R解释器的语法错误。您应该提供的完整输出在某种程度上更具信息性:
> lint('test4.r')
test4.r:3:9: style: Use <-, not =, for assignment.
testing = function(test1, test2)
^
test4.r:5:10: error: unexpected symbol
return paste(test, test1)
^
test4.r:8:1: style: Trailing blank lines are superfluous.https://stackoverflow.com/questions/33221019
复制相似问题