Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ The `repositories.json` file should be structured as follows:

```bash
poetry run rsmetacheck --input repositories.json \
--somef-output ./results/somef \
--pitfalls-output ./results/pitfalls \
--analysis-output ./results/summary.json
```
Expand Down Expand Up @@ -127,7 +128,7 @@ poetry run rsmetacheck --input https://github.com/tidyverse/tidyverse --verbose

The tool will:

- Process all JSON files in the `somef_outputs` (by default created by the tool) directory
- Process all JSON files in the SoMEF output directory (by default `somef_outputs` created by the tool)
- Display progress messages showing detected pitfalls
- Generate JSON-LD files of detailed Pitfalls and Warnings detected by the tool in `output_1_pitfalls.jsonld`,
`output_2_pitfalls.jsonld`, etc... in `pitfalls` (by default created by the tool) directory
Expand Down
7 changes: 6 additions & 1 deletion src/metacheck/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def cli():
default=os.path.join(os.getcwd(), "pitfalls_outputs"),
help="Directory to store pitfall JSON-LD files (default: ./pitfalls_outputs)."
)
parser.add_argument(
"--somef-output",
default=os.path.join(os.getcwd(), "somef_outputs"),
help="Directory to store SoMEF output files (default: ./somef_outputs)."
)
parser.add_argument(
"--analysis-output",
default=os.path.join(os.getcwd(), "analysis_results.json"),
Expand Down Expand Up @@ -62,7 +67,7 @@ def cli():

else:
threshold = args.threshold
somef_output_dir = os.path.join(os.getcwd(), "somef_outputs")
somef_output_dir = args.somef_output

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

Expand Down
3 changes: 2 additions & 1 deletion src/metacheck/detect_pitfalls_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ def detect_all_pitfalls(json_files: Iterable[Path], pitfalls_output_dir: Union[s
except Exception as e:
print(f"Error creating JSON-LD for {json_file.name}: {e}")

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

for i, count in enumerate(pitfall_counts):
pitfall_code_str = pitfall_detectors[i][1]
results["pitfalls & warnings"][i]["pitfall"] = f"https://w3id.org/rsmetacheck/catalog/#{pitfall_code_str}"
results["pitfalls & warnings"][i]["count"] = count
if total_repos > 0:
results["pitfalls & warnings"][i]["percentage"] = round((count / total_repos) * 100, 2)
Expand Down
7 changes: 2 additions & 5 deletions src/metacheck/utils/json_ld_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@ def create_pitfall_jsonld(somef_data: Dict, pitfall_results: List[Dict], file_na
"""
Create a JSON-LD structure for detected pitfalls following the sample format.
"""
import hashlib
software_info = extract_software_info_from_somef(somef_data)
description_info = extract_description_info(somef_data)

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

output_val = "true" if has_issue else "false"
evidence_val = format_evidence_text(pitfall_code, pitfall_result) if has_issue else f"{pitfall_code} not detected:"
suggestion_val = get_suggestion_text(pitfall_code) if has_issue else ""
suggestion_val = get_suggestion_text(pitfall_code) if has_issue else "N/A"

check_result = {
"@type": "CheckResult",
Expand All @@ -529,13 +528,11 @@ def create_pitfall_jsonld(somef_data: Dict, pitfall_results: List[Dict], file_na
},
"process": get_pitfall_description(pitfall_code),
"status": {"@id": "schema:CompletedActionStatus"},
"pitfall": f"https://w3id.org/rsmetacheck/catalog/#{pitfall_code}",
"output": output_val,
"evidence": evidence_val,
"suggestion": suggestion_val
}

check_hash = hashlib.sha256(json.dumps(check_result, sort_keys=True).encode("utf-8")).hexdigest()
check_result["checkId"] = check_hash

jsonld_output["checks"].append(check_result)

Expand Down