Skip to content

Commit a9d300f

Browse files
authored
chore: cleanup maybe patterns (#139)
1 parent e2fecbb commit a9d300f

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

format/repositories.bzl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Needed until Bazel 7 allows MODULE.bazel to directly call repository rules.
66
load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive", _http_file = "http_file", _http_jar = "http_jar")
77
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
88

9-
def http_archive(name, **kwargs):
10-
maybe(_http_archive, name = name, **kwargs)
9+
def http_archive(**kwargs):
10+
maybe(_http_archive, **kwargs)
1111

12-
def http_file(name, **kwargs):
13-
maybe(_http_file, name = name, **kwargs)
12+
def http_file(**kwargs):
13+
maybe(_http_file, **kwargs)
1414

15-
def http_jar(name, **kwargs):
16-
maybe(_http_jar, name = name, **kwargs)
15+
def http_jar(**kwargs):
16+
maybe(_http_jar, **kwargs)
1717

1818
def fetch_pmd():
1919
http_archive(

lint/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ bzl_library(
126126
visibility = ["//visibility:public"],
127127
deps = [
128128
"//lint/private:lint_aspect",
129+
"//lint/private:maybe",
129130
"@bazel_skylib//rules:native_binary",
130131
"@bazel_tools//tools/build_defs/repo:http.bzl",
131132
"@bazel_tools//tools/build_defs/repo:utils.bzl",

lint/private/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ bzl_library(
77
visibility = ["//lint:__subpackages__"],
88
)
99

10+
bzl_library(
11+
name = "maybe",
12+
srcs = ["maybe.bzl"],
13+
visibility = ["//lint:__subpackages__"],
14+
)
15+
1016
js_binary(
1117
name = "patcher",
1218
entry_point = "patcher.mjs",

lint/private/maybe.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"maybe utilities"
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive")
4+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
5+
6+
def maybe_http_archive(**kwargs):
7+
maybe(_http_archive, **kwargs)

lint/shellcheck.bzl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ shellcheck = shellcheck_aspect(
1717
"""
1818

1919
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
20-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
21-
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
2220
load("//lint/private:lint_aspect.bzl", "filter_srcs", "report_file")
21+
load("//lint/private:maybe.bzl", http_archive = "maybe_http_archive")
2322

2423
_MNEMONIC = "shellcheck"
2524

@@ -125,8 +124,7 @@ def fetch_shellcheck(version = SHELLCHECK_VERSIONS.keys()[0]):
125124
version: a version of shellcheck that we have mirrored, e.g. `v0.9.0`
126125
"""
127126
for plat, sha256 in SHELLCHECK_VERSIONS[version].items():
128-
maybe(
129-
http_archive,
127+
http_archive(
130128
name = "shellcheck_{}".format(plat),
131129
url = "https://github.com/koalaman/shellcheck/releases/download/{version}/shellcheck-{version}.{plat}.tar.xz".format(
132130
version = version,

0 commit comments

Comments
 (0)