Skip to content

Commit a513aae

Browse files
authored
Merge pull request #1076 from lightninglabs/linter-fix
scripts: exclude backward compatible versions from linter
2 parents 3cb337e + 04fb5c4 commit a513aae

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

scripts/check-go-version-dockerfile.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ exception_list=(
3434
# Exclude the tools Dockerfile as otherwise the linter may need to be
3535
# considered every time the Go version is updated.
3636
"./tools/Dockerfile"
37+
"./itest/backward-compat"
3738
)
3839

3940
# is_exception checks if a file is in the exception list.
@@ -43,6 +44,13 @@ is_exception() {
4344
if [ "$file" == "$exception" ]; then
4445
return 0
4546
fi
47+
48+
# Check if the file is inside an excluded directory.
49+
# The trailing slash ensures that similarly named directories
50+
# (e.g., ./itest/backward-compat_other) are not mistakenly excluded.
51+
if [[ "$file/" == "$exclude"* ]]; then
52+
return 0
53+
fi
4654
done
4755
return 1
4856
}

scripts/check-go-version-yaml.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,40 @@ fi
6363

6464
target_go_version="$1"
6565

66+
# File paths to be excluded from the check.
67+
exception_list=(
68+
"./itest/backward-compat"
69+
)
70+
71+
# is_exception checks if a file is in the exception list.
72+
is_exception() {
73+
local file="$1"
74+
for exception in "${exception_list[@]}"; do
75+
if [ "$file" == "$exception" ]; then
76+
return 0
77+
fi
78+
79+
# Check if the file is inside an excluded directory.
80+
# The trailing slash ensures that similarly named directories
81+
# (e.g., ./itest/backward-compat_other) are not mistakenly excluded.
82+
if [[ "$file/" == "$exclude"* ]]; then
83+
return 0
84+
fi
85+
done
86+
return 1
87+
}
88+
6689
# Search for YAML files in the current directory and its subdirectories.
6790
yaml_files=$(find . -type f \( -name "*.yaml" -o -name "*.yml" \))
6891

6992
# Check each YAML file.
7093
for file in $yaml_files; do
94+
# Skip the file if it is in the exception list.
95+
if is_exception "$file"; then
96+
echo "Skipping $file"
97+
continue
98+
fi
99+
71100
check_go_version_yaml "$file" "$target_go_version"
72101
check_go_version_env_variable "$file" "$target_go_version"
73102
done

0 commit comments

Comments
 (0)