Commit e263b57b authored by Leo's avatar Leo

add styles

parent 586599c0
CHANGES in 18.0:
- Add a Style severity label denoted by a T character
- Add leo to APKBUILD_STYLE options and move some style checks to it
CHANGES In 17.2:
- Remove line-above-80-chars [AL27], it was broken anyways
......
......@@ -34,6 +34,16 @@ situations. Should be fixed soon.
Won't directly cause issues during build or when the package is delivered to users.
Should be fixed when convenient
## STYLE (T)
Won't cause any issues, are specific style issues pertinent to a concerned developer
or contributor. the _APKBUILD\_STYLE_ variable can be set to a specific value to enable
a subset of checks that the specific developer or user uses.
Current valid values are:
- leo (style linting for leo)
# Certainty
Certainty is assigned to each tag and indicates how certain a test is that the violation
......@@ -168,13 +178,13 @@ Severity: Minor, Certainity: Certain
The APKBUILD's *pkgname* variable is quoted. It must not be quoted.
Severity: Minor, Certainty: Possible
Severity: Style, Certainty: Possible
## pkgver-quoted [AL4]
The APKBUILD's *pkgver* variable is quoted. It must not be quoted.
Severity: Minor, Certainty: Possible
Severity: Style, Certainty: Possible
## empty-variable [AL5]
......@@ -235,14 +245,14 @@ The APKBUILD has a space character between the name of a function
and the paranthesis that denote it is a function. Remove the superfluous
space.
Severity: Important, Certainty: Certain
Severity: Style, Certainty: Certain
## space-after-function-parenthesis [AL11]
The APKBUILD doesn't have a space after the function parenthesis or has more
than one space. Use only one space after the function parenthesis.
Severity: Important, Certainty: Certain
Severity: Style, Certainty: Certain
## newline-opening-brace [AL12]
......@@ -250,7 +260,7 @@ The APKBUILD has a newline before the opening brace of a function. Put the
opening brace in the same line as the declaration with one space after the
function parenthesis.
Severity: Important, Certainty: Certain
Severity: Style, Certainty: Certain
## superfluous-cd-builddir [AL13]
......
......@@ -74,15 +74,17 @@ unnecessary_return_1() {
}
pkgname_quoted() {
[ "$APKBUILD_STYLE" != "leo" ] && return 0
[ "$SKIP_PKGNAME_QUOTED" ] && return 0
[ "$SKIP_AL3" ] && return 0
scan '^pkgname="[^$]+"' "pkgname must not be quoted" 'AL3' 'MP'
scan '^pkgname="[^$]+"' "pkgname must not be quoted" 'AL3' 'TP'
}
pkgver_quoted() {
[ "$APKBUILD_STYLE" != "leo" ] && return 0
[ "$SKIP_PKGVER_QUOTED" ] && return 0
[ "$SKIP_AL4" ] && return 0
scan '^pkgver="[^$]+"' "pkgver must not be quoted" 'AL4' 'MP'
scan '^pkgver="[^$]+"' "pkgver must not be quoted" 'AL4' 'TP'
}
empty_variable() {
......@@ -123,21 +125,24 @@ function_keyword() {
}
space_before_function_parenthesis() {
[ "$APKBUILD_STYLE" != "leo" ] && return 0
[ "$SKIP_SPACE_BEFORE_FUNCTION_PARENTHESIS" ] && return 0
[ "$SKIP_AL10" ] && return 0
scan '^\t*[^ ]* *\(\)' 'do not use space before function parenthesis' 'AL10' 'IC'
scan '^\t*[^ ]* *\(\)' 'do not use space before function parenthesis' 'AL10' 'TC'
}
space_after_function_parenthesis() {
[ "$APKBUILD_STYLE" != "leo" ] && return 0
[ "$SKIP_SPACE_AFTER_FUNCTION_PARENTHESIS" ] && return 0
[ "$SKIP_AL11" ] && return 0
scan '^\t*[^ ]*\(\)(| *){' 'use one space after function parenthesis' 'AL11' 'IC'
scan '^\t*[^ ]*\(\)(| *){' 'use one space after function parenthesis' 'AL11' 'TC'
}
newline_opening_brace() {
[ "$APKBUILD_STYLE" != "leo" ] && return 0
[ "$SKIP_NEWLINE_OPENING_BRACE" ] && return 0
[ "$SKIP_AL12" ] && return 0
scan '^\t*[^ ]*\(\)$' 'do not use a newline before function opening brace' 'AL12' 'IC'
scan '^\t*[^ ]*\(\)$' 'do not use a newline before function opening brace' 'AL12' 'TC'
}
superfluous_cd_builddir() {
......
......@@ -143,7 +143,7 @@ is_travis() {
pkgver=1
EOF
run $cmd $apkbuild
APKBUILD_STYLE=leo run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL3\].*:pkgname must not be quoted"
}
......@@ -157,7 +157,7 @@ is_travis() {
pkgver=1
EOF
run $cmd $apkbuild
APKBUILD_STYLE=leo run $cmd $apkbuild
[[ $status -eq 0 ]]
}
......@@ -167,7 +167,7 @@ is_travis() {
pkgver="1"
EOF
run $cmd $apkbuild
APKBUILD_STYLE=leo run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL4\].*:pkgver must not be quoted"
}
......@@ -284,7 +284,7 @@ is_travis() {
}
EOF
run $cmd $apkbuild
APKBUILD_STYLE=leo run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL10\].*:do not use space before function parenthesis"
}
......@@ -299,7 +299,7 @@ is_travis() {
}
EOF
run $cmd $apkbuild
APKBUILD_STYLE=leo run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL11\].*:use one space after function parenthesis"
}
......@@ -315,7 +315,7 @@ is_travis() {
}
EOF
run $cmd $apkbuild
APKBUILD_STYLE=leo run $cmd $apkbuild
[[ $status -eq 1 ]]
assert_match "${lines[0]}" "\[AL12\].*:do not use a newline before function opening brace"
}
......
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