Skip to content

Commit 5a924bd

Browse files
committed
fix bug in script
1 parent 3c024e0 commit 5a924bd

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

scripts/knowledgebase-checker/knowledgebase_article_checker.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ def check_yaml_tags(directory, allowed_tags):
3838
try:
3939
frontmatter_data = yaml.safe_load(frontmatter_str)
4040
# check tags exist and are one of the allowed tags
41-
is_correct = False
41+
tagged_correct = False
42+
has_description = False
43+
has_precontent_tags = False
4244

4345
# check that KB articles are tagged with one of the correct tags
4446
if 'tags' in frontmatter_data and frontmatter_data['tags'] is not None:
4547
if all(tag in allowed_tags for tag in frontmatter_data['tags']):
46-
is_correct = True
47-
else:
48-
is_correct = False
48+
tagged_correct = True
4949

5050
# check that KB articles have a description
5151
if 'description' in frontmatter_data and frontmatter_data['description'] is not None:
52-
is_correct = True
53-
else:
54-
is_correct = False
52+
has_description = True
5553

5654
# check that KB articles contain the appropriate tags (given by pattern below) before the article content:
5755

@@ -60,12 +58,10 @@ def check_yaml_tags(directory, allowed_tags):
6058

6159
pattern = r"\{frontMatter.description\}\n\{\/\* truncate \*\/\}\n"
6260
if bool(re.search(pattern, content, flags=re.DOTALL)):
63-
is_correct = True
64-
else:
65-
is_correct = False
61+
has_precontent_tags = True
6662

6763
# add filename as appropriate if issues occured
68-
if is_correct is True:
64+
if tagged_correct and has_description and has_precontent_tags:
6965
correctly_tagged_files.append(filename)
7066
else:
7167
incorrectly_tagged_files.append(filename)

0 commit comments

Comments
 (0)