Skip to content

Commit

Permalink
Merge pull request #89 from LedgerHQ/tdj/check_app_name
Browse files Browse the repository at this point in the history
Add check on the app name unicity
  • Loading branch information
tdejoigny-ledger authored Sep 27, 2023
2 parents b1641b8 + b2b2719 commit 110eb00
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/app_load_params_lint.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env python3

import json
import difflib
from argparse import ArgumentParser
from pathlib import Path
from app_load_params_utils import format_database
from app_load_params_check import APP_LOAD_PARAMS_VALUE_CHECK
import json
import difflib


def check_database_lint(database_path: Path):
Expand All @@ -15,7 +15,7 @@ def check_database_lint(database_path: Path):
database = json.loads(database_str)

for variant, params in database.items():
for param, value in params.items():
for param, _ in params.items():
if param not in APP_LOAD_PARAMS_VALUE_CHECK:
print(f"[ERROR] Not allowed '{param}' in variant '{variant}'")
ret = -1
Expand All @@ -40,13 +40,14 @@ def check_database_appnames(database_path: Path):
database_str = f.read()
database = json.loads(database_str)

db_rev = {v["appName"]: k for k, v in database.items()}
db_rev = {v["appName"].lower().replace(" ","").replace("_", "").replace("-", ""): k for k,
v in database.items()}

for variant, params in database.items():
app_name = params["appName"]
db_rev_variant = db_rev[app_name]
db_rev_variant = db_rev[app_name.lower().replace(" ","").replace("_", "").replace("-", "")]
if db_rev_variant != variant:
print(f"[ERROR] Conflict on appName between '{db_rev_variant}' and '{variant}'")
print(f"[ERROR] Conflict on appName between '{db_rev_variant}' and '{variant}'. AppName shall be unique ('-',' ' and '_' are stripped)")
ret = -1

if ret != 0:
Expand Down

0 comments on commit 110eb00

Please sign in to comment.