@@ -3,27 +3,10 @@ load("//tools/skylark:drake_py.bzl", "py_test_isolated")
33#------------------------------------------------------------------------------
44# Internal helper; set up test given name and list of files. Will do nothing
55# if no files given.
6- def _bazel_lint (name , files , ignore ):
6+ def _bazel_lint (name , files ):
77 if files :
8- ignores = ["E%s" % e for e in (ignore or [])]
9-
10- # W504 relates to linebreaks around binary operators; buildifier
11- # disagrees with what pycodestyle wants to do.
12- ignores .append ("W504" )
13-
14- ignores_as_arg = ["--ignore=" + "," .join (ignores )]
158 locations = ["$(locations %s)" % f for f in files ]
169
17- py_test_isolated (
18- name = name + "_codestyle" ,
19- size = "small" ,
20- srcs = ["@drake//tools/lint:bzlcodestyle" ],
21- data = files ,
22- args = ignores_as_arg + locations + ["--max-line-length=80" ],
23- main = "@drake//tools/lint:bzlcodestyle.py" ,
24- tags = ["bzlcodestyle" , "lint" ],
25- )
26-
2710 py_test_isolated (
2811 name = name + "_buildifier" ,
2912 size = "small" ,
@@ -37,32 +20,20 @@ def _bazel_lint(name, files, ignore):
3720#------------------------------------------------------------------------------
3821def bazel_lint (
3922 name = "bazel" ,
40- ignore = None ,
4123 extra_srcs = None ,
4224 exclude = None ):
4325 """
44- Runs the ``bzlcodestyle`` code style checker on all Bazel files in the
45- current directory. The tool is based on the ``pycodestyle`` :pep:`8` code
46- style checker, but always disables certain checks while adding others.
26+ Runs ``buildifier -mode=check`` format checker on all Bazel files in the
27+ current directory.
4728
4829 Args:
4930 name: Name prefix of the test (default = "bazel").
50- ignore: List of errors (as integers, without the 'E') to ignore
51- (default = [265, 302, 305]).
5231 extra_srcs: List of files to lint that would otherwise be missed by the
5332 default glob pattern for Bazel source code.
5433 exclude: List to be passed to the skylark glob function for files that
5534 should not be linted (e.g., vendored files).
56-
57- Example:
58- BUILD:
59- load("//tools/lint:bazel_lint.bzl", "bazel_lint")
60-
61- bazel_lint()
6235 """
6336
64- if ignore == None :
65- ignore = [265 , 302 , 305 ]
6637 if extra_srcs == None :
6738 extra_srcs = []
6839 if exclude == None :
@@ -82,5 +53,4 @@ def bazel_lint(
8253 exclude = exclude ,
8354 allow_empty = True ,
8455 ) + extra_srcs ,
85- ignore = ignore ,
8656 )
0 commit comments