mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
Merge pull request #22 from YunoHost/18_arg_retrieval_env_var
[enh] #18: check arguments retrieval is done with env var.
This commit is contained in:
commit
b9bbb7d93c
1 changed files with 32 additions and 0 deletions
|
@ -186,6 +186,7 @@ def check_script(path, script_name, script_nbr):
|
|||
if script_nbr < 5:
|
||||
return_code = check_verifications_done_before_modifying_system(script) or return_code
|
||||
return_code = check_set_usage(script_name, script) or return_code
|
||||
return_code = check_arg_retrieval(script) or return_code
|
||||
|
||||
return return_code
|
||||
|
||||
|
@ -303,6 +304,37 @@ def check_set_usage(script_name, script):
|
|||
|
||||
return return_code
|
||||
|
||||
|
||||
def check_arg_retrieval(script):
|
||||
"""
|
||||
Check arguments retrival from manifest is done with env var $YNH_APP_ARG_* and not with arg $1
|
||||
env var was found till line ~30 on scripts. Stop file checking at L30: This could avoid wrong positives
|
||||
Check only from '$1' to '$10' as 10 arg retrieval is already a lot.
|
||||
"""
|
||||
return_code = 0
|
||||
present = False
|
||||
exitFlag = False
|
||||
|
||||
for line_nbr, line in enumerate(script):
|
||||
for i in range(1, 10):
|
||||
if "$" + str(i) in line:
|
||||
print_wrong("At line {}: \"{}\"".format(line_nbr, line))
|
||||
present = True
|
||||
if line_nbr > 30:
|
||||
exitFlag = True
|
||||
break
|
||||
if exitFlag == True:
|
||||
break
|
||||
|
||||
if present:
|
||||
print_wrong("Argument retrieval from manifest with $1 is deprecated. You may use $YNH_APP_ARG_*")
|
||||
print_wrong("For more details see: https://yunohost.org/#/packaging_apps_arguments_management_en")
|
||||
return_code = 1
|
||||
else:
|
||||
print_right("Argument retrieval from manifest seems to be done with environement variables")
|
||||
|
||||
return return_code
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.system("clear")
|
||||
|
||||
|
|
Loading…
Reference in a new issue