Commit 3716b257 authored by Leo's avatar Leo

Add literal-integer-is-quoted

resolves #21
parent 080d6a91
CHANGES in 18.2:
- remove APKBUILD_STYLE=leo from some tests for checks that are now part
- Remove APKBUILD_STYLE=leo from some tests for checks that are now part
of the main suite
- Add literal-integer-is-quoted
CHANGES in 18.1:
......
......@@ -303,6 +303,12 @@ Severity: Serious, Certainty: Certain
## _builddir-is-set [AL26]
\_builddir is set instead of builddir, which is an old variable from before builddir
existed as a concept understood by abuild
existed as a concept understood by abuild.
Severity: Serious, Certainty: Certain
## literal-integer-is-quoted [AL28]
A variable declaration containing only integers should not be quoted.
Severity: Minor, Certainty: Certain
......@@ -215,6 +215,12 @@ _builddir_is_set() {
fi
}
literal_integer_is_quoted() {
[ "$SKIP_LITERAL_INTEGER_IS_QUOTED" ] && return 0
[ "$SKIP_AL28" ] && return 0
scan '^[A-Za-z0-9_]*=('\''|")[0-9]+("|'\'')' 'literal integers must not be quoted' 'AL28' 'MC'
}
_run_apkbuild_leo() {
# Run all tests from Leo
pkgname_quoted &
......@@ -248,6 +254,7 @@ for apkbuild; do
space_before_function_parenthesis &
space_after_function_parenthesis &
newline_opening_brace &
literal_integer_is_quoted &
# Don't perform these checks on packages from main
if ! [ -z "${apkbuild##*main/*}" ]; then
......
......@@ -164,7 +164,7 @@ is_travis() {
@test 'pkgver should not be quoted' {
cat <<-"EOF" >$apkbuild
pkgname=a
pkgver="1"
pkgver="aa"
EOF
APKBUILD_STYLE=leo run $cmd $apkbuild
......@@ -476,4 +476,60 @@ is_travis() {
[[ $status -eq 0 ]]
}
@test 'pkgver is literal integer but is double-quoted' {
cat <<-"EOF" >$apkbuild
pkgver="1"
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL28\].*:literal integers must not be quoted"
}
@test 'pkgver is literal integer but is single-quoted' {
cat <<-"EOF" >$apkbuild
pkgver='1'
EOF
run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL28\].*:literal integers must not be quoted"
}
@test 'pkgver is literal integer and is not quoted' {
cat <<-"EOF" >$apkbuild
pkgver=2
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'pkgver is not an literal integer and is double-quoted' {
cat <<-"EOF" >$apkbuild
pkgver="1.0"
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'pkgver is not an literal integer and is single-quoted' {
cat <<-"EOF" >$apkbuild
pkgver='1.0'
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
@test 'pkgver is not an literal integer and is not quoted' {
cat <<-"EOF" >$apkbuild
pkgver=1.0
EOF
run $cmd $apkbuild
[[ $status -eq 0 ]]
}
# vim: noexpandtab
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment