Skip to content

Commit 8f94680

Browse files
committed
[SPARK-8495][SparkR] Add a .lintr file to validate the SparkR files and the lint-r script
Thank Shivaram Venkataraman for your support. This is a prototype script to validate the R files.
1 parent 3eaed87 commit 8f94680

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

R/pkg/.lintr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
linters: with_defaults(line_length_linter(100))
2+
exclusions: list("inst/profile/general.R" = 1, "inst/profile/shell.R")

dev/lint-r

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
20+
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
21+
SPARK_ROOT_DIR="$(dirname $SCRIPT_DIR)"
22+
23+
24+
if ! type "Rscript" > /dev/null; then
25+
echo "ERROR: You should install R"
26+
exit
27+
fi
28+
29+
`which Rscript` --vanilla "$SPARK_ROOT_DIR/dev/lint-r.R" "$SPARK_ROOT_DIR"

dev/lint-r.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
# Installs lintr from Github.
19+
# NOTE: The CRAN's version is too old to adapt to our rules.
20+
if ("lintr" %in% row.names(installed.packages()) == FALSE) {
21+
devtools::install_github("jimhester/lintr")
22+
}
23+
library(lintr)
24+
25+
argv <- commandArgs(TRUE)
26+
SPARK_ROOT_DIR <- as.character(argv[1])
27+
28+
path.to.package <- file.path(SPARK_ROOT_DIR, "R", "pkg")
29+
lint_package(path.to.package, cache = FALSE)

0 commit comments

Comments
 (0)