mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
add test of common file
This commit is contained in:
parent
e89e613f9e
commit
9f32e06dcc
1 changed files with 22 additions and 0 deletions
|
@ -402,6 +402,7 @@ class Script():
|
|||
self.check_set_usage()
|
||||
self.check_helper_usage_dependencies()
|
||||
self.check_deprecated_practices()
|
||||
self.check_source_common()
|
||||
|
||||
def check_verifications_done_before_modifying_system(self):
|
||||
"""
|
||||
|
@ -518,6 +519,26 @@ class Script():
|
|||
)
|
||||
|
||||
|
||||
def check_source_common(self):
|
||||
#test for standard execution
|
||||
if script["name"] in ["install","upgrade","remove"]:
|
||||
count_common=len(re.findall("^source _common.sh",script["raw"],flags=re.MULTILINE))
|
||||
if count_common == 0:
|
||||
print_warning("Calling _common.sh seams not present in this script, please add \"source _common.sh\"")
|
||||
elif count_common > 1:
|
||||
print_warning("Duplicates calls to _common.sh, please clean your code")
|
||||
|
||||
#test for "save" files
|
||||
else:
|
||||
count_common=len(re.findall("^source _common.sh",script["raw"],flags=re.MULTILINE))
|
||||
count_common_save=len(re.findall("^source ../settings/scripts/_common.sh",script["raw"],flags=re.MULTILINE))
|
||||
if count_common > 0 and count_common_save == 0:
|
||||
print_error("You must call _common.sh with \"source ../settings/scripts/_common.sh\" in this script to respect context execution")
|
||||
elif count_common == 0 and count_common_save == 0:
|
||||
print_warning("Calling _common.sh seams not present in this script, please add \"source ../settings/scripts/_common.sh\" in this script to respect context execution")
|
||||
elif count_common_save > 1:
|
||||
print_warning("Duplicates calls to _common.sh, please clean your code")
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("Give one app package path.")
|
||||
|
@ -526,6 +547,7 @@ def main():
|
|||
app_path = sys.argv[1]
|
||||
header(app_path)
|
||||
App(app_path).analyze()
|
||||
|
||||
sys.exit(return_code)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue