Skip to content

Commit

Permalink
fixes #451
Browse files Browse the repository at this point in the history
  • Loading branch information
AshesITR committed Jan 31, 2021
1 parent 00ec310 commit 84cdc87
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
* Set the default `complexity_limit` in `cyclocomp_linter` to 15. This is the same complexity limit that is enforced via
`default_linters` (#693, #695, @AshesITR).
* `lint_package()` now lints files in the `demo` directory by default (#703, @dmurdoch).
* `commented_code_linter()` now no longer lints parts of actual code (#451, @AshesITR)

# lintr 2.0.1

Expand Down
10 changes: 10 additions & 0 deletions R/comment_linters.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ commented_code_linter <- function(source_file) {
line_numbers <- rownames(na.omit(res))
lapply(line_numbers, function(line_number) {
line <- source_file$file_lines[as.numeric(line_number)]
line_code_end <- max(
source_file$full_parsed_content[source_file$full_parsed_content$line1 == line_number &
source_file$full_parsed_content$line2 == line_number, "col2"],
0
)
if (res[line_number, "code.start"] < line_code_end) {
# regex matched a part of actual code
return()
}

is_parsable <- parsable(substr(line,
res[line_number, "code.start"],
res[line_number, "code.end"]))
Expand Down

0 comments on commit 84cdc87

Please sign in to comment.