You are right, It's not a script parser at the moment, just counting the number of lines purely.
Blank lines shouldn't be part of the total number of lines, but I'm not sure about the comments, in my opinion commented code should be also part of this lint.
Although I do understand the commented header, as you can see below, could be ignored.
#!/bin/bash
# DESC: this is my script to build my awesome program
# INPUT: BUILD_ID, TARGET, PLATFORM
# OUTPUT: awesome.zip
#
. ./properties.properties
./build.sh $TARGET $PLATFORM $BUILD_ID
#if [ $? -gt 0 ] ; then
# echo "DEBUG=true" > status.properties
#fi
echo "DEBUG=false" > status.properties
My ideal use case would be:
- Script the logic, helper and information in the script
- Enable a --help flag to prompt the information about how to use it
- Upload the script to the SCM with a semantic name about what it does.
- And describe the aim of it in the job description.
Something like:
1) build_platform.sh
#!/bin/bash
# DESC: this is my script to build my awesome program
# INPUT: BUILD_ID, TARGET, PLATFORM
# OUTPUT: awesome.zip
# OPTIONS: --build --help
if [ "$1" == "--help" ]; then
echo "Usage: `basename $0` [--build TARGET PLATFORM BUILD_ID | --help] "
exit 0
fi
...
...
echo "DEBUG=false" > status.properties
2)
job ('myjob') {
description('This Job will generate an awesome zip based on the Platform and Target')
parameters {
stringParam('TARGET', 'default', 'Build target')
stringParam('PLATFORM', 'default', 'Build platform')
}
scm {
github('test/awesome.git')
}
steps {
shell("./build.sh $TARGET $PLATFORM $BUILD_ID")
}
}
Rather than:
job ('myjob') {
description('This Job will generate an awesome zip based on the Platform and Target')
parameters {
stringParam('TARGET', 'default', 'Build target')
stringParam('PLATFORM', 'default', 'Build platform')
}
scm {
github('test/awesome.git')
}
steps {
shell """
#!/bin/bash
# DESC: this is my script to build my awesome program
# INPUT: BUILD_ID, TARGET, PLATFORM
# OUTPUT: awesome.zip
#
. ./properties.properties
./build.sh $TARGET $PLATFORM $BUILD_ID
#if [ $? -gt 0 ] ; then
# echo "DEBUG=true" > status.properties
#fi
echo "DEBUG=false" > status.properties
"""
}
}
What do you think? Does it make sense to only care about the non blank lines?
Cheers
Martin Jost, let's follow up the comment lines ticket in the below cloned one:
JENKINS-46146