The case
statement should be used only to clearly define some new branches in the control flow. As soon as a pattern clause contains
too many statements, this highly decreases the readability of the overall control flow statement. In such case, the content of the pattern clause
should be extracted into a dedicated function.
Noncompliant code example
With the default threshold of 5:
case "$x" in
0) # Noncompliant: 6 lines till next pattern
statement1
statement2
statement3
statement4
statement5
;;
1)
# ...
;;
esac
Compliant solution
case "$x" in
0)
do_something
;;
1)
# ...
;;
esac
do_something() {
statement1
statement2
statement3
statement4
statement5
}