Skip to content

Commit dd35762

Browse files
Fix W006 wrong flag
1 parent 6b59de0 commit dd35762

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • src/rsmetacheck/scripts/warnings

src/rsmetacheck/scripts/warnings/w006.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from typing import Dict, List
22
import re
33

4+
from rsmetacheck.utils.pitfall_utils import extract_metadata_source_filename
5+
46

57
def is_valid_identifier(identifier: str) -> bool:
68
"""
@@ -95,6 +97,7 @@ def detect_identifier_name_warning(somef_data: Dict, file_name: str) -> Dict:
9597

9698
codemeta_identifier = None
9799
codemeta_source = None
100+
codemeta_has_valid_id = False
98101
other_identifier = None
99102
other_source = None
100103
other_identifiers = []
@@ -110,10 +113,18 @@ def detect_identifier_name_warning(somef_data: Dict, file_name: str) -> Dict:
110113

111114
if is_codemeta:
112115
if "result" in entry and "value" in entry["result"]:
113-
if codemeta_identifier is None: # Use first one found
114-
codemeta_identifier = entry["result"]["value"]
116+
if codemeta_identifier is None:
117+
raw_value = entry["result"]["value"]
115118
codemeta_source = source
116-
break # Stop at first codemeta identifier
119+
if isinstance(raw_value, list):
120+
codemeta_has_valid_id = any(
121+
isinstance(item, str) and is_valid_identifier(item)
122+
for item in raw_value
123+
)
124+
codemeta_identifier = ", ".join(str(item) for item in raw_value) if raw_value else None
125+
else:
126+
codemeta_identifier = raw_value
127+
break
117128

118129
for entry in identifier_entries:
119130
source = entry.get("source", "")
@@ -142,12 +153,14 @@ def detect_identifier_name_warning(somef_data: Dict, file_name: str) -> Dict:
142153

143154
result["codemeta_identifier"] = codemeta_identifier
144155
result["codemeta_source"] = codemeta_source
156+
result["metadata_source_file"] = extract_metadata_source_filename(codemeta_source) if codemeta_source else "codemeta.json"
145157
result["other_identifier"] = other_identifier
146158
result["other_source"] = other_source
147159
result["other_identifiers"] = other_identifiers
148160
result["has_valid_identifier_elsewhere"] = len(other_identifiers) > 0
149161

150162
if (codemeta_identifier and
163+
not codemeta_has_valid_id and
151164
not is_valid_identifier(codemeta_identifier) and
152165
other_identifier):
153166
result["has_warning"] = True

0 commit comments

Comments
 (0)