mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
[enh] add check for deprecated methods to manage app settings and propose helpers.
This commit is contained in:
parent
b89eb4c3e8
commit
640b3cd5aa
1 changed files with 27 additions and 0 deletions
|
@ -142,6 +142,7 @@ def check_script(path, script_name):
|
|||
check_script_header_presence(script)
|
||||
check_sudo_prefix_commands(script)
|
||||
check_verifications_done_before_modifying_system(script)
|
||||
check_non_helpers_usage(script)
|
||||
|
||||
|
||||
def check_script_header_presence(script):
|
||||
|
@ -205,6 +206,32 @@ def check_verifications_done_before_modifying_system(script):
|
|||
print_right(
|
||||
"Verifications (with 'ynh_die' or 'exit' commands) are done before any system modification.")
|
||||
|
||||
def check_non_helpers_usage(script):
|
||||
"""
|
||||
check if deprecated commands are used and propose helpers:
|
||||
- 'yunohost app setting' –> ynh_app_setting_(set,get,delete)
|
||||
- 'exit' –> 'ynh_die'
|
||||
"""
|
||||
i, ok = 0, 1
|
||||
while i < len(script):
|
||||
if "yunohost app setting" in script[i]:
|
||||
print_wrong("Line {}: 'yunohost app setting' command is deprecated, please use helpers ynh_app_setting_(set,get,delete).".format(i + 1))
|
||||
ok = 0
|
||||
i += 1
|
||||
if ok == 1:
|
||||
print_right("Only helpers are used")
|
||||
else:
|
||||
print_wrong("Helpers documentation: https://yunohost.org/#/packaging_apps_helpers\ncode: https://github.com/YunoHost/yunohost/…helpers")
|
||||
|
||||
i, ok = 0, 1
|
||||
while i < len(script):
|
||||
if "exit" in script[i]:
|
||||
print_wrong("Line {}: 'exit' command shouldn't be used. Use 'ynh_die' helper instead.".format(i + 1))
|
||||
ok = 0
|
||||
i += 1
|
||||
if ok == 1:
|
||||
print_right("no 'exit' command found: 'ynh_die' helper is possibly used")
|
||||
|
||||
if __name__ == '__main__':
|
||||
os.system("clear")
|
||||
if len(sys.argv) != 2:
|
||||
|
|
Loading…
Reference in a new issue