-
Notifications
You must be signed in to change notification settings - Fork 998
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For mistakes that are easy to fix automatically, Coccinelle patches may be written. If a patch finds a mistake, the linter will ask the human to fix either the code or the patch.
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
cocci_linter = if (!nzchar(Sys.which("spatch"))) function(...) {} else function(c_obj) { | ||
bad <- FALSE | ||
for (spfile in list.files(".ci/linters/cocci", full.names = TRUE)) { | ||
# Coccinelle parser gets confused sometimes, so ignore stderr and the exit code | ||
out = suppressWarnings(system2( | ||
"spatch", | ||
shQuote(c( | ||
"--sp-file", spfile, c_obj$path, "--recursive-includes", | ||
"-I", R.home("include"), "-I", "src" | ||
)), | ||
stdout = TRUE, stderr = FALSE | ||
)) | ||
if (length(out) > 0) { | ||
cat(sprintf("In file '%s', Coccinelle patch '%s' recommends the following changes:\n", c_obj$path, spfile)) | ||
writeLines(out) | ||
bad <- TRUE | ||
} | ||
} | ||
if (bad) stop("Please apply the changes above or fix the linter") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@@ | ||
type T; | ||
T* E; | ||
@@ | ||
- (T*) | ||
E |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters