Skip to content

Commit ed95768

Browse files
Users can now specify the location for SoMEF outputs issue #53, along side some minor changes to the report (wid, N/A instead of empty suggestions)
1 parent 28ade2e commit ed95768

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ The `repositories.json` file should be structured as follows:
9797

9898
```bash
9999
poetry run rsmetacheck --input repositories.json \
100+
--somef-output ./results/somef \
100101
--pitfalls-output ./results/pitfalls \
101102
--analysis-output ./results/summary.json
102103
```
@@ -127,7 +128,7 @@ poetry run rsmetacheck --input https://github.com/tidyverse/tidyverse --verbose
127128

128129
The tool will:
129130

130-
- Process all JSON files in the `somef_outputs` (by default created by the tool) directory
131+
- Process all JSON files in the SoMEF output directory (by default `somef_outputs` created by the tool)
131132
- Display progress messages showing detected pitfalls
132133
- Generate JSON-LD files of detailed Pitfalls and Warnings detected by the tool in `output_1_pitfalls.jsonld`,
133134
`output_2_pitfalls.jsonld`, etc... in `pitfalls` (by default created by the tool) directory

src/metacheck/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ def cli():
2323
default=os.path.join(os.getcwd(), "pitfalls_outputs"),
2424
help="Directory to store pitfall JSON-LD files (default: ./pitfalls_outputs)."
2525
)
26+
parser.add_argument(
27+
"--somef-output",
28+
default=os.path.join(os.getcwd(), "somef_outputs"),
29+
help="Directory to store SoMEF output files (default: ./somef_outputs)."
30+
)
2631
parser.add_argument(
2732
"--analysis-output",
2833
default=os.path.join(os.getcwd(), "analysis_results.json"),
@@ -62,7 +67,7 @@ def cli():
6267

6368
else:
6469
threshold = args.threshold
65-
somef_output_dir = os.path.join(os.getcwd(), "somef_outputs")
70+
somef_output_dir = args.somef_output
6671

6772
print(f"Detected {len(args.input)} input(s):")
6873

src/metacheck/detect_pitfalls_main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ def detect_all_pitfalls(json_files: Iterable[Path], pitfalls_output_dir: Union[s
374374
except Exception as e:
375375
print(f"Error creating JSON-LD for {json_file.name}: {e}")
376376

377-
# Capture commit ID in evaluated_repositories summary
378377
try:
379378
repo_name = json_file.name
380379
if "full_name" in somef_data and somef_data["full_name"]:
@@ -413,6 +412,8 @@ def detect_all_pitfalls(json_files: Iterable[Path], pitfalls_output_dir: Union[s
413412
results["summary"]["total_warnings_detected"] = total_warnings
414413

415414
for i, count in enumerate(pitfall_counts):
415+
pitfall_code_str = pitfall_detectors[i][1]
416+
results["pitfalls & warnings"][i]["pitfall"] = f"https://w3id.org/rsmetacheck/catalog/#{pitfall_code_str}"
416417
results["pitfalls & warnings"][i]["count"] = count
417418
if total_repos > 0:
418419
results["pitfalls & warnings"][i]["percentage"] = round((count / total_repos) * 100, 2)

src/metacheck/utils/json_ld_utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,6 @@ def create_pitfall_jsonld(somef_data: Dict, pitfall_results: List[Dict], file_na
484484
"""
485485
Create a JSON-LD structure for detected pitfalls following the sample format.
486486
"""
487-
import hashlib
488487
software_info = extract_software_info_from_somef(somef_data)
489488
description_info = extract_description_info(somef_data)
490489

@@ -516,7 +515,7 @@ def create_pitfall_jsonld(somef_data: Dict, pitfall_results: List[Dict], file_na
516515

517516
output_val = "true" if has_issue else "false"
518517
evidence_val = format_evidence_text(pitfall_code, pitfall_result) if has_issue else f"{pitfall_code} not detected:"
519-
suggestion_val = get_suggestion_text(pitfall_code) if has_issue else ""
518+
suggestion_val = get_suggestion_text(pitfall_code) if has_issue else "N/A"
520519

521520
check_result = {
522521
"@type": "CheckResult",
@@ -529,13 +528,11 @@ def create_pitfall_jsonld(somef_data: Dict, pitfall_results: List[Dict], file_na
529528
},
530529
"process": get_pitfall_description(pitfall_code),
531530
"status": {"@id": "schema:CompletedActionStatus"},
531+
"pitfall": f"https://w3id.org/rsmetacheck/catalog/#{pitfall_code}",
532532
"output": output_val,
533533
"evidence": evidence_val,
534534
"suggestion": suggestion_val
535535
}
536-
537-
check_hash = hashlib.sha256(json.dumps(check_result, sort_keys=True).encode("utf-8")).hexdigest()
538-
check_result["checkId"] = check_hash
539536

540537
jsonld_output["checks"].append(check_result)
541538

0 commit comments

Comments
 (0)